menu_img = new Array (
	new Image(), new Image(), new Image(), new Image(), new Image()
);

menu_img[0].src = "img/m1b.gif";
menu_img[1].src = "img/m2b.gif";
menu_img[2].src = "img/m3b.gif";
menu_img[3].src = "img/m4b.gif";

var closeTimer, activeMenu, activeEle, activeId;
var startLeft = 0;

var hideElements = new Array ();

function hoverBack (ele, state) {
	ele.style.backgroundImage = state ? "url(img/nav_back.gif)" : "none";
	//ele.style.backgroundColor = state ? "#FF6600" : "#FFFFFF";
	//ele.style.color = state ? "#FFFFFF" : "#333333";
}

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

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

function openMenu (id, ele) {
	if (activeEle) {
		activeEle.src = "img/m" + activeId + "a.gif";
	}

	ele.src = "img/m" + id + "b.gif";
	activeEle = ele;
	activeId = id;

	if (closeTimer)
		clearTimeout (closeTimer);

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

	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;
	}

	if (activeEle) {
		activeEle.src = "img/m" + activeId + "a.gif";
		activeEle = 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);
	window.open(url, name, opt);
}

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

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

function swap(target,img){
	if (activeMenu)
		activeMenu.style.visibility = "hidden";
	if(document.images[target]){
		document.images[target].src=img;
	}
}
