// popup opener
function myPopup(file,myWindow,width,height,specs) {
        if (height == null) {
			height=500;
		}
		if (width == null) {
			width=600;
		}
	ppWindow = open(file,myWindow,'resizable=1,width='+width+',height='+height+','+specs);
	if(ppWindow.opener == null) ppWindow.opener = self;
	ppWindow.focus();
}

// afbeelding popup
function afb(url,titel) {
        myPopup('popup.image.php?afb='+url+'&titel='+titel,'afbeelding',700,500,'scrollbars=1');
}

// functies joris...worden nog gebruikt?
function toon(objID) {
        if (document.getElementById && document.getElementById(objID) != null) {
           object = document.getElementById(objID);
        } else if (document.layers && document.layers[object] != null) {
           object = document.layers[objID];
        } else if (document.all) {
           object = document.all[object];
           object.className = replace(object.className,'hidden','visible');
        }
}

function replace(string,text,by) {
	// Replaces text with by in string
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;

	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))) return string;
	if (i == -1) return string;

	var newstr = string.substring(0,i) + by;

	if (i+txtLength < strLength)
	newstr += replace(string.substring(i+txtLength,strLength),text,by);

	return newstr;
}
//einde functiens joris

//scroll window
function scrollWin(x,y) {
        window.scrollTo(x,y);
        }

// Toon een verborgen element
function showDiv(id) {
	document.getElementById(id).style.display = "inline";
	}

// Verberg een element
function hideDiv(id) {
	document.getElementById(id).style.display = "none";
	}

function imgActivate(id) {
        imgName = "optie" + id;
        imgSrc = "/menuimages/" + imgName + "_active.gif";
        document.getElementById(imgName).src = imgSrc;
}

function imgDeactivate(id) {
        imgName = "optie" + id;
        imgSrc = "/menuimages/" + imgName + ".gif";
        document.getElementById(imgName).src = imgSrc;
}

function hideDivbyEvent(e) {
	//eventPhase = 2 => AT_TARGET : l'event est sur un élément.
	if ( e.eventPhase == 2 && (e.relatedTarget == e.currentTarget.parentNode || e.relatedTarget == document.body || e.relatedTarget == document.documentElement) ) {

	}
	else {
		e.preventDefault();
	}
}

function hidediv_ie(event) {
	if ( event.toElement == zediv.parentNode ) {

	}
	else {
		event.returnValue=false;
	}
}

function theMouseOutTimer(delay, menudefault) {
	timout = setTimeout("dropDownMenu('', 'hideall', '" + menudefault + "');", delay);
}

function resetTimer () {
	if (window.timout)	{
		clearTimeout(timout);
		timout = null;
	}
}

function dropDownMenu(id, action, menudefault) {
	if (action == "show") {
		resetTimer();

		counter = 1;
		zediv=document.getElementById(id);
			if (window.addEventListener) {
				zediv.addEventListener('onmouseout',hideDivbyEvent,false);
			} else if (window.attachEvent) {
				zediv.attachEvent('onmouseout', hidediv_ie);
			} else {
				alert('Your browser does not support DOM addEventListener or IE\'s proprietary attachEvent.\nImpossible to detect onmouseout for the DIV element.\n');
			}

		while (counter < 7) {
			divName = "dropdown_" + counter;
			if (id == divName) {
				showDiv(id);
                                if (counter < 6) imgActivate(counter);
                        } else {
				hideDiv(divName);
                                if (counter < 6) imgDeactivate(counter);
			}
			counter = counter + 1;
		}
	} else if (action =="hide") {
		hideDiv(id);
	} else if (action =="hideall") {
		counter = 1;
		while (counter < 7) {
                      divName = "dropdown_" + counter;
                        if (counter != menudefault) {
                           hideDiv(divName);
                           if (counter < 6) imgDeactivate(counter);
		        } else {
                           showDiv(divName);
                           if (counter < 6) imgActivate(counter);
                        }
                      counter = counter + 1;
		}
	}
}

function closeOut(){
/*
         event.returnValue = "Let op, sommige gegevens die in de talentscan zijn ingevuld kunnen verloren gaan. Klik op OK om deze pagina te verlaten.";
*/
}
