var to = null;
var currentHandle;
var scrollPaneTopPos;
function showMenu(handle,subhandle) {
	if(currentHandle != null) {
		window.clearTimeout(to);
		hideMenu(currentHandle);
	}
	if(document.getElementById('submenu_'+handle)) {
		activeMenu = document.getElementById('submenu_'+handle);
		activeMenu.parentNode.style.display='block';
		activeMenu.style.visibility='visible';
		scrollPaneTopPos=getTopPos(document.getElementById('scrollpane_'+handle).parentNode);
	}
	if(document.getElementById('mainitem_'+handle)) {
		activeA = document.getElementById('mainitem_'+handle);
		activeA.className='hover';
		formatMenuLineBG(activeA,handle,35);
	}
	if(subhandle) {
		if(document.getElementById('subitem_'+subhandle)) {
			activeA = document.getElementById('subitem_'+subhandle);
			activeA.className='hover';
			formatMenuLineBG(activeA,subhandle,27);

			activeA.onmouseout = "this.className='hover'";
		}
	}
	currentHandle = handle;
	showhideScrollArrows(handle);
}
function hideMenuTimed(handle) {
	to = window.setTimeout('hideMenu(\''+handle+'\')',500);
}
function hideMenu(handle) {
	if(document.getElementById('submenu_'+handle)) {
		hdMenu = document.getElementById('submenu_'+handle);
		hdMenu.parentNode.style.display='none';
		hdMenu.style.visibility='hidden';
	}
	if(document.getElementById('mainitem_'+handle)) {
		hdA = document.getElementById('mainitem_'+handle);
		hdA.className='';
	}
	currentHandle=null;
	window.setTimeout('restoreMenu()',0);
}
function restoreMenu() {
	if(currentHandle==null) {
		showMenu(restoreToHandle,restoreToSubHandle);
	}
}
function formatMenuLineBG(a,handle,offset) {
	if(document.getElementById('itemtext_'+handle)) {
		textSpan = document.getElementById('itemtext_'+handle);
		a.style.backgroundPosition = (textSpan.offsetWidth + offset) + 'px center';
	}
}
var toScroll = null;
function scrollUp(handle) {
	stopScroll();
	if(!canScrollUp(handle)) {
		return;
	}
	scrollPane = document.getElementById('scrollpane_'+handle);
	curTop = scrollPane.style.top == '' ? 0 : parseInt(scrollPane.style.top);
	newTop = curTop+5;
	scrollPane.style.top=newTop+'px';
	toScroll = window.setTimeout('scrollUp(\''+handle+'\')',25);
	showhideScrollArrows(handle);
}
function scrollDown(handle) {
	stopScroll();
	if(!canScrollDown(handle)) {
		
		return;
	}
	scrollPane = document.getElementById('scrollpane_'+handle);
	curTop = scrollPane.style.top == '' ? 0 : parseInt(scrollPane.style.top);
	newTop = curTop-5;
	scrollPane.style.top=newTop+'px';
	toScroll = window.setTimeout('scrollDown(\''+handle+'\')',25);
	showhideScrollArrows(handle);
}
function stopScroll() {
	window.clearTimeout(toScroll);
}
function canScrollUp(handle) {
	if(!document.getElementById('scrollpane_'+handle)) {
		return false;
	}
	scrollPane = document.getElementById('scrollpane_'+handle);
	curTop = scrollPane.style.top == '' ? 0 : parseInt(scrollPane.style.top);
	scrollPaneHeight = scrollPane.offsetHeight;
	scrollParentHeight = scrollPane.parentNode.offsetHeight;
	if(scrollParentHeight > scrollPaneHeight || curTop >= 0) {
		return false;
	}
	return true;
}
function canScrollDown(handle) {
	if(!document.getElementById('scrollpane_'+handle)) {
		return false;
	}
	scrollPane = document.getElementById('scrollpane_'+handle);
	curTop = scrollPane.style.top == '' ? 0 : parseInt(scrollPane.style.top);
	scrollPaneHeight = scrollPane.offsetHeight;
	scrollParentHeight = scrollPane.parentNode.offsetHeight;
	if(scrollParentHeight > scrollPaneHeight || (-scrollParentHeight + scrollPaneHeight + curTop) <= 0) {
		return false;
	}
	return true;
}
function showhideScrollArrows(handle) {
	if(document.getElementById('scrollup_'+handle)) {
		document.getElementById('scrollup_'+handle).style.visibility= (canScrollUp(handle) ? 'inherit' : 'hidden');
	}
	if(document.getElementById('scrolldown_'+handle)) {
		document.getElementById('scrolldown_'+handle).style.visibility= (canScrollDown(handle) ? 'inherit' : 'hidden');
	}
}
function zoneScroll(e,scrollPane,handle) {
	yRel = e.clientY - scrollPaneTopPos;
	if(yRel <= 20) {
		scrollUp(handle);
	} else if(yRel >= scrollPane.parentNode.offsetHeight - 20) {
		scrollDown(handle);
	} else {
		stopScroll();
	}
}
function getTopPos(inputObj) {
	var returnValue = inputObj.offsetTop;
	while((inputObj = inputObj.offsetParent) != null) {
		returnValue += inputObj.offsetTop;
	}
	return returnValue;
}
function setCookieMenuPos(link) {
	if(link.parentNode.style.top != '') {
		ck = new CJL_CookieUtil("xsarus_scrollmenu_menucookie",null,'/');
		ck.setSubValue('pos', link.parentNode.style.top);
	}
}
function restoreFromCookiePos(handle) {
	ck = new CJL_CookieUtil("xsarus_scrollmenu_menucookie",null,'/');
	if(canScrollDown(handle)) {
		ckpos = ck.getSubValue('pos');
		if(ckpos) {
			scrollPane = document.getElementById('scrollpane_'+handle);
			scrollPane.style.top = ckpos;
		}
		showhideScrollArrows(handle);
	}
	ck.setSubValue('pos',null);	
}
var current_desc_handle;
var toDesc;
function setRubriekOmschrijving(r_id) {
	window.clearTimeout(toDesc);
	if(r_id != current_desc_handle) {
		current_desc_handle = r_id;
		ctpr = document.getElementById('contentpreview');
		if(cm_desc[r_id]) {
			ctpr.innerHTML = cm_desc[r_id];
		} else {
			ctpr.innerHTML = '';
		}
	}
}
function hideRubriekOmschrijving() {
	toDesc = window.setTimeout("current_desc_handle = null; document.getElementById('contentpreview').innerHTML = ''",0);
}