var doExit = false;
document.getElementById('tiExitAnchor').href="http://www.sunpalacecasino.eu/Remote/AidDownload.php?casinoID=236&gAid=15426&subGid=3010&bannerID=0";
document.getElementById('tiExitAnchor').innerHTML = '<img src="http://www.flamingocasino.net/Sun-Palace-Casino.jpg" alt="" border="0" width="774" height="273" />';

function getBodySize(){
	if (document.body.scrollHeight>document.body.offsetHeight) return {x:document.body.scrollWidth,y:document.body.scrollHeight}; // all but Explorer Mac
	return {x:document.body.offsetWidth,y:document.body.offsetHeight}; // Explorer Mac;
}

function getPageScroll(){
	var offsetX=0, offsetY=0;
	if(!window.pageYOffset){
		if(!(document.documentElement.scrollTop == 0)){
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
		}else{
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
		}
	}else{
		offsetX = window.pageXOffset;
		offsetY = window.pageYOffset;
	}
	return {x:offsetX,y:offsetY};
}

function getWindowSize() {
	var myWidth=0, myHeight=0;
	if(typeof(window.innerWidth) == 'number'){
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return {x:myWidth,y:myHeight};
}

function showDHTMLExitPop(){
		if (doExit==true && document.getElementById('dhtmlExitOverlay') && document.getElementById('dhtmlExit')){
		// the overlay and exit pop are on the page
		var objExitOverlay = document.getElementById('dhtmlExitOverlay');
		var objExit = document.getElementById('dhtmlExit');

		if ((getCookie('tx_unique_flash') != 1) && (getCookie('tx_unique_dl') != 1) && (getCookie('tx_unique_dhtmlexit') != 1)){
			// no flash click, download click, and previous dhtml exit pop - don't but our customers :)
			setCookie('tx_unique_dhtmlexit','1',1);
			var winSize = getWindowSize();
			var pageScroll = getPageScroll();
			var bodySize = getBodySize();
			var totalPageHeight = bodySize.y;
			if (winSize.y > totalPageHeight) totalPageHeight = winSize.y;
			if (pageScroll.y > 0) totalPageHeight = totalPageHeight + pageScroll.y;
			objExitOverlay.style.height = totalPageHeight+'px';
			objExitOverlay.style.display = '';
			objExit.style.display = '';
			objExit.style.top = (winSize.y / 2) - (objExit.offsetHeight / 2) + pageScroll.y +'px';
			objExit.style.left = (winSize.x / 2) - (objExit.offsetWidth / 2)+'px';
		}
	}
}

function hideDHTMLExitPop(){
	document.getElementById('dhtmlExitOverlay').style.display = 'none';
	document.getElementById('dhtmlExit').style.display = 'none';
}

function updateExitNets(){
	if (document.getElementById('exitNetLeft') && document.getElementById('exitNetRight') && document.getElementById('exitNetCenter')){
		var pageScroll = getPageScroll();
		var winSize = getWindowSize();
		
		var objNetLeft = document.getElementById('exitNetLeft');
		var objNetRight = document.getElementById('exitNetRight');
		var objNetCenter = document.getElementById('exitNetCenter');
		
		objNetLeft.style.left = '0px';
		objNetLeft.style.top = pageScroll.y +'px';
		objNetRight.style.right = '0px';
		objNetRight.style.top = pageScroll.y +'px';
		objNetCenter.style.left = '0px';
		objNetCenter.style.top = pageScroll.y +'px';
	}
	setTimeout(updateExitNets,100);
}

function setCookie(name, value, days, path, domain, secure) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	
	var curCookie = name + "=" + escape(value) + expires +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie(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 allowExit(){
	
	doExit = true;	
}

setTimeout("allowExit()",5000);
updateExitNets();




