/*
 * Dynamic Menu
 * Written by Andy Peatling - http://www.cssdev.com/
 * April 1, 2006.
 */
var oTarget = document; // voor als je met frames werkt

//addLoadEvent(collapseMenu);
addLoadEvent(prepareMenu);
addLoadEvent(slikker);
addLoadEvent(trap)

function collapseMenu(node) {
	if (!document.getElementById) return false;
	if (!document.getElementById("menu")) return false;
	if (!node) node = document.getElementById("menu");

	if (node.childNodes.length > 0) {
		for (var i=0; i<node.childNodes.length; i++) {
			var child = node.childNodes[i];
			if (child.nodeName == "UL") {
				if (i!=0) child.style.display = "none"; // **** de if stond er niet
			}
			collapseMenu(child);
		}
	}
}

function prepareMenu() {
	if (!document.getElementById || !document.getElementsByTagName) return false;
	if (!document.getElementById("menu")) return false;

	var links = document.getElementById("menu").getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {		
		links[i].onclick = function() {
//			toggleMenu(this.parentNode.getElementsByTagName("UL")[0], this.href); // ******* origineel
			toggleMenu(this.parentNode.getElementsByTagName("UL")[0], this);
			return false;
		}
	}
}

function toggleMenu(node, link) {
	if (!document.getElementById) return false;
	if (!link) return false;
//	if (!node) location.href = link.href; // origineel

	// Collapse all nodes, and only show clicked node (when clicking top level of menu)

	if (node){
		if (node.parentNode.parentNode.id == "menu") {
			hideTopLevels();
		}
		
		if (node.style.display == "") {
			Effect.BlindUp(node, {duration: 0.5});
		} else {
			Effect.BlindDown(node, {duration: 0.5});
		}
		if (link.href!="#") setTimeout("oTarget.location.href = '" + link.href + "';", 500);
	} else {
		oTarget.location.href = link.href;
	}
	
//	if (link.href!="#") oTarget.location.href = link.href;  // ***bijgezet
//	if (link.href!="#") setTimeout("oTarget.location.href = '" + link.href + "';", 800);  // ***bijgezet
}

function hideTopLevels() {
	if (!document.getElementById) return false;
	if (!(node = document.getElementById("menu"))) return false;	
	
	if (node.childNodes.length > 0) {
		for (var i=0; i<node.childNodes.length; i++) {
			var child = node.childNodes[i];
			for(var j=0; j<child.childNodes.length; j++) {
				var grandchild = child.childNodes[j];
				if (grandchild.nodeName == "UL") {
					if (grandchild.style.display == '') {
						Effect.BlindUp(grandchild, {duration: 0.2});
					}
				}
			}
		}		
	}
}

function slikker(){
	var a = document.getElementById("st1");
	a.onclick = function(){
		Effect.BlindUp(document.getElementById("slick2"), {duration: 0.8});
		Effect.BlindUp(document.getElementById("slick3"), {duration: 0.8});
		var el = document.getElementById("slick1");
		if (el.style.display == "") {
			Effect.BlindUp(el, {duration: 0.8});
		} else {
			Effect.BlindDown(el, {duration: 0.8});
		}
	}
	
	var a = document.getElementById("st2");
	a.onclick = function(){
		Effect.BlindUp(document.getElementById("slick1"), {duration: 0.8});
		Effect.BlindUp(document.getElementById("slick3"), {duration: 0.8});
		var el = document.getElementById("slick2");
		//alert(el);
		if (el.style.display == "") {
			Effect.BlindUp(el, {duration: 0.8});
		} else {
			Effect.BlindDown(el, {duration: 0.8});
		}
	}	
	
	var a = document.getElementById("st3");
	a.onclick = function(){
		Effect.BlindUp(document.getElementById("slick1"), {duration: 0.8});
		Effect.BlindUp(document.getElementById("slick2"), {duration: 0.8});
		var el = document.getElementById("slick3");
		if (el.style.display == "") {
			Effect.BlindUp(el, {duration: 0.8});
		} else {
			Effect.BlindDown(el, {duration: 0.8});
		}
	}
}

function retard(href){
	// alert(href);
	return false;	
}


function right(e) {
	if (navigator.appName == 'Netscape' && e.which == 3) {
//		alert("lele")
		return false;
	}
	if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
		return false;
	}
		else return true;
}

function trap() {

if (document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages()


if(document.images) {
    for(i=0;i<document.images.length;i++) {
			// alert(document.images[i].src)
      document.images[i].onmousedown = right;
      document.images[i].onmouseup = right;
		}
	}
}

function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
	var str = event.srcElement.src;
	var ar = str.split("/");
	var iAr = ar.length-1;
	var name = ar[iAr];
	if(name == "pdf.gif") {
			return true;
	} else {
		doNothing(); 
		return false;
	}
}
}
}
else if (document.layers) {
if (e.which == 3) {
	doNothing();return false;
}
}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
	//alert(e.target.src);
	doNothing();return false
}
}
}

function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}

function doNothing() {
		alert("Our images are protected.")
		return false;
	}
