function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


function menu() {
	var menu_contact = document.getElementById("contact_area");
	var menu_contact_hover = document.getElementById("contact_hover");
	var menu_contact_active = document.getElementById("contact_active");
	if (menu_contact && menu_contact_hover && !menu_contact_active) {
		menu_contact.onmouseover = function() {
			menu_contact_hover.style.display = "block";
		}
		menu_contact.onmouseout = function() {
			menu_contact_hover.style.display = "none";
		}
	}
	var menu_wedstrijd = document.getElementById("wedstrijd_area");
	var menu_wedstrijd_hover = document.getElementById("wedstrijd_hover");
	var menu_wedstrijd_active = document.getElementById("wedstrijd_active");
	if (menu_wedstrijd && menu_wedstrijd_hover && !menu_wedstrijd_active) {
		menu_wedstrijd.onmouseover = function() {
			menu_wedstrijd_hover.style.display = "block";
		}
		menu_wedstrijd.onmouseout = function() {
			menu_wedstrijd_hover.style.display = "none";
		}
	}
	var menu_mdg15 = document.getElementById("mdg15_area");
	var menu_mdg15_hover = document.getElementById("mdg15_hover");
	var menu_mdg15_active = document.getElementById("mdg15_active");
	if (menu_mdg15 && menu_mdg15_hover && !menu_mdg15_active) {
		menu_mdg15.onmouseover = function() {
			menu_mdg15_hover.style.display = "block";
		}
		menu_mdg15.onmouseout = function() {
			menu_mdg15_hover.style.display = "none";
		}
	}
	var menu_leerkracht = document.getElementById("leerkracht_area");
	var menu_leerkracht_hover = document.getElementById("leerkracht_hover");
	var menu_leerkracht_active = document.getElementById("leerkracht_active");
	if (menu_leerkracht && menu_leerkracht_hover && !menu_leerkracht_active) {
		menu_leerkracht.onmouseover = function() {
			menu_leerkracht_hover.style.display = "block";
		}
		menu_leerkracht.onmouseout = function() {
			menu_leerkracht_hover.style.display = "none";
		}
	}
	var menu_leerling = document.getElementById("leerling_area");
	var menu_leerling_hover = document.getElementById("leerling_hover");
	var menu_leerling_active = document.getElementById("leerling_active");
	if (menu_leerling && menu_leerling_hover && !menu_leerling_active) {
		menu_leerling.onmouseover = function() {
			menu_leerling_hover.style.display = "block";
		}
		menu_leerling.onmouseout = function() {
			menu_leerling_hover.style.display = "none";
		}
	}
	var menu_forum = document.getElementById("forum_area");
	var menu_forum_hover = document.getElementById("forum_hover");
	var menu_forum_active = document.getElementById("forum_active");
	if (menu_forum && menu_forum_hover && !menu_forum_active) {
		menu_forum.onmouseover = function() {
			menu_forum_hover.style.display = "block";
		}
		menu_forum.onmouseout = function() {
			menu_forum_hover.style.display = "none";
		}
	}
}

function poll() {
	var frm = document.pollform;
	if(frm) {
		frm.onsubmit = function() {
			var radio_choice = false;
			for (counter = 0; counter < frm.answer.length; counter++) {
				if (frm.answer[counter].checked)
					radio_choice = true; 
			}
			if (!radio_choice) {
				alert(lbl_poll_controle);
				return false;
			}
			return true;
		}
	}
}

function doMovie(id) {
	var divke = document.getElementById(id);
	if (divke) {
		if (divke.style.display == "none") {
			divke.style.display='block';
		}
		else {
			divke.style.display='none';
		}
	}	
	return false;
}

