/* Javascript voor www.waterwinner.nl (C) 2002 - Tim Heesters */

var	tabCount,	// total number of tabs on this site
	curTab = 0;	// tab that is currently selected

/* getTabCount() initializes the tabCount variable */
function DoLoad() {
	var t = document.all["tab0"];	
	tabCount = 0;
	while ( eval(t) ) {
		tabCount++;
		t = document.all["tab" + tabCount];		 
	}
	
}

/* tabClick(tab) sets %tab% as the selected tab */
function tabClick(tab) {
	var t,h,d,i;	
	event.cancelBubble=true;
	event.returnValue=false;
		for ( i = 0 ; i < tabCount ; i++ ) {
		t = document.all["tab" + i];
		h = document.all["hint" + i];
		d = document.all["data" + i];		
		if (t != tab) {
			h.style.display="none";			  
			d.style.display="none";			  			
			t.className="normaltab";
		} else {      
			h.style.display="block";
			d.style.display="block";
			t.className="selectedtab";
			curTab = i;
		}
	}
}	 

/* nextTab() sets the selected tab to the next in-line */
function nextTab() {
	if (curTab + 1 >= tabCount) {
		tabClick(document.all["tab" + 0]);
	} else {
		tabClick(document.all["tab" + (curTab + 1)]);
	}
}

/* prevTab() sets the selected tab to the next in-line */
function prevTab() {
	if (curTab - 1 < 0) {
		tabClick(document.all["tab" + (tabCount - 1)]);
	} else {
		tabClick(document.all["tab" + (curTab - 1)]);
	}
}

/* imageWindow(imgname,title) opens a new windows containing "images\screenshots\%imgname%" 
   with %title% as the window title  */
function show(img, title) {
	var newWindow = window.open('','','width=650,height=590,toolbar=no,location=no,directories=o,status=no,menubar=no,scrollbars=no,resizable=no,screenX=50,screenY=50');
	newWindow.document.write(
		"<html>" + 
		"	<head>" +
		"		<title> Waterwinner: " + title + "</title>" +
		"		<link href='waterwinner.css' rel='stylesheet' type='text/css' />" +
		"	</head>" +
		"	<body style='margin-top: 0px; margin-left: 0px; margin-bottom: 0px; margin-right: 0px;'>" +
		"		<table cellspacing=0 valign=top width=100% height=100% style='padding: 0px; border: 0px; margin: 0px;'>" + 
		"			<tr><td class='imagefiller'> &nbsp; Waterwinner: " + title + " </td></tr>" +
		"			<tr><td class='imagedata' align='middle'> <img src=images/screenshots/" + img + " alt='" + title + "'></td></tr>" +
		"			<tr><td class='imagefiller' style='text-align: right;'>&nbsp;<A CLASS='backlink' HREF='javascript:window.close();'> Dit venster sluiten</a>&nbsp&nbsp</td></tr>" + 
		"		</table>" +
		"	</body>" +
		"</html>"        
	);
}

/* validate(form) validates the organisation/name-field and the email field of %form% */
function validate(form) {
	var iAt,iDot;
	if (form.name != "msgform") {
		if (form.organization.value == "") {
    		alert("U moet een geldige waarde in vullen in het veld 'Organisatie' ");
		    form.organization.focus();
    		return (false);
	    }
	} 
	iAt = form.replyto.value.indexOf("@");
	iDot = form.replyto.value.lastIndexOf(".");
	if (iAt == -1 || iDot == -1 || iAt > iDot || iDot == form.replyto.value.length - 1) {
		alert("'" + form.replyto.value + "' is geen geldig e-mail adres.");
		form.replyto.focus();
		return (false);
	}
	return (true);
}

function IsGemeente(form) {
	var gem = form.gemeente.value;

	gem = gem.toLowerCase();
	// TODO
	alert("De gemeente " + form.gemeente.value + " bestaat niet of is (nog) niet geregistreerd.");
	return(false);
}