// login
function toPassword(objOldInput) {
	var objNewElement = document.createElement('input');
	objNewElement.setAttribute('type', 'password');
    objNewElement.setAttribute('name', objOldInput.name);
	objOldInput.parentNode.replaceChild(objNewElement, objOldInput);
	toPassword.el = objNewElement;
	setTimeout('toPassword.el.focus()',100);
	return true;
}
// menu.js
function elementContains(elmOuter, elmInner) {
	while (elmInner && elmInner != elmOuter) { elmInner = elmInner.parentNode; }
	if (elmInner == elmOuter) {return true;}
	return false;
}
function getPageXY(elm) {
	var point = { x: 0, y: 0 };
	while (elm)	{
		point.x += elm.offsetLeft;
		point.y += elm.offsetTop;
		elm = elm.offsetParent;
	}
	return point;
}
function setPageXY(elm, x, y) {
	var parentXY = {x: 0, y: 0 };
	if (elm.offsetParent) { parentXY = getPageXY(elm.offsetParent); }
	elm.style.left = (x - parentXY.x) + 'px';
	elm.style.top  = (y - parentXY.y) + 'px';
}
function cssjsmenu(menuid, menutype) {
	// make the variables
	var i, j, node, child, parent, ul, li, deept, deeper, menudiv, version, offset, type;
	// if the browser doesn't even support
	// document.getElementById, give up now.
	if (!document.getElementById) { return true; }
	offset = navigator.userAgent.indexOf('Opera');
	if (offset != -1) { 
		version = parseInt('0' + navigator.userAgent.substr(offset + 6), 10);
		if (version < 7) { return true; }
	}
	offset = navigator.userAgent.indexOf('MSIE');
	if (offset != -1) { 
		if (navigator.userAgent.indexOf('Mac') != -1) { return true; }
	}
	// horisontal or vertical menu
	if (menutype == 'vertical') { type = 'vertical'; }
	else { type = 'horisontal'; }
	// set the variables
	var deept = 0, deeper = false, ul = new Array(), li = new Array();
	menudiv = document.getElementById(menuid);
	// first ul (this is the horisontal head navigation)
	ul[deept] = new Array();
	for (i = 0; i < menudiv.childNodes.length; i++) {
		node = menudiv.childNodes[i];
		if (node.nodeName.toUpperCase() == 'UL') { ul[deept][ul[deept].length] = node; }
	}
	// first ul > li (this is the horisontal head navigation)
	li[deept] = new Array();
	for (i = 0; i < ul[deept].length; i++)	{
		node = ul[deept][i];
		for (j = 0; j < node.childNodes.length; j++) {
			child = node.childNodes[j];
			if (child.nodeName.toUpperCase() == 'LI') {	li[deept][li[deept].length] = child; }
		}
	}
	// if there are li's => go deeper (this is for the vertical sub navigations)
	if (li[deept].length > 0 ) deeper = true;
	for (deept=1; deeper==true; deept++) {
		var deeper = false;
		// deeper ul
		ul[deept] = new Array();
		for (i = 0; i < li[deept-1].length; i++) {
			node = li[deept-1][i];
			for (j = 0; j < node.childNodes.length; j++) {
				child = node.childNodes[j];
				if (child.nodeName.toUpperCase() == 'UL') {
					ul[deept][ul[deept].length] = child;
					// attach hover to parent li
					parent = child.parentNode;
					// onmouseover function
					parent.onmouseover = function (e) {
						var i, child, point;
						// stop the pure css hover effect
						//this.style.paddingBottom = '0';
						for (i = 0; i < this.childNodes.length; i++) {
							child = this.childNodes[i];
							if (child.nodeName.toUpperCase() == 'UL') {
								if (type == 'horisontal') {
									point = getPageXY(this);
									setPageXY(child, point.x, point.y + this.offsetHeight);
								}
								child.style.visibility = 'visible';
							}
						}
						return false;
					};
					// onmouseout function
					parent.onmouseout = function (e) {
						var relatedTarget = null;
						if (e) {
							relatedTarget = e.relatedTarget;
							// work around Gecko Linux only bug where related target is null
							// when clicking on menu links or when right clicking and moving
							// into a context menu.
							if (navigator.product == 'Gecko' && navigator.platform.indexOf('Linux') != -1 && !relatedTarget) { relatedTarget = e.originalTarget; }
						}
						else if (window.event) {
							relatedTarget = window.event.toElement;
						}
						if (elementContains(this, relatedTarget)) { return false; }
						var i, child;
						for (i = 0; i < this.childNodes.length; i++) {
							child = this.childNodes[i];
							if (child.nodeName.toUpperCase() == 'UL') {
								child.style.visibility = 'hidden';
								//child.style.display='none';
							}
						}
						return false;
					};
				}
			}
		}
		// deeper ul > li
		li[deept] = new Array();
		for (i = 0; i < ul[deept].length; i++) {
			node = ul[deept][i];
			for (j = 0; j < node.childNodes.length; j++) {
				child = node.childNodes[j];
				if (child.nodeName.toUpperCase() == 'LI') {	li[deept][li[deept].length] = child; }
			}
		}
		// if there are li's => go deeper and do this lus again
		if (li[deept].length != 0) { deeper = true; }
	}
	return true;
}