function clicks() {
	var txt1 = document.getElementById("searcher");
	if (txt1) {
		txt1.onfocus = function() {
			this.select();
		}
		txt1.onblur = function() {
			if (this.value == "") {
				this.value = this.title;
			}
		}
	}
	var txt2 = document.getElementById("user_name_left");
	if (txt2) {
		txt2.onfocus = function() {
			this.select();
		}
		txt2.onblur = function() {
			if (this.value == "") {
				this.value = this.title;
			}
		}
	}
	var txt3 = document.getElementById("password_left");
	if (txt3) {
		txt3.onfocus = function() {
			this.select();
		}
		txt3.onblur = function() {
			if (this.value == "") {
				this.value = this.title;
			}
		}
	}
	var txt4 = document.getElementById("user_name_mid");
	if (txt4) {
		txt4.onfocus = function() {
			this.select();
		}
		txt4.onblur = function() {
			if (this.value == "") {
				this.value = this.title;
			}
		}
	}
	var txt5 = document.getElementById("password_mid");
	if (txt5) {
		txt5.onfocus = function() {
			this.select();
		}
		txt5.onblur = function() {
			if (this.value == "") {
				this.value = this.title;
			}
		}
	}
}
/*
function scores() {
	var score1 = document.getElementById("score_slecht");
	if (score1) {
		score1.onclick = function() {
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster3").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster4").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster5").src = "/images/score_ster_1_outline.gif";
		}
	}
	var score2 = document.getElementById("score_matig");
	if (score2) {
		score2.onclick = function() {
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1.gif";
			document.getElementById("ster3").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster4").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster5").src = "/images/score_ster_1_outline.gif";
		}
	}
	var score3 = document.getElementById("score_goed");
	if (score3) {
		score3.onclick = function() {
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1.gif";
			document.getElementById("ster3").src = "/images/score_ster_1.gif";
			document.getElementById("ster4").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster5").src = "/images/score_ster_1_outline.gif";
		}
	}
	var score4 = document.getElementById("score_zeer_goed");
	if (score4) {
		score4.onclick = function() {
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1.gif";
			document.getElementById("ster3").src = "/images/score_ster_1.gif";
			document.getElementById("ster4").src = "/images/score_ster_1.gif";
			document.getElementById("ster5").src = "/images/score_ster_1_outline.gif";
		}
	}
	var score5 = document.getElementById("score_super");
	if (score5) {
		score5.onclick = function() {
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1.gif";
			document.getElementById("ster3").src = "/images/score_ster_1.gif";
			document.getElementById("ster4").src = "/images/score_ster_1.gif";
			document.getElementById("ster5").src = "/images/score_ster_1.gif";
		}
	}
}
*/
function geefScore(score) {
	document.scoreform.score.value=score;
	switch(score) {
		case 1:
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster3").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster4").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster5").src = "/images/score_ster_1_outline.gif";
			break;
		case 2:
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1.gif";
			document.getElementById("ster3").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster4").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster5").src = "/images/score_ster_1_outline.gif";
			break;
		case 3:
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1.gif";
			document.getElementById("ster3").src = "/images/score_ster_1.gif";
			document.getElementById("ster4").src = "/images/score_ster_1_outline.gif";
			document.getElementById("ster5").src = "/images/score_ster_1_outline.gif";
			break;
		case 4:
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1.gif";
			document.getElementById("ster3").src = "/images/score_ster_1.gif";
			document.getElementById("ster4").src = "/images/score_ster_1.gif";
			document.getElementById("ster5").src = "/images/score_ster_1_outline.gif";
			break;
		case 5:
			document.getElementById("ster1").src = "/images/score_ster_1.gif";
			document.getElementById("ster2").src = "/images/score_ster_1.gif";
			document.getElementById("ster3").src = "/images/score_ster_1.gif";
			document.getElementById("ster4").src = "/images/score_ster_1.gif";
			document.getElementById("ster5").src = "/images/score_ster_1.gif";
			break;
	}
}

function show_newsbrief(url) {
	theWidth = 650;
	theHeight = 600;
	theTop = (screen.height-theHeight*1.5)/2;
	theLeft = (screen.width-theWidth)/2;
	winopts = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,copyhistory=0,width="+theWidth+",height="+theHeight+",top="+theTop+",left="+theLeft;
	smallwindow=window.open(url,"Detail",winopts);
	smallwindow.focus();
}

//addLoadEvent(scores);
addLoadEvent(clicks);
addLoadEvent(menu);
addLoadEvent(poll);

function popup(url, width, height) {
	theWidth = width;
	theHeight = height;
	theTop = Math.ceil((screen.height-theHeight*1.5)/2);
	theLeft = Math.ceil((screen.width-theWidth)/2);
	winopts = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,copyhistory=0,width="+theWidth+",height="+theHeight+",top="+theTop+",left="+theLeft;
	smallwindow=window.open(url,"Popup",winopts);
	smallwindow.focus();
}




/*******************************
IMAGEPOP
(c) 2003, Peter Bailey, http://www.peterbailey.net
Modified by Skyzyx Genesis, http://www.skyzyx.com

- Works in IE5+, Gecko 0.94+ (maybe earlier?)
- Downlevel for Opera.
- Probably works in KHTML browsers
*******************************/

function imgPop(imageURL) {
	if (document.getElementById && navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{
		var imgWin = window.open('about:blank','imgWin','width=200, height=200, left=200, top=100');

		with (imgWin.document)
		{
			writeln('<html><head><title>Loading...</title>');
			writeln('<style type="text/css"><!-- body { margin: 0px; } --></style></head>');
			writeln('<body onload="self.focus();"><img id="pic" style="display:none" /></body></html>');
			close();		
		}

		var img = new Image();
		img.onload = function() { sizeImgWin(imgWin, img); };
		img.src = imageURL;
	}
	else window.open(imageURL);
}
	
function sizeImgWin(win, img) {
   	var new_w = img.width;
	var new_h = img.height;
	var old_w = win.innerWidth || win.document.body.offsetWidth;
	var old_h = win.innerHeight || win.document.body.offsetHeight;

	if (!new_w) { new_w = old_w; }
	if (!new_h) { new_h = old_h; }

	new_w -= old_w; new_h -= old_h;
	win.resizeBy(new_w,new_h);
	win.document.title = img.src.substring(img.src.lastIndexOf("/")+1);
	var pic = win.document.getElementById('pic');
	pic.src = img.src;
	pic.style.display = 'block';

	sw=screen.width;
	sh=screen.height;

	var leftPos=((sw-new_w)/2)-100; // Exactly centered.
	var topPos=((sh-new_h)/2)-(100+(((sh-new_h)/2)*0.1)); // Centered, then moved up 10%
	//win.moveTo(leftPos, topPos);
}