// JavaScript Document
/*Pokazanie wartosci cookie */
function pokazCookie(nazwa) {
	String.prototype.trim = function () {
    	return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}
	
	if (document.cookie!="") {
		var toCookie = document.cookie.split(";");
		for (i=0; i<toCookie.length; i++) {
			var nazwaCookie=toCookie[i].split("=")[0];
			var wartoscCookie=toCookie[i].split("=")[1];
			if (nazwaCookie.trim() == nazwa){
				return unescape(wartoscCookie)
			}
		}
	}
}
/*Ustawienie cookie*/
function setCookie(name,value,days) {
	var now=new Date();
	var expTime=now.getTime()+days*24*60*60*1000;
	var expDate=new Date(expTime);
	document.cookie=name+"="+value+";EXPIRES="+expDate.toGMTString();
}
function hideAll() {
	document.getElementById("pop_up").style.display = "none";
	document.getElementById("tbg").style.display = "none";
}
function getDocHeight() {
	var D = document;
	var height = Math.max( Math.max(D.body.scrollHeight,D.documentElement.scrollHeight),Math.max(D.body.offsetHeight,D.documentElement.offsetHeight),Math.max(D.body.clientHeight,D.documentElement.clientHeight) );
	document.getElementById("tbg").style.height = height + "px";
	
	/*Pozycja pop_up*/
	var szer = document.documentElement.clientWidth;
	var wys = document.documentElement.clientHeight;
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0) {
		if (window.pageYOffset)  	  			
			ScrollTop = window.pageYOffset; 
		else  	  			
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	/*Pozycja ankiety poziom*/
	var x = (szer / 2) - 268;
	document.getElementById("pop_up").style.left = (x>0)?x+"px":"0px";
	/*Pozycja ankiety pion*/
	var y = (wys / 2) - 157 + ScrollTop;
	document.getElementById("pop_up").style.top = (y>0)?y+"px": "0px";
}
/*Sprawdzenie czy ciasteczko zostalo ustawione*/
function pokazPopUp() {
	if (pokazCookie('popup') != '1') {
		setCookie('popup','1','1');
		var l = Math.ceil(Math.random() * 1);
		/*Co piatej osobie wyswietlamy ankiete*/
		if (l == 1) {
			document.getElementById('pop_up').style.display='block';
			document.getElementById('tbg').style.display = 'block';
			getDocHeight();
		}
	}
}