﻿function FilterNumeric()
{
	//debugger;
	var ch = String.fromCharCode(event.keyCode);
	if (event.keyCode < 32)
	{
		return;
	}

	if ((event.keyCode <= 57) && (event.keyCode >= 48))
	{
		if (!event.shiftKey)
		{
			return;
		}
	}
	if ((ch == ',') || (ch == '.'))
	{
		event.keyCode = 44; // ',', Pagina's instellen op nl-NL
		return;
	}
	event.returnValue = false;
}

function popup(callback, dest, w, h, name)
{
	//debugger;
	var term = "?callback=" + callback;

	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;

	var page = dest + term;
	windowprops = "height=" + h + ",width=" + w + ",top=" + wint + ",left=" + winl + ",location=no,"
		+ "scrollbars=yes,menubars=no,toolbars=no,resizable=no,status=yes";

	win2 = window.open(page, name, windowprops);
	if (win2.opener == null)
		win2.opener = self;
}

function popopen(callback, dest, w, h, name) {
	//debugger;
	var term = "?callback=" + callback;

	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;

	var page = dest + term;
	windowprops = "height=" + h + ",width=" + w + ",top=" + wint + ",left=" + winl + ",location=no,"
		+ "scrollbars=yes,menubars=no,toolbars=no,resizable=yes,status=yes";

	win2 = window.open(page, name, windowprops);
	if (win2.opener == null)
		win2.opener = self;
}

var delay = 1; // Aantal minuten om te wachten
function SessionStart()
{
	var exp = new Date();
	exp.setMinutes(exp.getMinutes() + delay);

	// Cookie zetten die na x minuten expired
	setCookie("sesstart", "yes", exp);

	// Is even voor te debuggen, elke 2 seconden even checken tot de cookie weg is
	//setTimeout(CheckDelay, 2000)
}

function CheckDelay()
{
	var ck = getCookie("sesstart"); // als ie er nog is ben ik pas net op de site
	var ret = (ck == null);
	return ret; 
	//	if (ck != null) {
	//		setTimeout(CheckDelay, 2000);
	//	}
	//	else {
	//		alert("Time!");
	//	}
}

function setCookie(name, value, expires, path, domain, secure)
{
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie(name)
{
	var results = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');

	if (results)
		return (unescape(results[2]));
	else
		return null;
}

function deleteCookie(name, path, domain)
{
	if (getCookie(name))
	{
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
