function init() {
	//pre load images
	var buttonbackground1 = new Image();
	buttonbackground1.src = "images/menubutton-start-selected.gif";
	var buttonbackground2 = new Image();
	buttonbackground2.src = "images/menubutton-end-selected.gif";
	var menubackground1 = new Image();
	menubackground1.src = "images/menu-dropdown-background.gif";
	var menubackground2 = new Image();
	menubackground2.src = "images/menu-dropdown-background-highlight.gif";
	//menu mousover effects
	setMouseOvers();
}

function setMouseOvers() {
	var navRoot = document.getElementById("nav");
    navRoot.onmouseover = function(){
    	for (var i=0; i < this.childNodes.length; i++) {
    	  var node = this.childNodes[i];
    	  if (node.nodeName == "LI") {
    		  node.style.zIndex = 999;
    	  }
      }
    }

    var lTimeout = -1;
    var lMenuToHide = '';
  	for (var i=0; i < navRoot.childNodes.length; i++) {
    	var node = navRoot.childNodes[i];
    	if (node.nodeName == "LI") {
    		node.onmouseover = function() {
//          try{window.clearTimeout(lTimeout);}catch(e){}
    			this.className += "-selected over";
    			//document.getElementById(this.id + "-end").className += "-selected";
    		}
    		node.onmouseout = function() {
          if ((this.id == 'menu1')||(this.id == 'menu1_over')){try{window.clearTimeout(lTimeout);}catch(e){} lTimeout = window.setTimeout('swapMenuButton(\'menu1\')',1000);lMenuToHide=this.id}
          if ((this.id == 'menu2')||(this.id == 'menu2_over')){try{window.clearTimeout(lTimeout);}catch(e){} lTimeout = window.setTimeout('swapMenuButton(\'menu2\')',1000);lMenuToHide=this.id}
          if ((this.id == 'menu3')||(this.id == 'menu3_over')){try{window.clearTimeout(lTimeout);}catch(e){} lTimeout = window.setTimeout('swapMenuButton(\'menu3\')',1000);lMenuToHide=this.id}
          if ((this.id == 'menu4')||(this.id == 'menu4_over')){try{window.clearTimeout(lTimeout);}catch(e){} lTimeout = window.setTimeout('swapMenuButton(\'menu4\')',1000);lMenuToHide=this.id}
          if ((this.id == 'menu5')||(this.id == 'menu5_over')){try{window.clearTimeout(lTimeout);}catch(e){} lTimeout = window.setTimeout('swapMenuButton(\'menu5\')',1000);lMenuToHide=this.id}
          if ((this.id == 'menu6')||(this.id == 'menu6_over')){try{window.clearTimeout(lTimeout);}catch(e){} lTimeout = window.setTimeout('swapMenuButton(\'menu6\')',1000);lMenuToHide=this.id}

    			this.className = this.className.replace("-selected over", "");
    			//document.getElementById(this.id + "-end").className = "menubutton-end";
//[2008-04-24 DH] below line caused menuitems to disappear in IE.
//            this.style.zIndex = -1;
    		}
    	}
   }
}

/* FORM VALIDATION, based on http://www.w3schools.com/js/js_form_validation.asp */

function validate_required(field,alerttxt) {
	with (field) {
		if (value == null || value == "") {
			alert(alerttxt);
			return false;
		}
		else {
			return true;
		}
	}
}

function validate_email(field, alerttxt) {
	with (field) {
		var apos = value.indexOf("@")
		var dotpos = value.lastIndexOf(".")
		if (apos < 1 || dotpos-apos < 2) {
			alert(alerttxt);
			return false;
		}
		else {
			return true;
		}
	}
}

function validate_form(thisform, language) {
	if (language == "nl") {
		message_required_field = "Vul alle verplichte velden in a.u.b.";
		message_email_invalid = "U heeft een ongeldig e-mail adres ingevuld";
	}
	else {
		message_required_field = "Please fill in all required fields";
		message_email_invalid = "Not a valid e-mail address";
	}
	
	with (thisform) {
		if (validate_required(name , message_required_field) == false) {
			name.focus();
			return false;
		}
		if (validate_email(email, message_email_invalid) == false) {
			email.focus();
			return false;
		}
		if (validate_required(message , message_required_field) == false) {
			message.focus();
			return false;
		}
	}
	return true;
}

/* END FORM VALIDATION */

/* PORTFOLIO */
function browsePortfolio() {
	document.getElementById('showSelectedAdds').innerHTML = "blaat";
}
/* END PORTFOLIO */

function enLarge() {
	document.getElementById('topAdd').width = "400";
	document.getElementById('topAdd').height = "400";
	document.getElementById('topAdd').style.position = "relative";
	document.getElementById('topAdd').style.left = "-200px";
}
function shrink()
{
	document.getElementById('topAdd').width = "200";
	document.getElementById('topAdd').height = "200";
	document.getElementById('topAdd').style.position = "static";
	document.getElementById('topAdd').style.left = "0px";
}

function sape() {
	var i = 400;
	document.getElementById('lemonAdd').style.width = i + "px";
	document.getElementById('lemonAdd').style.height = i + "px";
}

function kareljan() {
	document.getElementById('lemonAdd').style.width = "200px";
	document.getElementById('lemonAdd').style.height = "200px";
}

/* COOKIES */


function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+ 	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
