sfHover = function() {
	var sfEls = $("nav").getElementsByTagName("LI")
	if ($("opened")) 
		var current = $("opened").getElementsByTagName("UL")[0];
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].id != "opened") {
			sfEls[i].onmouseover=function() {
				this.className+=" hover";
				if ((this.parentNode.parentNode.id != "opened") && (current)) {
					current.style.display = "none";
				}
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
				if(current)
					current.style.display = "block";
			}
		}
	}
}

toggleTabs = function(obj) {
	if (window.event) obj = window.event.srcElement; //ie
	else if (obj.target) obj = obj.target; //other
	
	if(obj.id == 'vac_tab') {
		$('vac_tab').className = 'toggle';
		$('aan_tab').className = '';
		$('vacatures').style.display = '';
		$('aanvragen').style.display = 'none';
	} else if(obj.id == 'aan_tab') {
		$('vac_tab').className = '';
		$('aan_tab').className = 'toggle';
		$('vacatures').style.display = 'none';
		$('aanvragen').style.display = '';
	}
}

init = function() {
	// hide 'aanvragen'
	// TODO set and read from cookie which to hide and show
	if($('aanvragen')) {
		$('aanvragen').style.display = 'none';
		$('vac_tab').className = 'toggle';
		if (window.attachEvent) $('vac_tab').attachEvent("onclick", toggleTabs);
		else $('vac_tab').addEventListener('click',toggleTabs,false);
		
		if (window.attachEvent) $('aan_tab').attachEvent("onclick", toggleTabs);
		else $('aan_tab').addEventListener('click',toggleTabs,false);
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);
else window.addEventListener('load',sfHover,false);
if (window.attachEvent) window.attachEvent("onload", init);
else window.addEventListener('load',init,false);