function klikCell (ele, state) {
	ele.style.color = state ? "#5886AD" : "#666666";
}

var closeTimer, activeMenu, activeEle;
var startLeft = 33;

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

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

function openMenu (id, ele) {
	if (window.innerWidth){ 
		docwidth = window.innerWidth; 
		} 

	if (document.body.clientWidth){ 
		docwidth = document.body.clientWidth; 
		} 

	startLeft = 33 + ((docwidth/2)-388);
	
	if (activeEle) {
		activeEle.style.backgroundColor = "transparent";
	}

	ele.style.backgroundColor = "#E2E6F0";
	activeEle = ele;

	if (closeTimer)
		clearTimeout (closeTimer);

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

	if (id) {
		activeMenu = document.getElementById (id);
		activeMenu.style.left = (startLeft + activeEle.offsetLeft) + 'px';
		
		activeMenu.style.visibility = "visible";
	}
}

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

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

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 printv () {
	openPopup ("printv.php", "print", 600, 500, 1);
}
