//Xeinet Media Inc © 2009. Version 1.1.5  All rights reserved. This script is the property of Xeinet Media Inc
//and may only be used by authorized person(s) and companies. It may not be altered in anyway.
var AD_NODE_URL = "http://traffic.xeinet.com/";
var SESSION_POP_COUNT=1;
var DAY_POP_COUNT=1;
var ORDER_ID = "-1";
var browserCheck = (document.all) ? 1 : 0;
var DBG = false;

function AddChecker(){ 
    var c = get_cookie('wta_pop')== '' ? 0: get_cookie('wta_pop');
      if (parseInt(c) < SESSION_POP_COUNT){
        setTimeout("delayCheck()",200);
        var cVal = "wta_pop=" + (parseInt(c) + 1)  + ";"
        document.cookie= cVal;
      }
      else { if(DBG){setTimeout("delayCheck()",200);}}
}

function delayCheck(){
    GetOrderId(AD_NODE_URL + "clickOrderCheck.aspx",FLOW_ID,"callbackFunction");
}

function GetOrderId(url,flowid,callbackName){
    if (url.indexOf("?") > -1){ url += "&cb="; }else{url += "?cb="; }
    url += callbackName + "&fid=" + flowid; url += "&d=" + new Date().getTime().toString(); //prevent caching     
    try{var script = document.createElement("script");script.setAttribute("src",url);script.setAttribute("type","text/javascript");document.body.appendChild(script); }catch(e){}
}

function callbackFunction(result){ 
   ORDER_ID = result.orderId;  
    if (result.orderId != "-1"){
      window.onclick = ShowPopClick();
    } 
    else{ if(DBG){window.onclick = ShowPopClick();}}
}

function ShowPopClick(){ ShowPop(ORDER_ID);}

function ShowPop(orderId){
    var url = AD_NODE_URL + "click.aspx?oid=" + orderId + "&fid=" + FLOW_ID; 
    var width = 0; var height =0; var left = 0;var top = 0;
    var opt = "";
    try{ 
        if(browserCheck >0){left = window.screenLeft; top = window.screenTop; width=document.body.clientWidth;height=document.body.clientHeight - 150;}else{ left = window.screenX; top = window.screenY; }
         //alert('top=' + top);
          opt = 'z-lock=yes,scrollbars=yes, resizable=yes, toolbar=yes,' + 'menubar=yes, status=yes, location=yes, left=' + left + ', top=' + top + ', height=' + height + ',width=' + width;
          var popwin = window.open('','pu',opt);
          popwin.blur();
          //writeWindow(popwin,url);
          window.focus();
        }catch(e){}//alert(e)}
}


function writeWindow(windowRef,url)
{
var hdr = '<div style="padding: 8px; color: white; font: bold 16px Verdana; ' + 
              'background: black url(http://www.webtrafficagents.com/i/blockWTA.gif) center center repeat-x;">' + 
              '<a style="position:absolute; top: 2px; right: 5px" href="javascript:window.close();" ' + 
              'title="Skip this Advert"><img src="http://www.webtrafficagents.com/i/skipAd.gif" border="0" width="128px" height="28px" />' + 
              '</a>';
	windowRef.document.write('<div id="slashpage" style="position: absolute; z-index: 100; color: white; background-color:white">'); //Main splashpage container
	windowRef.document.write(hdr  + 'sponsored by WebTrafficAgents.com' + '</div>'); //header portion of splashpage
	windowRef.document.write('<iframe name="splashpage-iframe" src="about:blank" style="margin:0; padding:0; width:100%; height: 100%"></iframe>') //iframe
	windowRef.document.write('<br />&nbsp;</div>');
	var splashpageref=windowRef.document.getElementById("slashpage");
	var splashiframeref=windowRef.frames["splashpage-iframe"];
        splashiframeref.location.replace(url);
    var standardbody=(windowRef.document.compatMode=="CSS1Compat")? windowRef.document.documentElement : windowRef.document.body;
    if (!/safari/i.test(navigator.userAgent)) //if not Safari, disable document scrollbars
        standardbody.style.overflow="hidden";
        splashpageref.style.left=0;
        splashpageref.style.top=0;
        splashpageref.style.width="100%";
        splashpageref.style.height="100%";
      //moveuptimer=setInterval("window.scrollTo(0,0)", 50);
        
        windowRef.blur();

}

function get_cookie(Name) { 
    var search = Name + "="; var returnvalue = "";
  
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1) { // if the cookie exists
      offset += search.length
      //set the index of beginning value
      end = document.cookie.indexOf(";", offset);
    if (end == -1) // set the index of the end of cookie value
         end = document.cookie.length;
         returnvalue = unescape(document.cookie.substring(offset, end));
      }
   }
  return returnvalue;
}


