// JavaScript functions for www.krektsailing.nl
/*	Function		: sfHover()
*	Description		: initialises the suckerfish menu for Internet Explorer
*/
var sfHover;
sfHover = function() {
	var sfLeft = document.getElementById("navleft").getElementsByTagName("li");
	var sfTop = document.getElementById("navtop").getElementsByTagName("li");
	for (var i=0; i<sfTop.length; i++) {
		sfTop[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfTop[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	for (var i=0; i<sfLeft.length; i++) {
		sfLeft[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfLeft[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
/*	Function		: fixresize()
*	Description		: initializes listener so that window is reloaded when resized
*/
fixresize = function(){
	//var b = document.getElementsByTagName("body");
	window.onresize = reload;
}
function reload(){
	window.location.reload();
}
// in IE6 the right margin for large images causes the sidebar to shift. This is the fix
function fixRightMargin(){
	var img = "";
	for (i = 0; i < document.images.length;i++){
		src = document.images[i].src;
		imgWidth = document.images[i].width;
		//if(){
		if(imgWidth >= 400 || src.indexOf("large") != -1){
			document.images[i].className="largeimg";
		}
	}
}
// shows/hides div with id according to val
// id	: id of the element to show/hide
// val	: true shows the element. false hides the element

function showDiv(id, val){
	var elem = document.getElementById(id);
	//alert("plip");// 
	(val == true)? (elem.style.display = "block") : (elem.style.display="none");
	//return false;
}
// restores the original text of a <label> in a form
// id	: id of the element to restore
// text	: text to put in the label
function restoreLabel(id){	
	var elem = document.getElementById(id);
	//alert("plop");
	// elem.innerHTML = text;
	elem.className = null;
	//return false;
}
