function o(id) {
	if(document.getElementById) {
		return document.getElementById(id);
	} else if(document.all) {
		return document.all[id];
	} else if(document.layers) {
		return document.layers[id];
	} else {
		return false;
	}
}

function openVideoPopup(aid, nr) {
	window.open('popup_video.php?aid=' + aid.toString() + '&nr=' + nr.toString(), 'video' + aid.toString(), 'scrollbars=no,height=260,width=320,menubar=no,resizable=yes');
}

function openAudioPopup(aid, nr) {
	window.open('popup_video.php?type=audio&aid=' + aid.toString() + '&nr=' + nr.toString(), 'audio' + aid.toString(), 'scrollbars=no,height=20,width=300,menubar=no,resizable=yes');
}

function checkSendpageForm(oForm,lang) {
	if(oForm.sender_name.value.length == 0 || oForm.sender_email.value.length == 0 || oForm.receiver_name.value.length == 0 || oForm.receiver_email.value.length == 0) {
		if(lang == 'nl') alert('Gelieve alle verplichte velden in te vullen.');
		if(lang == 'fr') alert('Veuillez remplir toutes les champs obligatoires.');
		if(lang == 'en') alert('Please fill in all required fields.');
		return false;
	}
	return true;
}

function checkContactForm1(oForm,lang) {
	if(oForm.contact_firstname.value.length == 0 || oForm.contact_lastname.value.length == 0 || oForm.contact_company.value.length == 0 || oForm.contact_function.value.length == 0 || oForm.contact_tel.value.length == 0 || oForm.contact_email.value.length == 0 || oForm.contact_address.value.length == 0 || oForm.contact_postalcode.value.length == 0 || oForm.contact_city.value.length == 0 || oForm.contact_country.value.length == 0) {
		if(lang == 'nl') alert('Gelieve alle verplichte velden in te vullen.');
		if(lang == 'fr') alert('Veuillez remplir toutes les champs obligatoires.');
		if(lang == 'en') alert('Please fill in all required fields.');
		return false;
	}
	return true;
}

function checkContactForm2(oForm,lang) {
	if(oForm.contact_firstname.value.length == 0 || oForm.contact_lastname.value.length == 0 || oForm.contact_email.value.length == 0 || oForm.contact_address.value.length == 0 || oForm.contact_postalcode.value.length == 0 || oForm.contact_city.value.length == 0 || oForm.contact_country.value.length == 0) {
		if(lang == 'nl') alert('Gelieve alle verplichte velden in te vullen.');
		if(lang == 'fr') alert('Veuillez remplir toutes les champs obligatoires.');
		if(lang == 'en') alert('Please fill in all required fields.');
		return false;
	}
	return true;
}

function hideContainer() {
	o('container').style.visibility = "hidden";
}

function showContainer() {
	o('container').style.visibility = "visible";
}

function doSearch() {
	var url = "";
	if(o('search_value').value.length > 0 ) {
		url += 'search.php?search=' + escape(o('search_value').value);
		for (var i = 0;  i < document.getElementsByName('searchIn').length; i++)
		{
			if (document.getElementsByName('searchIn')[i].checked)
				url += '&SearchIn=' + document.getElementsByName('searchIn')[i].value;
		}
		
		location.href = url;
	}
}

function checkSearchSubmit(e) {
	var obj = document.getElementById('search_value');
	if(obj.value == 'Zoek' || obj.value == 'Search' || obj.value == 'Recherche')
	{
		obj.value = '';
		obj.className = 'formfield2';
	}
	if(e.keyCode && e.keyCode == 13) doSearch();
	if(e.which && e.which == 13) doSearch();
}

function getViewPortWidth() {
	var viewportwidth = 0;
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (window.innerWidth) {
		viewportwidth = window.innerWidth;
		//viewportheight = window.innerHeight;
	} else if(document.documentElement && document.documentElement.clientWidth && document.documentElement.clientWidth != 0) {
		 // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		viewportwidth = document.documentElement.clientWidth;
		//viewportheight = document.documentElement.clientHeight;
	} else {
		// older versions of IE
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
		//viewportheight = document.getElementsByTagName('body')[0].clientHeight;
	}
	
	return viewportwidth;
}

function getViewPortHeigth() {
	var viewportheigth = 0;
	
	if (window.innerHeight) {
		viewportheigth = window.innerHeight;
} else if(document.documentElement && document.documentElement.clientHeight && document.documentElement.clientHeight != 0) {
		viewportheigth = document.documentElement.clientHeight;
	} else {
		viewportheigth = document.getElementsByTagName('body')[0].clientHeight;
	}
	
	return viewportheigth;
}

/* new context blocks */

var overdiv = false;
var dtimeout;
var vtimeout;
var gtimeout;
var itimeout;
var etimeout;

function showHover(itemname) {
	if(itemname == "contextcontentdoc")
	{
		clearTimeout(dtimeout);
	}	
	if(itemname == "contextcontentvideo")
	{
		clearTimeout(vtimeout);
	}
	if(itemname == "contextcontentgeluid")
	{
		clearTimeout(gtimeout);
	}
	if(itemname == "contextcontentintern")
	{
		clearTimeout(itimeout);
	}
	if(itemname == "contextcontentextern")
	{
		clearTimeout(etimeout);
	}
}

function showItem(itemname) {
	$("div[id^=contextcontent]").hide();
	document.getElementById(itemname).style.display='';
}

function hideItem(itemname) {
	if(itemname == "contextcontentdoc")
	{
      dtimeout = setTimeout( function()
      {
         $("div[id^="+itemname+"]").fadeOut(300);
      }, 200);
	}	
	if(itemname == "contextcontentvideo")
	{
      vtimeout = setTimeout( function()
      {
         $("div[id^="+itemname+"]").fadeOut(300);
      }, 200);
	}
	if(itemname == "contextcontentgeluid")
	{
      gtimeout = setTimeout( function()
      {
         $("div[id^="+itemname+"]").fadeOut(300);
      }, 200);
	}
	if(itemname == "contextcontentintern")
	{
      itimeout = setTimeout( function()
      {
         $("div[id^="+itemname+"]").fadeOut(300);
      }, 200);
	}
	if(itemname == "contextcontentextern")
	{
      etimeout = setTimeout( function()
      {
         $("div[id^="+itemname+"]").fadeOut(300);
      }, 200);
	}
}

//Facebook plugin (like button), TG 12/04/2011
function fbs_click(test) {
	u = test.href;
	t = test.title;
	window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
	return false;
} 

function fbs_click2(href, title) {
	u = href;
	t = title;
	window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
	return false;
} 

function twt_click(test) {
	u = test.href;
	t = test.title;
	window.open('http://twitter.com/share?url=' + encodeURIComponent(u), 'sharer', 'toolbar=0,status=0,width=626,height=436');
	return false;
} 
