/* Utility functions */
function element(id) {
  var e = false;
  if (document.getElementById) { e = document.getElementById(id); }
  else if (document.all) { e = document.all(id); }
  return e;
}
// login
function toPassword(objOldInput) {
	var objNewElement = document.createElement('input');
	objNewElement.setAttribute('type', 'password');
	objNewElement.setAttribute('value', '');
	objNewElement.setAttribute('name', objOldInput.name);
	objNewElement.className = 'text';
	objOldInput.parentNode.replaceChild(objNewElement, objOldInput);
	toPassword.el = objNewElement;
	setTimeout('toPassword.el.focus()',100);
	return true;
}
// quicklinks
function quickLinks(){
	$('#serviceMenu a.quicklinks').each(function(){
		$(this).mouseover(function(){
			$('#quicklinks').css('visibility','visible');
	    }).mouseout(function(){
	    	$('#quicklinks').css('visibility','hidden');
	    	//$('#quicklinks').hide('fast');
	    });
	});
}
// menu.js
function hasULchildren(linode) {
	var uls = linode.getElementsByTagName('ul')[0];
	if(uls) return true;
	return false;
}


function efMenu(menuid, menutype) {
	//alert(menuid);
	var menudiv = element(menuid);
	var listitems = menudiv.getElementsByTagName('li');
	if(listitems){
		for(var i=0; i<listitems.length; i++){
			var listitem = listitems[i];
			if(hasULchildren(listitem)) {
				listitem.onmouseover = function (e) {
					// checks if the menuid is the id of the menu on the left side, not the one on the top part
					if ((menuid == 'jongActiefSub' || menuid == 'jongOnlineSub' || menuid == 'jongReumaSub') && this.firstChild.nodeName.toUpperCase() == 'A') {
						if(this.firstChild.className.indexOf('active') != -1) { this.firstChild.className = 'active mouse'; }
						else { this.firstChild.className = 'mouse'; }
						//this.firstChild.style.display = 'visible'; 
						for (var i=0; i<this.childNodes.length; i++) {
							var child = this.childNodes[i];
							if (child.nodeName.toUpperCase() == 'UL') { 
								child.style.visibility = 'visible';
								child.style.display = 'block';
							}
						}
					} else {
						if (this.firstChild.nodeName.toUpperCase() == 'A') {
							if(this.firstChild.className.indexOf('active') != -1) { this.firstChild.className = 'active mouse'; }
							 else { this.firstChild.className = 'mouse'; }
						}
					
						for (var i=0; i<this.childNodes.length; i++) {
							var child = this.childNodes[i];
							if (child.nodeName.toUpperCase() == 'UL') { 
								child.style.visibility = 'visible';
								child.style.display = 'block';
							}
						}
					}
					return false;
				};
				listitem.onmouseout = function (e) {
					for (var i=0; i<this.childNodes.length; i++) {
						var child = this.childNodes[i];
						// checks if the menuid is the id of the menu on the left side, not the one on the top part
						if ((menuid == 'jongActiefSub' || menuid == 'jongOnlineSub' || menuid == 'jongReumaSub') && child.nodeName.toUpperCase() == 'UL') 
						{	
							if (child.nodeName.toUpperCase() == 'UL')  {
									child.style.visibility = 'hidden';
									child.style.display = 'none';
								}
								menudiv.getElementsByTagName('ul')[0].getElementsByTagName('ul')[0].style.visibility = 'visible';
								menudiv.getElementsByTagName('ul')[0].getElementsByTagName('ul')[0].style.display = 'block';
							} else {
								if (child.nodeName.toUpperCase() == 'UL')  {
									child.style.visibility = 'hidden';
								}
							}
						}
						if (this.firstChild.nodeName.toUpperCase() == 'A') {
							if(this.firstChild.className.indexOf('active') != -1) { this.firstChild.className = 'active'; }
							else { this.firstChild.className = ''; }
						}
						return false;
					};
			}
		}
	}
	return void(0);
}

function user_response(){
	var msg = '';
	for( var i = 0; i < arguments.length; i++) { if(document.getElementById(arguments[i]).value == '') { msg += ' - '+document.getElementById(arguments[i]).title+'\n'; } }
	if(msg != '' && msg != 'undefined') {
		msg = 'De volgende velden mogen niet leeg zijn:\n' + msg;
		alert(msg); return false;
	}else{ return true; }
}