function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}
window.onload = function() {
	externalLinks();
	var wh = getWindowHeight();
	$('#bgimage').css('min-height', wh-84);
	$('#col2').css('height', wh-112);

	if ($('#maincontent').attr('scrollHeight') > wh-84) {
		$('#bgimage').css('height', $('#maincontent').attr('scrollHeight'));
	}
	if (location.href.indexOf('films') != -1) {
		$('#moviecategorydescription').html('Meest populaire filmpjes');
		$('#playlistinfo').html("<p><img src='images/loading.gif'/>Bezig met het laden van de categorie 'Meest populair' ...</p>");
		$.ajax({
			data	: 'act=getPlaylist',
			success	: function(thedata) {
				$('#moviecategories li').removeClass('selectedmc');
				$('#mc0').addClass('selectedmc');
				$('#playlistinfo').html(thedata.dat);
				var corr = 144 + 24+$('#moviecategories').height()+14+$('#moviecategorydescription').height()+24;
				$('#playlistinfo').css('height', wh-corr);
				$('#playlist').css('height', wh-corr-30);
			}
		});
	}
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function validateContactform(theform) {
	var msg = '';
	if (theform.elements['f[name]'].value == '') {
		msg += "U heeft uw naam nog niet ingevuld.\n";
	}
	if (theform.elements['f[phone]'].value == '') {
		msg += "U heeft uw telefoonnummer nog niet ingevuld.\n";
	}
	if (theform.elements['f[email]'].value == '') {
		msg += "U heeft uw e-mail-adres nog niet ingevuld.\n";
	}
	if (theform.elements['f[message]'].value == '') {
		msg += "U heeft nog geen bericht ingevuld.\n";
	}
	if (msg != '') {
		alert (msg);
		return false;
	}
	if (prompt('Ter bestrijding van spamberichten graag 1234 invullen:') != '1234') {
		return false;
	}
	alert("Dank voor uw bericht!");
	return true;
}