function imgpop() {
	if(document.getElementById && document.createTextNode) {
		var photo,il,imga,spana,i,j,prev,next;
		photo = document.getElementById('photo')	
		if (photo) {
			il=photo.getElementsByTagName('li');
			for(i=0;i<il.length;i++) {
				imga=il[i].getElementsByTagName('a')[0];
				if (i == 0 && imga) { imga.parentNode.className = "select"; swapimage(il, imga);} 
				if (imga) {
					imga.onmouseover=function(){ this.parentNode.className+="over"; }
					imga.onmouseout=function(){ this.parentNode.className = this.parentNode.className.replace("over", "");}
					imga.onclick=function(){ return swapimage(il, this); }
				}
			}
		}
	}	
}

function createMenu(list, current){
	var beeldmenu=false, prev=false, next=false;
	var imga, spana, nexta, nexttxt, preva, prevtxt, i, j;
	var imagecounter = 0;
	for(j=0;j<list.length;j++) {
		spana = list[j].getElementsByTagName('span')[0];
		spana.className = "";
		imga = list[j].getElementsByTagName('a')[0];
		if(imga){ imagecounter++; }
	}
	for(i=0;i<list.length;i++) {
		imga = list[i].getElementsByTagName('a')[0];
		if(imga){
			if (current == imga.toString()) {	
				imga.parentNode.className = "select";
				if(i >= 1) prev = list[i-1].getElementsByTagName('a')[0];
				if(i < imagecounter-1 ) next = list[i+1].getElementsByTagName('a')[0];
				beeldmenu = document.createElement('div');
				if(prev != false) {
					preva = document.createElement('a');
					prevtxt = document.createTextNode('previous');
					preva.appendChild(prevtxt);
					preva.setAttribute('href', prev);
	   				preva.onclick=function(){ return swapimage(list, this);};
					beeldmenu.appendChild(preva);
				}
				if(prev != false && next != false) {
					var divider = document.createTextNode('|');
					beeldmenu.appendChild(divider);
				}
				if(next != false) {
					nexta = document.createElement('a');
					nexttxt = document.createTextNode('next');
					nexta.appendChild(nexttxt);
					nexta.setAttribute('href', next);
	   				nexta.onclick=function(){ return swapimage(list, this);};
					beeldmenu.appendChild(nexta);
				}
			}
		}
	}
	
	if(beeldmenu){
		var menu = document.getElementById('beeldContentMenu');
		if(menu){
			if(menu.getElementsByTagName('div').length>0){ // delete it
  				menu.removeChild(menu.getElementsByTagName('div')[0])
			}
			menu.appendChild(beeldmenu);		
		}
	}
}

function swapimage(list, o) {
	createMenu(list, o);
	var img = document.getElementById('sfeerbeeld');
	img.src = o;
	return false;
}
