var browser = navigator.userAgent;
if(browser.indexOf('MSIE') != -1 && browser.indexOf('Opera') == -1) var browser = "Microsoft Internet Explorer";


function show_submenu(id)
{
	clear_sub_timeout();
	var oSub = document.getElementById(id);
	if(oSub) oSub.style.display = 'block';
}

function hide_submenu(id,oTime)
{
	if(typeof oTime == 'undefined') oTime = 1000;
	oSub = document.getElementById(id);
	if(oSub) oHideTimer = setTimeout("hide_it()",oTime);
}

function clear_sub_timeout() { 	if(typeof oHideTimer != 'undefined') clearTimeout(oHideTimer); }

function hide_it() { oSub.style.display = 'none';}

function hide_all_subs()
{
	for(i=0;i<oSubmenu_array.length;i++)
	{
		var oSub = document.getElementById(oSubmenu_array[i]);
		if(oSub) oSub.style.display = 'none';
	}
}


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

function show_parent_nodes(oSub,level)
{
	for(i=0;i<level;i++)
	{
		oSub = oSub.parentNode;
		oSub.style.display = '';
	}
}

function top_offset(oThis,oTarget_id,topOffset)
{
	if(!oThis.currentStyle)
	{
		oTopMargin = oThis.offsetHeight * topOffset;
		document.getElementById(oTarget_id).style.marginTop = oTopMargin;
	}
}


if(typeof oActive_insert == 'undefined') oActive_insert 	= new Object();
oActive_insert 	= function (src,type,width,height,params)
{
	this.oSrc 		= src;
	this.oType		= type;
	this.oWidth		= width;
	this.oHeight		= height;
	this.oParams		= params;
	
	if(this.oParams == '') this.oParams = ' wmode="transparent" ';
	
	this.init		= function()
	{
		this.oHTML 		= ''; // reset the html
		if(this.oParams == '' || typeof(this.oParams) == 'undefined') 	this.oParams = 'autoplay=\"0\" autostart=\"0\"';
		if(this.oType == 'swf') this.getswf();
		if(this.oType == 'mov') this.getmov();
		if(this.oType == 'avi') this.getmov();
		if(this.oType == 'mpeg' || this.oType == 'mpg') this.getmpeg();
		if(this.oType == 'wmv') this.getwmv();		
		document.write(this.oHTML);
	}
		
	this.getswf = function()
	{
        this.oHTML 		= '<embed src="'+this.oSrc+'" '+ this.oParams +' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+this.oWidth+'" height="'+this.oHeight+'" />';
	}
	
	this.getmov = function()
	{
        this.oHTML 		= '  <embed src="'+this.oSrc+'" '+ this.oParams +' pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime" width="'+this.oWidth+'" height="'+this.oHeight+'" />';
	}
	
	this.getmpeg = function()
	{
        this.oHTML 		= '  <embed src="'+this.oSrc+'" '+ this.oParams +' pluginspage="http://www.microsoft.com/mac/otherproducts/otherproducts.aspx?pid=windowsmedia" type="video/quicktime" width="'+this.oWidth+'" height="'+this.oHeight+'" />';
	}
	
	this.getwmv = function()
	{
		this.oSrc = this.oSrc.replace("../../userfiles/",oAbspath+"userfiles/"); // op de een of andere manier werkt wmv alleen met absoluut pad
        this.oHTML 		= '  <embed src="'+this.oSrc+'" '+ this.oParams +' width="'+this.oWidth+'" height="'+this.oHeight+'" />';
	}
	
	this.init();
}

function new_ajax()
{
	if ( browser == 'Microsoft Internet Explorer' ) return new ActiveXObject("Microsoft.XMLHTTP");
	else return new XMLHttpRequest();
}

function live_content(id,content_path2,xml_sitemap_file2)
{
	http_page = new_ajax();
	http_page.open('POST', 'templates/live.php',true);
	http_page.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http_page.onreadystatechange = show_content;
	http_page.send('getpage=1&id='+id+'&content_path='+content_path2+'&xml_sitemap_file='+xml_sitemap_file2);
	
	if(typeof prev_pagetree_id == 'undefined') document.getElementById('link_1').className = document.getElementById('link_1').className.replace('selected','');
	else document.getElementById('link_'+prev_pagetree_id).className = document.getElementById('link_'+prev_pagetree_id).className.replace('selected','');
	
	document.getElementById('link_'+id).className = document.getElementById('link_'+id).className.replace('selected','') + 'selected';
	
	prev_pagetree_id 	= id;
	content_path 		= content_path2;
	xml_sitemap_file 	= xml_sitemap_file2;	
	if(typeof breadcrumbs != 'undefined' && breadcrumbs == true)
	{
		setTimeout('live_breadcrumbs()',300);
	}
	
}

function show_content()
{
	if ( http_page.readyState == 4 ) 
	{				
			var response 	= http_page.responseText;
			document.getElementById('content_div').innerHTML = response;
	}
}

function live_breadcrumbs()
{
	http_breadcrumbs = new_ajax();
	http_breadcrumbs.open('POST', 'templates/live.php',true);
	http_breadcrumbs.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http_breadcrumbs.onreadystatechange = show_breadcrumbs;
	http_breadcrumbs.send('getbreadcrumbs=1&breadcrumbs_seperator='+breadcrumbs_seperator+'&id='+prev_pagetree_id+'&content_path='+content_path+'&xml_sitemap_file='+xml_sitemap_file);
}

function show_breadcrumbs()
{
	if ( http_breadcrumbs.readyState == 4 ) 
	{				
			var response 	= http_breadcrumbs.responseText;
			document.getElementById('breadcrumbs_sys').innerHTML = response;
	}
}

function pagetree(id,oIMG)
{
	t = document.getElementById(id);
	if(t.style.display == 'none') t.style.display = '';
	else t.style.display = 'none';	

	if(basename(oIMG.src) == 'plus.gif') oIMG.src = oIMG.src.replace('plus.gif','min.gif');
	else oIMG.src = oIMG.src.replace('min.gif','plus.gif');
	
	// onderstaande ivm IE bezoekers die hun cache uit hebben staan (vage IE)
	if(browser == 'Microsoft Internet Explorer')
	{
		oSrc = oIMG.src;
		oSetIMG = oIMG;
		setTimeout('setSource()',100);
	}
}

function setSource()
{
	oSetIMG.src = oSrc;
}

function basename(oPath)
{ 
	oPath = oPath.toString();
	oPath = oPath.split('?');
	oPath	= oPath[0];
	oSplit 	= oPath.split('\/');
	oFile 	= oSplit[oSplit.length-1];
	return oFile;	
}

function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}


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;
}



