sfHover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) {
	window.attachEvent("onload", sfHover);
}

/* Copyright (c) 2006 Patrick Fitzgerald */


// A function which changes the appearance of an input element's label, depending
// on which event that input element fired
//
// Arguments:
// @sCase - a string which refers to the action to be taken
// @sID - a string which contains the ID of the element that called to this function
function fManipLabel(sCase, sID) {
	switch (sCase) {
		case "dim":
			// If the input element is empty, lighten the colour of its label
			if ($(sID).value == "") {
				$('lbl_' + sID).style.color = '#e1e1e1';
			}
			break;
		case "darken":
			// If the input element is empty, darken the colour of its label
			if ($(sID).value == "") {
				$('lbl_' + sID).style.color = '#666666';
			}
			break;
		case "hide":
			// If the input element is not empty, hide its label
			if ($(sID).value != "") {
				$('lbl_' + sID).style.zIndex = '97';
			} else {
				// If the input element is empty, display its label
				$('lbl_' + sID).style.color = '#e1e1e1';
				$('lbl_' + sID).style.zIndex = '99';
			}

			// Reset the background colour of the input element in case it was
			// found not valid while attempting to submit the form
			if ($(sID).style.backgroundColor != '#ffffff') {
				$(sID).style.backgroundColor = '#ffffff';
			}

			break;
	}
}

function ShowHideMap(divid, h2element) {
	
	if ($(divid).style.display == "block") {		
		
		var size = $(divid).getElements('ul')[0].getSize();
		
		
		$(divid).style.display = "none";
		h2element.className = (h2element.className).replace(' open','');
		
		var orgsize = $$('.folder_0').getStyle("height");
		for(var i=0; i<orgsize.length; i++) {
			var value = orgsize[i];
			if (value != "0px") { 
				oldsize = value;
				elmnr = i ; 
			} 
		}
		var orgid = $$('.folder_0').get("id");
		orgid = orgid[elmnr];
		oldsize = oldsize.replace("px", "");
		newsize = parseInt(oldsize) - parseInt(size.y);
		
		$(orgid).setStyle('height', newsize+'px');
		
		
	} else {
		$(divid).style.display = "block";
		h2element.className = h2element.className + ' open';
	
		var size = $(divid).getElements('ul')[0].getSize();
		var orgsize = $$('.folder_0').getStyle("height");
		for(var i=0; i<orgsize.length; i++) {
			var value = orgsize[i];
			if (value != "0px") { 
				oldsize = value;
				elmnr = i ; 
			} 
		}
		var orgid = $$('.folder_0').get("id");
		orgid = orgid[elmnr];
		oldsize = oldsize.replace("px", "");
		newsize = parseInt(oldsize) + parseInt(size.y);
		
		$(orgid).setStyle('height', newsize+'px');
	}
}


// A function which validates the newsletter subscription form and allows
// it to be posted or not (and provides feedback for the latter)
function fValidateSubscForm() {
	var iInvalid = 0;
	var sRegExpEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if ($('naam').value == "") { $('naam').style.backgroundColor = '#ffcec7'; iInvalid++; }
	if ($('email').value == "") { $('email').style.backgroundColor = '#ffcec7'; iInvalid++; }
	if (!sRegExpEmail.test($('email').value)) { $('email').style.backgroundColor = '#ffcec7'; iInvalid++; }

	if (iInvalid > 0) {
		return false;
	} else {
		return true;
	}
}


// A function which clears the value of the search form text field when it is brought to
// focus if it still contains the default value
function fClearSearchCriteria() {
	var sQueryString = window.location.search.substring(1);
	var aVariables = sQueryString.split("&");
	var aVarNames = aVariables[0].split("=");

	if (aVarNames[0] != "cx") {
		$('s_phrase').value = "";
	}
}
