
// this script must be included/executed within the div tag that
// contains the commission junction link which is to be redirected
// after a brief delay which gives time to set the tracking cookies 

/////////////////////////////////////////////////////////
// CONFIGURABLE

// this variable holds the url of the page to which the
// visitor will be redirected after a short delay period
var cj__destination = 'http://www.avg.com/us.homepage';

// END OF CONFIGURABLE
/////////////////////////////////////////////////////////



// place a div tag at the current location in 
// the document so that we can find the enclosing
// div tag and ultimately track down the cj link
document.write('<div id="cj_tracer"></div>');

// find our current enclosing parent using the
// tracer div that we just put onto the page    
var div = document.getElementById('cj_tracer');
var container = div.parentNode;

// establish a global reference
// to the new window we will open    
var cj__window;
    
// now traverse the children of the
// current container to find the 
// commission junction link that 
// we intend to alter to new window
var nodes = container.childNodes;    
for (var i = 0; i<nodes.length; i++)
{
  if ((nodes[i].tagName == 'a') || (nodes[i].tagName == 'A'))
  {
    // we are going to alter the behavior of the link so that it will
    // open a new window with javascript and send the visitor to an
    // intermediate page, once at the intermediate page, the visitor will
    // be immediately taken to the destination of the commission junction
    // link, thereby, properly crediting the referral and setting the 
    // tracking cookies, because the visitor is using a window which we 
    // have created with javascript we have limited control over this 
    // window and can change the "href" location of it after a short delay
    // to ultimately get the visitor to the us version of the target site    
     nodes[i].onclick = function() {     
       cj__window = window.open('standby.html', 'standby');
       return false;
     };
        
     // make sure the link
     // doesn't go anywhere
     // it its default action
     nodes[i].href='#';
  }
}

// this function will be called by 
// the intermediate page when its 
// ready to send the user to the
// commission junction destination
function cj__redirect(delay) 
{
  // this will cause a redirection after
  // the supplied number of milliseconds
  setTimeout('_cj__redirect()', delay);
}

// this simple function will perform
// the redirect action to the us
// version of the target page
function _cj__redirect() {
  cj__window.location.href = cj__destination;
}