//取得cookie  
function getCookie(name) { 
 var nameEQ = name + "=";  
 var ca = document.cookie.split(';');    //把cookie分割成组  
 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) {       //如果含有我们要的name  
 return unescape(c.substring(nameEQ.length,c.length));    //解码并截取我们要值  
 }  
 }  
 return false;  
}  
  
//清除cookie  
function clearCookie(name) {  
 setCookie(name, "", -1);  
}  
  
//设置cookie  
function setCookie(name, value, seconds) {  
 seconds = seconds || 0;   //seconds有值就直接赋值，没有为0，这个根php不一样。  
 var expires = "";  
 if (seconds != 0 ) {      //设置cookie生存时间  
 var date = new Date();  
 date.setTime(date.getTime()+(seconds*1000));  
 expires = "; expires="+date.toGMTString();  
 }  
 document.cookie = name+"="+escape(value)+expires+"; path=/";   //转码并赋值  
}  

var bgtop = 0;
var cotop = 0;
var interstitialID = 1;

function interstitial( webSite ){
	
	if(webSite.toString() == ''){
		return false;
	}
	// div aussen
	var myDiv = document.createElement( 'div' );
	
	var id = document.createAttribute( 'id' );
	id.nodeValue = 'backgroundDiv';
	
	myDiv.setAttributeNode( id );
	  
	var Ausgabebereich = document.body;
	Ausgabebereich.appendChild( myDiv );
	
	var backgroundDiv = document.getElementById( 'backgroundDiv' );
	/* backgroundDiv.style.width = getWidth() + 'px'; */
	
	var myDiv2 = document.createElement( 'div' );
	
	var id2 = document.createAttribute( 'id' );
	id2.nodeValue = 'commercialOuter';
	
	myDiv2.setAttributeNode( id2 );
	  
	Ausgabebereich.appendChild( myDiv2 );
	
	var commercialOuter = document.getElementById( 'commercialOuter' );
	
	left = getWidth()/2-327/2;
	cotop = getHeight()/2-350/2;
	commercialOuter.style.left = left + 'px';
	commercialOuter.style.top = cotop + 'px';
	commercialOuter.innerHTML = '<iframe src="http://www.mmogamesite.com/linker.php?webSite=' + webSite + '" width="100%" height="100%" name="Interstitial" framespacing="0" frameborder="no" scrolling="no" allowtransparency="false"></iframe>';
	var x=window.XMLHttpRequest;
	if( !x ){
		
	    var aktiv1 = window.setInterval("center1('backgroundDiv')", 1);
	    var aktiv2 = window.setInterval("center1('commercialOuter')", 1);
	}
	
	return false;
}

function interstitialHome(){
	setCookie("magic","mmorpg",1800);
	
			var simpleWindown_html = new String;
			simpleWindown_html = "<div id=\"bgDiv\"></div>";
			simpleWindown_html += "<dl id=\"outer\">";
			simpleWindown_html += "<dt><a onclick=\"return interstitialClose();\"><img src=\"http://www.onlinegamedaily.com/wp-content/themes/mmogamesite/images/icon_close.png\" alt=\"close\"/></a></dt>";
			simpleWindown_html += "<dd><a href=\"http://bit.ly/xGfged\" target=\"_blank\"><img src=\"http://www.onlinegamedaily.com/wp-content/themes/europe/cs-800x440.jpg\" alt=\"call of gods\"/></a></dd>"; 
			simpleWindown_html += "</dl>";
			jQuery("body").append(simpleWindown_html);
			
	
	
	var outer = document.getElementById( 'outer' );
	
	left = getWidth()/2-800/2;
	cotop = getHeight()/2-440/2;
	outer.style.left = left + 'px';
	outer.style.top = cotop + 'px';
	
	return false;
}
function center1( divName ){
 	var o = document.getElementById( divName );
    var body = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ?
    window.document.documentElement : window.document.body || null;
    
    var win_h = (window.innerHeight || parseInt(body.clientHeight )) / 2;
    var win_w = (window.innerWidth || parseInt(body.clientWidth)) / 2;
    var height = (o.offsetHeight / 2);
    var width = (o.offsetWidth / 2);
    var t = win_h - height + parseInt(window.pageYOffset || body.scrollTop) ;
    var l = win_w  - width  + parseInt(window.pageXOffset || body.scrollLeft);
    o.style.top = t + 'px';
    o.style.left = l + 'px';
}

function getHeight(){
	if (window.innerWidth) { 
		h = window.innerHeight; 
	}else if(document.body){
		h = document.body.clientHeight;
		if (document.body.offsetHeight == h && document.documentElement && document.documentElement.clientHeight){
			h = document.documentElement.clientHeight;
		}
	}
	return h;
}

function getWidth(){
	if (window.innerWidth) { 
		w = window.innerWidth; 
	}else if(document.body){
		w = document.body.clientWidth;
		if (document.body.offsetWidth == w && document.documentElement && document.documentElement.clientWidth){
			w = document.documentElement.clientWidth;
		}
	}
	return w;
}

function interstitialClose(){
	
	var bgDiv = document.getElementById( 'bgDiv' );
	bgDiv.style.display = 'none';
	var outer = document.getElementById( 'outer' );
	outer.style.display = 'none';
}


