var Dauer = 300; // in Sekunden

var gWindowCloseWait = 300; //erst nach 5 min ausblenden
window.setTimeout("versteckepopup()", gWindowCloseWait*1000);


function versteckepopup() {
document.getElementById("popup1").style.display = 'none';
} 

function zeigepopup() {
document.getElementById("popup1").style.display = 'block';
} 


function CookieLesen (name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		{
			return CookieEinlesen (j); 
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
		{
			break;
		}
	}
	return null;
}

function CookieSetzen (name, value)
{
	var argv = CookieSetzen.arguments;
	var argc = CookieSetzen.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

function CookieLoeschen (name)
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = CookieLesen (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var exp = new Date(); 
exp.setTime(exp.getTime() + (Dauer*1000));

function CookieEinlesen(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	{
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

function PopUpCheck()
{
	var count = CookieLesen('PopUp');
	if (count == null)
	{
		count=1;
		CookieSetzen('PopUp', count, exp);
		zeigepopup();
	}
	else
	{
		if (count < 5)
		{
			zeigepopup();
		}
		count++;
		CookieSetzen('PopUp', count, exp);
	}
}