/* browser detection */
var agt 	= navigator.userAgent.toLowerCase();
var isMajor	= parseInt(navigator.appVersion);
var isNav	= ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
               && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
               && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var isIE	= ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var isNav4	= (isNav && (isMajor == 4));
var isN4	= isNav4;
var isNav6up = (isNav && (isMajor >= 5));
var isIE4up	= (isIE && (isMajor >= 4));
var isDom	= document.getElementById?1:0
var isOp	= (agt.indexOf("opera") != -1);
var isWin   = ((agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1));
/* end browser detection */

var win;
function bigFoto(url, msg) {
	var top = 10;
	var height = 680;
	var width = 840;
	var left = screen.width/2 - width/2 - 5;
	var opties = "toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=" + top + ",left=" + left + ",width=" + width + ",height=" + height + "";
	if (win && !win.closed) {win.focus();}
	win = window.open('', 'grotefoto', opties);
	win.document.writeln('<html><head><title>' + msg + '</title></head>')
	win.document.writeln('<body bgcolor="#FFFFFF"><center>')
	win.document.writeln('<b>' + msg + '</b><br><br>')
	win.document.writeln('<img src="' + url + '" onclick="top.close();">')
	win.document.writeln('</center></body></html>')
	win.document.close();
	win.focus();
}
function bookmark() {	
	if (isIE4up) {
		var url="http://www.windsurfinghargen.com";
		var title="Windsurfing Hargen";

		document.write('<A HREF="javascript:window.external.AddFavorite(\'http://www.windsurfinghargen.com\',\'Windsurfing Hargen\');" ');
		document.write('onMouseOver=" window.status=');
		document.write("'Voeg Windsurfinghargen toe aan je favorieten.'; return true ");
		document.write('"onMouseOut=" window.status=');
		document.write("' '; return true ");
		document.write('"><img border="0" src="http://www.windsurfinghargen.com/images/bookmark.gif"></a>');
	} else {
		document.write('<img border="0" src="http://www.windsurfinghargen.com/images/bookmark.gif">');
	}
}
function updateAfteller() {
	var nu = new Date();
	var seizoenBegint = new Date(2002, 3, 27, 13, 0)
	seizoenBegint = new Date(2003, 3, 5, 13, 0)
	seizoenBegint = new Date(2004, 3, 10, 12, 0)
	seizoenBegint = new Date(2005, 3, 9, 12, 0)
	seizoenBegint = new Date(2005, 4, 5, 12, 0)
	seizoenBegint = new Date(2011, 3, 23, 12, 0)
	var lyr = getLayer('afteller')

	if (lyr != undefined) {
		nu = nu.getTime();
		seizoenBegint = seizoenBegint.getTime();

		if (nu < seizoenBegint) {
			sec = Math.floor((seizoenBegint - nu)/1000);
			dagen = Math.floor(sec / (3600 * 24));
			sec = sec - (dagen*24*3600)
			uren = Math.floor(sec / 3600);
			sec = sec - (uren*3600);
			minuten = Math.floor(sec / 60);
			sec = sec - (minuten*60);
			seconden = Math.floor(sec/1);
			txtdagen = "dagen";
			txtminuten = "minuten";
			txtseconden = "seconden";
			if (dagen == 1) txtdagen = "dag";
			if (minuten == 1) txtminuten = "minuut";
			if (seconden == 1) txtseconden = "seconde";
			setAttr("innerhtml", lyr, "Het nieuwe seizoen begint over " + dagen + " " + txtdagen + ", " + uren + " uur, " + minuten + " " + txtminuten + " en " + seconden + " " + txtseconden + ".");

			setTimeout("updateAfteller()", 1000);
		} else {
			if (nu < seizoenBegint + 604800000) {
				setAttr("innerhtml", lyr, "Het nieuwe seizoen is begonnen.");
			} else {
				setAttr("innerhtml", lyr, "");
			}
		}
	}
}

function startAfteller() {
	updateAfteller();
}

/* frame boven */
function getLayer(name) {
	if (isDom) {
		return document.getElementById(name)
	} else if (isIE || isOp) {
		return document.all[name]
	} else if (isNav4) {
		return document.layers[name]
	}
}

