/* ITYIMbanners.com Adserver
/* ©2008 ITYIMbanenrs.com */




function Set_CookieDay( name, value, expires, path, domain, secure ) {
   // set time, it's in milliseconds
   var today = new Date();
   today.setTime( today.getTime() );
   // if the expires variable is set, make the correct expires time, the
   // current script below will set it for x number of days, to make it
   // for hours, delete * 24, for minutes, delete * 60 * 24
   if ( expires )
   {
      expires = expires * 1000 * 60 * 60 * 24;
   }
   //alert( 'today ' + today.toGMTString() );// this is for testing purpose only
   var expires_date = new Date( today.getTime() + (expires) );
   //alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

   document.cookie = name + "=" +escape( value ) +
      ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
      ( ( path ) ? ";path=" + path : "" ) +
      ( ( domain ) ? ";domain=" + domain : "" ) +
      ( ( secure ) ? ";secure" : "" );
}


function Set_Cookie( name, value, expires, path, domain, secure ) {
   // set time, it's in milliseconds
   var today = new Date();
   today.setTime( today.getTime() );
   // if the expires variable is set, make the correct expires time, the
   // current script below will set it for x number of days, to make it
   // for hours, delete * 24, for minutes, delete * 60 * 24
   if ( expires )
   {
      expires = expires * 1000 * 60;
   }
   //alert( 'today ' + today.toGMTString() );// this is for testing purpose only
   var expires_date = new Date( today.getTime() + (expires) );
   //alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

   document.cookie = name + "=" +escape( value ) +
      ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
      ( ( path ) ? ";path=" + path : "" ) +
      ( ( domain ) ? ";domain=" + domain : "" ) +
      ( ( secure ) ? ";secure" : "" );
}



function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
Set_Cookie(name,"",'-1');
}


function is_array( mixed_var ) {
    return ( mixed_var instanceof Array );
}






function adserverconfig5(adtype,varsarray) {


//alert('err1');

var randomnumber=Math.floor(Math.random()*101);

var adtype1_adserver='http://ity.im/adserver_remote/adserver_inter.php';
var request_url=adtype1_adserver;

var jsref=""+window.location;


var randomnumber1=Math.floor(Math.random()*1000001);
var randomnumber=Math.floor(Math.random()*1000001);
request_url=request_url+'?r='+randomnumber1+ '&id='+varsarray[0] + '&token=' + varsarray[1]  + '&jsref=' + jsref + '&rand=' + randomnumber;





return request_url;
}








function WriteLayer5(ID,parentID,sText) {

 if (document.layers) {
   var oLayer;
   if(parentID){
     oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
   }else{
     oLayer = document.layers[ID].document;
   }
   oLayer.open();
   oLayer.write(sText);
   oLayer.close();
 }
 else if (parseInt(navigator.appVersion)>=5&&navigator.
appName=="Netscape") {
   document.getElementById(ID).innerHTML = sText;
 }
 else if (document.all) document.all[ID].innerHTML = sText
} 


function clearad() {
WriteLayer5('ITYIM_interstitual','','');
document.getElementById('ITYIM_interstitual').style.display="none";
document.getElementById('ITYIM_interstitual').style.width="0px";
document.getElementById('ITYIM_interstitual').style.height="0px";
document.body.style.height="100%";


document.documentElement.style.overflow = 'visible';	 // firefox, chrome
document.body.scroll = "yes";	// ie only
document.documentElement.style.overflowX = 'visible';	 // horizontal scrollbar will be hidden
document.documentElement.style.overflowY = 'visible';	 // vertical scrollbar will be hidden

}


function skipthead() {
x=document.getElementById('ITYIM_interstitual');
x.innerHTML = 'test';
}


function displayskip() {

var skipad='<a href="javascript:clearad()"><img class="ityskipad" id="skipadimg" src="http://ity.im/ityimages/skipad.png" border=0 width=160 height=45 style="width:160px; height:45px;"></a>';
WriteLayer5('loading','',skipad);



}





