function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


var persistclose=0 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = 0 //set x offset of bar in pixels
var startY = 0 //set y offset of bar in pixels

function createAd(){
	var arrayPageSize = getPageSize();

	var newdiv = document.createElement('div');
	newdiv.setAttribute('id','over');
	newdiv.innerHTML = '<div id="overlay" style="width:100%;height:100%;z-index:90;background-image: url(http://www.mobil-forum.dk/home/images/overlay.png);">\n		<div id="box" style="position: absolute;top:150px;z-index: 1000; right: 25%;width: 600px;background:#225197;" align="center">\n			<iframe framespacing="0" frameborder="no" scrolling="no" width="600px" height="240px" src="http://www.mobil-forum.dk/home/surveymonkey.html" onload="setCookie();">\n			<\/iframe>\n		<button type="button" class="btnx" onClick="setCookie_day();document.getElementById(\'over\').style.visibility=\'hidden\';" style="font-size:18px;font-weight:bold;">Vis senere<\/button>			<button type="button" class="btnx" onclick="document.getElementById(\'over\').style.visibility=\'hidden\';" style="font-size:18px;font-weight:bold;">Vis ikke igen<\/button>\n<\/div>\n	<\/div>';
	document.body.appendChild(newdiv);
	document.getElementById("over").style.position="absolute";
	document.getElementById("over").style.width=100+"%";
	document.getElementById("over").style.height=arrayPageSize[1]+"px";
	document.getElementById("over").style.top=0+"px";
	document.getElementById("over").style.right=0+"px";
}

function get_cookie(Name) {
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search)
		if (offset != -1) {
			offset += search.length
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

function setCookie(){
	var today = new Date();
	today.setTime( today.getTime() );
	var expires = 1000 * 60 * 60 * 24 * 1000;
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = "remainclosed" + "=1" +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" );
}

function setCookie_day(){
	var today = new Date();
	today.setTime( today.getTime() );
	var expires = 1000 * 60 * 60 * 24 * 1;
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = "remainclosed" + "=1" +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" );
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function staticbar(){
	createAd();
	barheight=document.getElementById("over").offsetHeight
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	var d = document;
	function ml(id){
		var el=document.getElementById(id);
		if (!persistclose || persistclose && get_cookie("remainclosed")=="")
			el.style.visibility="visible"
		if(d.layers)
			el.style=el;
		el.sP=function(x,y){
			this.style.left=x+"px";
			this.style.top=y+"px";
		};
		el.x = startX;
		el.y = startY;
		return el;
	}
	ftlObj = ml("over");
}

if (window.addEventListener && !get_cookie("remainclosed")){
	window.addEventListener("load", staticbar, false);
}else if (window.attachEvent && !get_cookie("remainclosed")){
	window.attachEvent("onload", staticbar);
}else if (document.getElementById && !get_cookie("remainclosed")){
	window.onload=staticbar;
}
