/* 1800banners.com Adserver
/* ©2008 1800banenrs.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://174.37.100.129:9001/adserver/adserver_5.php';
var request_url=adtype1_adserver;


//alert('err2');


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('1800_interstitual','','');
document.getElementById('1800_interstitual').style.display="none";
document.getElementById('1800_interstitual').style.width="0px";
document.getElementById('1800_interstitual').style.height="0px";
document.body.style.height="100%";

}


function displayinterstitual(request_url) {

var html;
html=html + '<div style="position:absolute; top:0px; left:0px; width:100%; height:65px; background-color:#3a3a3a;">';
html=html + '<div style="float:left;';
html=html + 'position:relative;">';
html=html + '<a href="http://1800banners.com" target=_blank><img src="http://1800banners.com/images/interlogo.jpg" border=0></a>';
html=html + '</div>';

html=html + '<div style="float:left;';
html=html + 'position:relative;';
html=html + 'margin-left:30px;">';
html=html + '<iframe id="bannerframe" name="bannerframe" width="468" height="60" src="" frameborder=no scrolling=no> </iframe>';

html=html + '</div>';

html=html + '<div style="float:right;';
html=html + 'position:relative;">';
html=html + '<a href="javascript:clearad()"><img src="http://1800banners.com/images/skipad.jpg" border=0></a>';
html=html + '</div>';


html=html + '</div>';
html=html + '<div style="position:absolute; top:65px; left:0px; width:100%; height:100%;background-color:#ffffff;">';
html=html + '<iframe id="website" width="100%" height="100%" src="'+request_url+'" frameborder=no> </iframe>';
html=html + '</div>';

WriteLayer5('1800_interstitual','',html);
document.getElementById('bannerframe').src='http://1800banners.com/adserver/468x60.html';
}


function getHost() {
var host=window.location.host;
host=host.replace(/\./g, "");
return host;
}


function basicloader(adtype,varsarray,background_color,border_color,text_color,text_rollcolor,domain_color) {


//alert(varsarray['interhours']);
//alert(varsarray['interpages']);

var browsecount=readCookie('interstitual_'+getHost());
if(!browsecount || browsecount=='NaN') {var browsecount=0*1;}
browsecount=(browsecount*1) + (1*1);



Set_Cookie('interstitual_'+getHost(),browsecount,varsarray['interhours']);
var interstitualran=readCookie('interstitualran_'+getHost());


//alert('bcount:'+browsecount+'interstitualran:'+interstitualran);

//document.write('bcount:'+browsecount+'interstitualran:'+interstitualran+' domain:'+getHost());


//interstitualran=null;


if(browsecount>10) {
interstitualran=null;
}


if(browsecount>varsarray['interpages'] && interstitualran==null) {
//document.write('running insterstitual');

//alert(browsecount);

eraseCookie('interstitual_'+getHost());
Set_CookieDay('interstitualran_'+getHost(),'1',varsarray['interhours']);


document.body.style.height="0px";

document.write('<div id="1800_interstitual" style="position:absolute; top:0px; left:0px; width:100%; height:100%; min-height:2000px;">');
document.write('</div>');

var request_url=adserverconfig5(adtype,varsarray);

displayinterstitual(request_url);

} 















}


function adserver_initialize(token,loadtype,adtype,background_color,border_color,text_color,text_rollcolor,domain_color,varsarray) {


varsarray[1]=token;
 


basicloader(adtype,varsarray,background_color,border_color,text_color,text_rollcolor,domain_color);



}