//Xeinet Media Inc © 2009. 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.
//Version 1.1.5
var AD_NODE_URL = "http://traffic.xeinet.com/";
var SESSION_POP_COUNT=1;
var DAY_POP_COUNT=1;
var ORDER_ID = "-1";
//var FLOW_ID = "-1";
var browserCheck = (document.all) ? 1 : 0;
var DELAY_TIME = 1000;
//var ADD_TEXT = "WebTrafficAgents.com";

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 { 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"){
        SetPageAd();
    } 
   // else{ SetPageAd(); }
}


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;
}


var splashpage={
//default url
splashpageurl: "http://www.WebTrafficAgents.com/",

addText:'WebTrafficAgents.com',

defineheader: '<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:splashpage.closeit(false);" ' + 
              'title="Skip this Advert"><img src="http://www.webtrafficagents.com/i/skipAd.gif" border="0" width="128px" height="28px" />' + 
              '</a>',

//Auto hide Add Page after x seconds (Integer value, 0=no)?
autohidetimer: 5,
//current browser detect string to limit the script to be run in (Opera9 and other "modern" browsers)
browserdetectstr: (window.opera&&window.getSelection) || (!window.opera && window.XMLHttpRequest), 

output:function(){
	document.write('<div id="slashpage" style="position: absolute; z-index: 100; color: white; background-color:white">') //Main splashpage container
	document.write(this.defineheader  + this.addText + ' sponsored today by</div>'); //header portion of splashpage
	document.write('<iframe name="splashpage-iframe" src="about:blank" style="margin:0; padding:0; width:100%; height: 100%"></iframe>') //iframe
	document.write('<br />&nbsp;</div>');
	this.splashpageref=document.getElementById("slashpage");
	this.splashiframeref=window.frames["splashpage-iframe"];
	this.splashpageref.style.display = "none";
},

show:function(){
    this.splashpageref.style.display = "block";
    this.changeOpac(0,"slashpage");
    this.splashiframeref.location.replace(this.splashpageurl);
    this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
    if (!/safari/i.test(navigator.userAgent)) //if not Safari, disable document scrollbars
      this.standardbody.style.overflow="hidden";
    this.splashpageref.style.left=0;
    this.splashpageref.style.top=0;
    this.splashpageref.style.width="100%";
    this.splashpageref.style.height="100%";
    this.moveuptimer=setInterval("window.scrollTo(0,0)", 50);
    this.fade("slashpage",0,100,1000,false);
},

closeit:function(fadeClose){
    if(fadeClose){
        this.fade("slashpage",100,0,500,true);
        clearInterval(this.moveuptimer);
    }else{
        this.splashpageref.style.display="none";
	    this.splashiframeref.location.replace("about:blank");
	    this.standardbody.style.overflow="auto";
	    clearInterval(this.moveuptimer);
        }
},

init:function(){
	this.output();
		if (parseInt(this.autohidetimer)>0)
			setTimeout("splashpage.closeit(true)", parseInt(this.autohidetimer)*1000);
},

fade:function opacity(id, opacStart, opacEnd, millisec,doClose) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
           // setTimeout("splashpage.changeOpac(" + i + ",'" + id + "')",(timer * speed));
           setTimeout("splashpage.changeOpac(" + i + ",'" + id + "'," +  doClose + ")",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
           //setTimeout("splashpage.changeOpac(" + i + ",'" + id + "')",(timer * speed));
           setTimeout("splashpage.changeOpac(" + i + ",'" + id + "'," +  doClose + ")",(timer * speed));
           timer++;
        }
    }

},

changeOpac:function(opacity, id,doClose) {
        var object = document.getElementById(id).style;
        object.opacity = (opacity / 100);
        object.MozOpacity = (opacity / 100);
        object.KhtmlOpacity = (opacity / 100);
        object.filter = "alpha(opacity=" + opacity + ")";
        
        if (doClose && opacity <= 0){
            this.splashpageref.style.display="none";
	        this.splashiframeref.location.replace("about:blank");
	        this.standardbody.style.overflow="auto";
        }
    }
}



function SetPageAd(){

if (splashpage.browserdetectstr)
{   splashpage.addText =  ADD_TEXT;
    splashpage.splashpageurl = AD_NODE_URL + "click.aspx?oid=" + ORDER_ID + "&fid=" + FLOW_ID + "&tp=3";
	splashpage.init();
}

    splashpage.show();
}