function setAttr(attr, lyr, newVal) {
	switch (attr) {
	case "top":
		if (isDom) {
			lyr.style.top = newVal;
		} else if (isN4) {
			lyr.top = newVal;
		} else if (isIE4up) {
			lyr.style.pixelTop = newVal;
		}
		break;
	case "left":
		if (isDom) {
			lyr.style.left = newVal;
		} else if (isN4) {
			lyr.left = newVal;
		} else if (isIE4up) {
			lyr.style.pixelLeft = newVal;
		}
		break;
	case "width":
		if (isDom) {
			lyr.style.width = newVal;
		} else if (isN4) {
			lyr.width = newVal;
		} else if (isIE4up) {
			lyr.style.pixelWidth = newVal;
		}
		break;
	case "bgcolor":
		if(isN4) lyr.document.bgColor = newVal;
		else lyr.style.backgroundColor = newVal;
		break;
	case "innerhtml":
		if(isN4) {
			lyr.document.open();
			lyr.document.write(newVal);
			lyr.document.close();
		} else {
			lyr.innerHTML = newVal;
		}
		break;
	case "cursor":
		if (isDom) {
			if (newVal == 'hand') {
				if (isIE) lyr.style.cursor = 'hand';
				else lyr.style.cursor = 'pointer';
			} else {
				lyr.style.cursor = newVal;
			}
		}
	}
}

function getAttr(attr, lyr) {
	switch (attr) {
	case "left":
		if (isDom) {
			return Number(lyr.style.left.replace('px', ''));
		} else if (isNav4) {
			return lyr.left;
		} else if (isIE4up || isOp) {
			return lyr.style.pixelLeft;
		}
		break;
	case "innerhtml":
		return lyr.innerHTML;
		break;
	}
}
/* end frame boven */

/* start foto show */
var fotoNow = -1
var timerFoto = -1
var fotoShowTitel = ''
var winFotoShow;
var slide_show_status = -1
var preloadImage = new Image();
function slideShowShow(nr) {
	bigFotoShow(arrFotos[nr], fotoShowTitel)
}
function slideShow() {
	slideShowVolgende()
	slideShowShow(fotoNow)
}
function slideShowVolgende() {
	fotoNow++
	if (fotoNow >= arrFotos.length) fotoNow = 0
}
function slideShowVorige() {
	fotoNow--
	if (fotoNow < 0) fotoNow = arrFotos.length - 1
}
function slideShowStart(titel) {
	slide_show_status = 0
	fotoShowTitel = titel
	if (timerFoto != -1) slideShowStop()
	slideShow()
	showShow()
	slideShowLoaded()
}
function slideShowLoaded() {
	if (timerFoto != -1) clearInterval(timerFoto)
	if (slide_show_status == 0) timerFoto = setInterval("slideShow()", 6000)
	var preloadFoto = fotoNow + 1
	if (preloadFoto >= arrFotos.length) preloadFoto = 0
	preloadImage.src = arrFotos[preloadFoto]
}
function slideShowPause() {
	slide_show_status = 1
	clearInterval(timerFoto)
	timerFoto = -1
}
function slideShowBack() {
	slideShowVorige()
	slideShowShow(fotoNow)
}
function slideShowFw() {
	slideShowVolgende()
	slideShowShow(fotoNow)
}
function slideShowStop() {
	slide_show_status = 2
	clearInterval(timerFoto)
	showHide();
	timerFoto = -1
}
function bigFotoShow(url, msg) {
	var ShowTitel = fotoShowTitel.replace("'", "\\'")
	var content = ''
	content += '<center>'
	content += '<div class="wsheader" style="color: #fff;">' + msg + '</div><br>'
	content += '<a href="javascript:slideShowBack\(\)"><img src="/images/back.gif" border=0 alt="vorige"></a>&nbsp;'
	content += '<a href="javascript:slideShowStart\(\''+ShowTitel+'\'\)"><img src="/images/play.gif" border=0 alt="play"></a>&nbsp;'
	content += '<a href="javascript:slideShowPause\(\)"><img src="/images/pause.gif" border=0 alt="pause"></a>&nbsp;'
	content += '<a href="javascript:slideShowStop\(\)"><img src="/images/stop.gif" border=0 alt="stop"></a>&nbsp;'
	content += '<a href="javascript:slideShowFw\(\)"><img src="/images/forward.gif" border=0 alt="volgende"></a><br><br>'
	content += '<img src="' + url + '" style="max-height: 600px">'
	content += '</center>'
	
	lyr = document.getElementById('fotoshow');
	lyr.innerHTML = content;
}
function showShow() {
	lyr = document.getElementById('fotoshow');
	lyr.className = "showshow";
}
function showHide() {
	lyr = document.getElementById('fotoshow');
	lyr.className = "showhide";
}
/* end foto show */
	
function homepagepicture() {
	document.write('<img src="/images/homepage/' + getRandom(8) + '.jpg" height="100" width="350">')
}