function displayinterstitual(request_url,varsarray) {




document.documentElement.style.overflow = 'hidden';	 // firefox, chrome
//document.body.scroll = "no";	// ie only
document.documentElement.style.overflowX = 'hidden';	 // horizontal scrollbar will be hidden
document.documentElement.style.overflowY = 'hidden';	 // vertical scrollbar will be hidden





var headID = document.getElementsByTagName("head")[0];         
var cssNode = document.createElement('link');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.href = 'http://ity.im/adserver_remote/adserver_inter.css';
cssNode.media = 'screen';
headID.appendChild(cssNode);








var html='';
html=html + '<div class="ity_top">';
html=html + '<div style="float:right;';
html=html + 'position:relative; margin-top:5px; margin-right:10px; color: #000000; font-family: arial, helvetica; font-size: 16px; font-weight: bold;" id="loading" >';
html=html + 'Loading Please Wait';
html=html + '</div>';

html=html + '<div style="float:right;';
html=html + 'position:relative; margin-top:5px; margin-right:10px;">';
html=html + '<a href="http://majon.com" target="_blank">';
html=html + '<img class="itymajonlogo" src="http://ity.im/ityimages/majonlogo2.png" alt="internet marketing &amp; web promotion" border="0" width="130" height="50"></a>';
html=html + '</div>';

html=html + '</div>';
html=html + '<div class="ity_bottom">';
html=html + '<div style="float:left; position:relative; margin-left:10px;">';
html=html + '</div>';
html=html + '<div class="ity_bottomleft">';
html=html + '<a href="../index.php?ref='+varsarray[0]+'" target=_blank>ITY.IM : Shorten Urls, Add a Survey, Upload Images, Earn Cash & More!</a>';
html=html + '</div>';
html=html + '<div class="ity_bottomright"><a href="http://ity.im/advertise.php?ref='+varsarray[0]+'" target=_blank>Advertise with Ity.im</a></div>';
html=html + '</div>';



html=html + '<div id="ityframecontainer" style="position:absolute; top:70px; left:0px; width:100%; height:100%;background-color:#ffffff; z-index:9999;">';
html=html + '<IFRAME style="position:absolute; top:0px; left:0px; z-index:10000; width="0" height="0" src="" frameborder="no" scrolling="no"></iframe><IFRAME style="position:absolute; top:0px; left:0px; z-index:10000;" id="ITYIMFRAME" name="ITYIMFRAME" width="100%" height="100%" frameborder="no" scrolling="yes"></iframe>';
html=html + '<IFRAME style="position:absolute; top:0px; left:0px; z-index:10000; width="0" height="0" src="" frameborder="no" scrolling="no"></iframe></div>';


html=html + '</div>';

WriteLayer5('ITYIM_interstitual','',html);


document.getElementById('ITYIMFRAME').src = request_url;



setTimeout("displayskip()",5000);








}


function getHost() {
var host=window.location.host;
host=host.replace(/\./g, "");
return host;
}


function basicloader5(adtype,varray,interpages,background_color,border_color,text_color,text_rollcolor,domain_color) {


varray['interpages']=interpages;

//alert(varray['interhours']);
//alert(varray['interpages']);

var browsecount=readCookie('interstitual_'+getHost());
if(!browsecount || browsecount=='NaN') {var browsecount=0*1;}
browsecount=(browsecount*1) + (1*1);



Set_Cookie('interstitual_'+getHost(),browsecount,varray['interhours']);
var interstitualran=readCookie('interstitualran_'+getHost());


//alert('bcount:'+browsecount+'interstitualran:'+interstitualran);
//document.write('bcount:'+browsecount+'interstitualran:'+interstitualran+' domain:'+getHost());
//interstitualran=null;


//if(browsecount>varray['interpages']) {
//interstitualran=null;
//}


if(browsecount>=varray['interpages'] && interstitualran==null) {


//alert(browsecount+'  -'+varray['interpages']+' - '+varray[0]);

eraseCookie('interstitual_'+getHost());
Set_CookieDay('interstitualran_'+getHost(),'1',varray['interhours']);


//document.body.style.height="0px";


document.getElementById('ITYIM_interstitual').style.display="block";


//  var divIdName="ITYIM_interstitual"; 
//  var divstyle="float:left; position:absolute; top:0px; left:0px; display:block; visibility:visible; width:100%; height:100%; z-index:90999;";
//  var newdiv = document.createElement('div');
//  newdiv.setAttribute('id',divIdName);
//  newdiv.setAttribute('style',divstyle);
 


//document.body.innerHTML+=interlayer;

//var thebody=document.getElementsByTagName("body")[0]; 
//thebody.innerHTML=interlayer + thebody.innerHTML;

var request_url=adserverconfig5(adtype,varray);
displayinterstitual(request_url,varray);

} 















}


function adserver_initialize(token,loadtype,adtype,background_color,border_color,text_color,text_rollcolor,domain_color,varray) {

var varray;
var interlayer;
interlayer="<div id=\"ITYIM_interstitual\" style=\"float:left; position:absolute; top:0px; left:0px; display:none; visibility:visible; width:100%; height:100%; z-index:90999;\">";
interlayer=interlayer+"0</div>";
document.write(interlayer);


//alert(varsarray['interpages']);
var interpages=varray['interpages'];
//varray[1]=token;
 

setTimeout(function(){
basicloader5(adtype,varray,interpages,background_color,border_color,text_color,text_rollcolor,domain_color);
},1500);


}