﻿window.onload = init;

function init() {
	menuHover();
	if (typeof checkDivs == 'function') {
		checkDivs();
	}
}

function $(e) { return document.getElementById(e); }

function openWindow(strPage, strName, iWidth, iHeight) {
	var winl = (screen.width - iWidth) / 2; var wint = (screen.height - iHeight) / 2;
	winprops = 'width=' + iWidth + ',height=' + iHeight + ',top=50,left=' + winl + ',location=no,resizable=yes,scrollbars=auto,status=no,titlebar=no'
	win = window.open(strPage, strName, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function newWindow(strPage) {
	var winl = screen.width; var wint = screen.height;
	winprops = 'width=' + winl + ',height=' + wint + ',top=0,left=0,location=no,resizable=yes,scrollbars=yes,status=no,titlebar=no'
	win = window.open(strPage, '_blanc', winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function geoWindowClose() {
    if (opener.parent.opener) {
        opener.parent.opener.__doPostBack();
        opener.__doPostBack();
    }
    else {
        opener.__doPostBack();
    }
    window.close();
}

function getPosX(e) {
	var x = 0;
	while (e != null) {
		x += e.offsetLeft;
		e = e.offsetParent;
	}
	return x;
}

function getPosY(e) {
	var y = 0;
	while (e != null) {
		y += e.offsetTop;
		e = e.offsetParent;
	}
	return y;
}

function openTab(nr) {
	var tabs = $("tabs").getElementsByTagName("li");
	for (var i = 0; i < tabs.length; i++) {
		$("tab" + i).className = "";
		$("tabcontent" + i).className = "tabcontent hidden";
		if (tabs[i].id == "tab" + nr) {
			$("tab" + i).className = "active";
			$("tabcontent" + i).className = "tabcontent";
		}
	}

}

function rblOther(elementClicked, elementToHideUnhide) {
	if (elementClicked.value != "")
		$(elementToHideUnhide).className = "hidden";
	else
		$(elementToHideUnhide).className = "";
}

function menuHover() {
	if (isSet(document.body.currentStyle) && $("navigation")) {
		var listItems = $("navigation").getElementsByTagName('li');
		for (var i = 0; i < listItems.length; i++) {
			if (listItems[i].className == 'parent') {
				var parent = listItems[i];
				if (isSet(parent) && isSet(parent.lastChild.style)) {
					parent.onmouseover = function() { this.lastChild.style.display = 'block'; }
					parent.onmouseout = function() { this.lastChild.style.display = 'none'; }
				}
			}
		}
	}
}

function isSet(el) {
	return (typeof el != 'undefined');
}

function validateDelete(what) {
	if (what == "") what = "dit";
	return (confirm("Weet u zeker dat u " + what + " wilt verwijderen?"));
}

