/**
 * beuszo ablak
**/

var timer;
var startpos=-510;
var endpos=0;
	
function start(delay) {
	document.getElementById("light").style.display="block";
	document.getElementById("light").style.top=startpos + "px";
	if (window.location.pathname=="/") {
		var sec=(delay)*1000;
		var t=setTimeout("popupslide();",sec);
	}
}

function popupslide() {
	state=typeof tPos;
	if (state=="undefined") tPos=startpos;
	if (tPos < endpos) {
		tPos+=10;
		document.getElementById("light").style.top = tPos+"px";
	}

	if (timer!=null) clearInterval(timer);
	timer = setTimeout("popupslide()",0);
}


/**
 * lightbox
**/


function popup(delay) {
	if (window.location.pathname=="/") {
		var sec=(delay)*1000;
		var t=setTimeout("showbox();",sec);
	}
}

function showbox(){
	var ph=getPS();
	document.getElementById("fade").style.height=ph+"px";
	document.getElementById("light").style.display="block";
	document.getElementById("fade").style.display="block";
	
}
function closebox(){
	document.getElementById("light").style.display="none";
	document.getElementById("fade").style.display="none";
}

function getPS(){
	var xScroll, yScroll;
	var windowWidth, windowHeight;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight) {
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	if (self.innerHeight) {
		if (document.documentElement.clientWidth) windowWidth = document.documentElement.clientWidth; 
		else windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	if (yScroll < windowHeight) pageHeight = windowHeight;
	else pageHeight = yScroll;
	
	if(xScroll < windowWidth)pageWidth = xScroll;		
	else pageWidth = windowWidth;
	
	return pageHeight;
}


/**
 * beuszo also sav
**/

function bottomStart(delay) {
	var sec=(delay)*1000;
	var t=setTimeout("popupBottom();",sec);
}

var startH=0;
var endH=125;

function popupBottom() {
	document.getElementById("bottom_popup").style.display="block";
	if (startH<=endH) {
		document.getElementById("bottom_popup").style.height=startH+"px";
		startH+=2;
		openTimer=setTimeout("popupBottom()",1);
	}
	else clearTimeout(openTimer);
}
function closebottom() {
	if (endH>=0) {
		document.getElementById("bottom_popup").style.height=endH+"px";
		endH-=2;
		openTimer=setTimeout("closebottom()",1);
	}
	else {
		clearTimeout(openTimer);
		document.getElementById("bottom_popup").style.display="none";
	}
}
