// Dropdown menu

var closeTimer, activeMenu;
var startLeft = 0;

var hideElements = new Array ();

function hover (ele, state) {
	ele.style.backgroundColor = state ? "#d74238" : "#d12c20";

	if (state && closeTimer)
		clearTimeout (closeTimer);
	
	if (!state)
		timedClose();
}

function hoverNav (ele, state) {
	ele.style.backgroundColor = state ? "#d74238" : "#d12c20";
}

function openMenu (id, ele) {
	if (closeTimer)
		clearTimeout (closeTimer);

	if (activeMenu)
		activeMenu.style.visibility = "hidden";

	startLeft=ele.offsetParent.offsetLeft;
	activeMenu = document.getElementById ("ddmenu" + id);
	activeMenu.style.left = (startLeft + ele.offsetLeft) + 'px';
	activeMenu.style.visibility = "visible";

	for (var i=0; i<hideElements.length; i++) {
		document.getElementById(hideElements[i]).style.visibility = 'hidden';
	}
}

function timedClose () {
	if (closeTimer)
		clearTimeout (closeTimer);
	closeTimer = setTimeout ("_timedClose()", 500);
}

function _timedClose () {
	if (activeMenu) {
		activeMenu.style.visibility = "hidden";
		activeMenu = null;
	}

	for (var i=0; i<hideElements.length; i++) {
		document.getElementById(hideElements[i]).style.visibility = 'visible';
	}
}

function ddnav (url, target, width, height) {
	if (target == "huidig")
		location.href = url;
	else if (target == "nieuw")
		window.open (url);
	else if (target == "popup")
		openPopup (url, "popup", width, height, 1);
	
	return false;
}

function openPopup (url, name, w, h, resizable) {
	var resizable = resizable || 0;
	var opt = "toolbar=0,location=0,scrollbars="+resizable+",directories=0,status=0,menubar=0,resizable="+resizable+","
				+"width="+w+",height="+h+",left="+parseInt((screen.width-w)/2)+",top="+parseInt((screen.height-h)/3);
	var wh = window.open(url, name, opt);
	wh.focus ();
}

function openLogin () {
	openPopup ('login.php', 'login', 350, 180, 0);
	return false;
}

function openLogout () {
	openPopup ('logout.php', 'logout', 350, 180, 0);
	return false;
}

function printv () {
	openPopup ("printv.php", "print", 600, 500, 1);
}

function checkVoorwaarden (aantal) {
	var frm = document.forms['voorwaarden'];
	for (var i = 0; i < 10; i++) {
		if (frm.elements['vw'+i] && frm.elements['vw'+i].checked == false) {
			alert('U kunt alleen declareren als u akkoord gaat met alle voorwaarden voor dit project.');
			return false;
		}
	}
	return true;
}
function formatCurrency(num) {
num = num.replace('.','');
num = num.replace(',','.');
num = num.toString().replace(/\$|\,/g,'');
num=new Number(num);
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+ num.substring(num.length-(4*i+3));
return (((sign)?'':'-') +  num + ',' + cents);
}


