// Hier wordt een film-object weggeschreven zonder activex-click-bug
function writeflash(src, width, height) {
	document.write('<object width="'+width+'" height="'+height+'">');
	document.write('<param name="movie" value="'+src+'" />');
	document.write('<embed src="'+src+'" width="'+width+'" height="'+height+'">');
	document.write('</embed>');
	document.write('</object>'); 
}
// Indien geen content-DIV dan wordt de hele pagina afgedrukt, anders alleen de
// inhoud van de content-DIV.
window.print=function () {
	var doc=document.getElementById('content');
	if(!doc) var doc=document.getElementById('news-box');
	if(!doc) var doc=document.getElementById('col-b');
	if(!doc) var doc=document.getElementById('col-d');
	if(!doc) var doc=document.body;
	var hwnd=window.open('','printwindow');
	hwnd.document.write(doc.innerHTML);
	hwnd.document.close();
	hwnd.document.title=document.title;
	hwnd.print();
	hwnd.close();
}
window.email=function () { window.open('popup_email_pagina.php','emailwindow','width=420,height=220'); }

/* SEARCH-RESULTS-BOX
**************************************************/
function toggleCategory(id)
	{
	if (document.getElementById('category'+id).style.display != 'none')
	{
		document.getElementById('category'+id).style.display = 'none';
	} else {
		document.getElementById('category'+id).style.display = 'block';

	}		
}

/* SAFARI LABELS
**************************************************/
function init() { 

	if(window.alphaPNG) alphaPNG(); 

	$("#home-teaser-box .banner").hover(
		function() {
			$(this).children('a.btn').children('img').css({ margin: '-18px 0 0 0'});
		},
		function() {
				$(this).children('a.btn').children('img').css({ margin: '0'});
		}
	).css("cursor", "pointer").click(entireDivClick);
	
	if(document.getElementById('fancythemes'))
		document.getElementById('fancythemes').style.display = 'block';	
	activateSafariLabels();
	// Maakt document.crumpath aan
	if(document.getElementById('crumpath')) {
		var crumpath=new Array();
		var p=document.getElementById('crumpath').getElementsByTagName('UL')[0].getElementsByTagName('LI');
		var re=new RegExp("<a(?:.*?)>(.*?)</a>","i");
		for(var i=0;i<p.length;i++) crumpath[i]=p[i].innerHTML.replace(re,'$1');
		document.crumpath=crumpath;
	}
}
function openpulldown() {
	document.getElementById('themespulldown').style.display = 'block';	
	document.body.onmouseup = function () { 
		document.getElementById('themespulldown').style.display = 'none';	
		document.body.onmouseup = null;
	}
}

function activateFormControl ( controlId ) {
	if (controlId.getAttribute("type") == "checkbox") {
		if (!controlId["checked"]) { 
			controlId["checked"] = true;
		} else {
			controlId["checked"] = false;
		}
	} else if (controlId.getAttribute("type") == "radio") {
		var allRadios = document.getElementsByTagName("input");
		var radios = new Array();
		for (i = 0; i < allRadios.length; i++) {
			if (allRadios[i].getAttribute("name") == controlId.getAttribute("name")) {
				radios.push(allRadios[i]);
			}
		}
		for (i = 0; i < radios.length; i++) {
			if (radios[i]["checked"] && radios[i].getAttribute("id") != controlId.getAttribute("id")) {
				radios[i]["checked"] = false;
			}
		}
		item["checked"] = true;
	}
}

function activateSafariLabels () {
	if (navigator.userAgent.indexOf("Safari") > 0)  {
		labels = document.getElementsByTagName( "label" );
		for ( labelIndex = 0; labelIndex < labels.length; labelIndex++ ) {
			labels[ labelIndex ].onclick = function () {
				activateFormControl( this.getAttribute( "for" ) );
			}
		}
	}
}

function open_video_popup(video_id) {
	window.open('popup_video_pagina.php?video_id=' + video_id,'videoplayer','width=640,height=520');
}

/* short generic onload by Brothercake */
if(typeof window.addEventListener != 'undefined') {
	window.addEventListener('load', init, false);
} else if(typeof document.addEventListener != 'undefined') {
	document.addEventListener('load', init, false);
} else if(typeof window.attachEvent != 'undefined') {
	window.attachEvent('onload', init);
}



function entireDivClick (){
	if($(this).find("a").attr("target") == '_blank'){
		window.open($(this).find("a").attr("href"));
	}else{
		window.location=$(this).find("a").attr("href");
	}
	return false;
}