var winShowMovie;
function showMovie (url, w, h) {
	var top = 10;
	var height = h + 40;
	var width = w + 40;
	var left = screen.width/2 - width/2 - 5;
	var opties = "toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,top=" + top + ",left=" + left + ",width=" + width + ",height=" + height + "";
	if (winFotoShow && !winShowMovie.closed) {winShowMovie.focus();}

	if (isWin && isIE) {
		winShowMovie = window.open(url, 'showmovie', opties);
		winShowMovie.focus();
	} else {
		url = 'http://www.windsurfinghargen.com' + url;
		winShowMovie = window.open('', 'showmovie', opties);
		winShowMovie.document.writeln('<html><head><title>WSH Movie</title></head>')
		winShowMovie.document.writeln('<body bgcolor="#FFFFFF"><center>')
		winShowMovie.document.writeln('<OBJECT ID="MediaPlayer" WIDTH="'+w+'" HEIGHT="'+h+'" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" TYPE="application/x-oleobject">')
		winShowMovie.document.writeln('<PARAM NAME="FileName" VALUE="'+url+'">')
		winShowMovie.document.writeln('<PARAM NAME="autostart" VALUE="1">')
		winShowMovie.document.writeln('<PARAM NAME="showcontrols" VALUE="1">')
		winShowMovie.document.writeln('<EMBED TYPE="application/x-mplayer2" ')
		winShowMovie.document.writeln('SRC="'+url+'"')
		winShowMovie.document.writeln('WIDTH="'+w+'" HEIGHT="'+h+'" AUTOSTART="1" SHOWCONTROLS="1" REPEAT="1">')
		winShowMovie.document.writeln('<\/EMBED><\/OBJECT>')
		winShowMovie.document.writeln('</center></body></html>')
	
		winShowMovie.document.close();
		winShowMovie.focus();
	}
}

function mail(name) {
	if (name == 'lieuwe.faber') {
		adres = 'mai' + 'lto:' + name + '@' + 'gmail.com';
	} else {
		adres = 'mai' + 'lto:' + name + '@' + 'windsurfinghargen.com';
	}
	window.open(adres);
}

function ShirtsAfteller() {
	var nu = new Date();
	var seizoenBegint = new Date(2002, 3, 27, 13, 0)
	seizoenBegint = new Date(2003, 3, 5, 13, 0)
	seizoenBegint = new Date(2004, 3, 10, 12, 0)
	seizoenBegint = new Date(2005, 3, 9, 12, 0)
	seizoenBegint = new Date(2005, 4, 5, 12, 0)
	seizoenBegint = new Date(2006, 5, 18, 23, 59)
	var lyr = getLayer('shirtsafteller')

	nu = nu.getTime();
	seizoenBegint = seizoenBegint.getTime();

	if (nu < seizoenBegint) {
		sec = Math.floor((seizoenBegint - nu)/1000);
		dagen = Math.floor(sec / (3600 * 24));
		sec = sec - (dagen*24*3600)
		uren = Math.floor(sec / 3600);
		sec = sec - (uren*3600);
		minuten = Math.floor(sec / 60);
		sec = sec - (minuten*60);
		seconden = Math.floor(sec/1);
		setAttr("innerhtml", lyr, "U kunt nog " + dagen + " dagen, " + uren + " uur, " + minuten + " minuten en " + seconden + " seconden shirts bestellen.");

		setTimeout("ShirtsAfteller()", 1000);
	} else {
		if (nu < seizoenBegint + 604800000) {
			setAttr("innerhtml", lyr, "U kunt geen shirts meer bestellen.");
		} else {
			setAttr("innerhtml", lyr, "");
		}
	}
}

function toggleLinks(id) {
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = 'block';
	} else {
		document.getElementById(id).style.display = 'none';
 	}
}

function addSlideShowImages() {
	var anchors = document.getElementsByTagName('a');
	for(var i = 0; i < anchors.length; i++) {
		var index = anchors[i].href.toLowerCase().indexOf('/images/');
		if (index > 0) {
			var start = anchors[i].href.indexOf('\'') + 1;
			var eind = anchors[i].href.indexOf('\',') - start;
			var url = anchors[i].href.substr(start, eind);
			arrFotos[arrFotos.length] = url
		}
	}
}

function checkMastersBBQ() {
	if (document.form.bbq.checked == false &&
	    document.form.wshmasters.checked == false) {
		alert ('Je bent vergeten aan te vinken of je meedoet met de masters en/of de bbq!');
		return false;
	}
else {
		document.form.recipient.value = "wsh";
		return true;
	}
}

function checkMastersClinicBBQ() {
	if (document.form.bbq.checked == false &&
	    document.form.wshclinics.checked == false &&
	    document.form.wshmasters.checked == false) {
		alert ('Je bent vergeten aan te vinken of je meedoet met de masters, clinic en/of de bbq!');
		return false;
	}
else {
		document.form.recipient.value = "wsh";
		return true;
	}
}

