/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landr�               |
|                                                   |
| This script can be used freely as long as all     |
| copyright messages are intact.                    |
|                                                   |
| Updated: 17.04.2003                               |
|--------------------------------------------------*/

// Node object
function Node(id, pid, name, url, title, target, icon, iconOpen, open)
{
	this.id 					= id;
	this.pid 					= pid;
	this.name 					= name;
	this.url 					= url;
	this.title 					= title;
	this.target 				= target;
	this.icon 					= icon;
	this.iconOpen 				= iconOpen;
	this._io 					= open || false;
	this._is 					= false;
	this._ls 					= false;
	this._hc 					= false;
	this._ai 					= 0;
	this._p;
};

// Tree object
function dTree(objName)
{
	this.config =
	{
		target					: null,
		folderLinks				: true,
		useSelection			: true,
		useCookies				: true,
		useLines				: true,
		useIcons				: true,
		useStatusText			: false,
		closeSameLevel			: false,
		inOrder					: false
	}

	this.icon =
	{
		root					: '/shared/img/dtree/bullit.gif',
		folder					: '/shared/img/dtree/folder.gif',
		folderOpen				: '/shared/img/dtree/folderopen.gif',
		node					: '/shared/img/dtree/page.gif',
		empty					: '/shared/img/dtree/empty.gif',
		line					: '/shared/img/dtree/line.gif',
		join					: '/shared/img/dtree/join.gif',
		joinBottom				: '/shared/img/dtree/joinbottom.gif',
		plus					: '/shared/img/dtree/plus.gif',
		plusBottom				: '/shared/img/dtree/plusbottom.gif',
		minus					: '/shared/img/dtree/minus.gif',
		minusBottom				: '/shared/img/dtree/minusbottom.gif',
		nlPlus					: '/shared/img/dtree/nolines_plus.gif',
		nlMinus					: '/shared/img/dtree/nolines_minus.gif'
	};

	this.obj 					= objName;
	this.aNodes 				= [];
	this.aIndent 				= [];
	this.root 					= new Node(-1);
	this.selectedNode 			= null;
	this.selectedFound 			= false;
	this.completed 				= false;
};

// Adds a new node to the node array
dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open)
{
	this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
};

// Open/close all nodes
dTree.prototype.openAll = function()
{
	this.oAll(true);
};

dTree.prototype.closeAll = function()
{
	this.oAll(false);
};

// Outputs the tree to the page
dTree.prototype.toString = function()
{
	var str = '<div class="dtree">\n';
	if (document.getElementById)
	{
		if (this.config.useCookies) this.selectedNode = this.getSelected();
		str += this.addNode(this.root);
	}
	else str += 'Browser not supported.';
	str += '</div>';
	if (!this.selectedFound) this.selectedNode = null;
	this.completed = true;
	return str;
};

// Creates the tree structure
dTree.prototype.addNode = function(pNode)
{
	var str = '';
	var n=0;
	if (this.config.inOrder) n = pNode._ai;
	for (n; n<this.aNodes.length; n++)
	{
		if (this.aNodes[n].pid == pNode.id)
		{
			var cn = this.aNodes[n];
			cn._p = pNode;
			cn._ai = n;
			this.setCS(cn);
			if (!cn.target && this.config.target) cn.target = this.config.target;
			if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
			if (!this.config.folderLinks && cn._hc) cn.url = null;
			if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound)
			{
				cn._is = true;
				this.selectedNode = n;
				this.selectedFound = true;
			}
			str += this.node(cn, n);
			if (cn._ls) break;
		}
	}
	return str;
};

// Creates the node icon, url and text
dTree.prototype.node = function(node, nodeId)
{
	niveau_bg = this.aIndent.length;
	var str = '<div class="dTreeNode" id="divnode'+nodeId+'">' + this.indent(node, nodeId);

	if (this.config.useIcons)
	{
		niveau = this.aIndent.length;

		if (niveau == 0) 			{ 	divwidth = 251;			}
		else if (niveau == 1) 		{ 	divwidth = 233;			}
		else if (niveau == 2) 		{ 	divwidth = 215;			}
		else if (niveau == 3) 		{ 	divwidth = 197;			}

		if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
		if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
		if (this.root.id == node.pid)
		{
			node.icon = this.icon.root;
			node.iconOpen = this.icon.root;
		}
		str += '<div class="dtree_imagediv"><img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" /></div><div class="dtree_contentdiv" style="width: '+ divwidth +'px;">';
	}

	if (node.url)
	{
		//str += '<a id="s' + this.obj + nodeId + '" class="pointer ' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
		str += '<a id="s' + this.obj + nodeId + '" class="pointer ' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" " ';
		if (node.title) str += ' title="' + node.title + '"';
		if (node.target) str += ' target="' + node.target + '"';
		if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
		if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
		str += ' onclick="' + this.obj + '.s(' + nodeId + '); '+node.url+'"';
		str += '>';

	}

	else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
		str += '<a onclick="' + this.obj + '.o(' + nodeId + ');" class="node pointer">';
		str += node.name;

	if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
		str += '</div></div>';
		str += '<br class="clear" />';

	// dit is de ombouw van elke node
	if (node._hc)
	{
		str += '<div id="d' + this.obj + nodeId + '" class="clip" style=" display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
		str += this.addNode(node);
		str += '</div>';
	}
	this.aIndent.pop();
	return str;
};

// Adds the empty and line icons
dTree.prototype.indent = function(node, nodeId)
{
	var str = '';

	if (this.root.id != node.pid)
	{
		for (var n=0; n<this.aIndent.length; n++)
			str += '<div class="dtree_imagediv"><img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" /></div>';
			(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);

		if (node._hc)
		{
			str += '<div class="dtree_imagediv"><a class="pointer" onclick="' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
			if (!this.config.useLines)
			{
				str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
			}
			else
			{
				str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
			}
			str += '" alt="" /></a></div>';
		}
		else
		{
			str += '<div class="dtree_imagediv"><img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" /></div>';
		}
		//str += node.pid;
	}
	return str;
};

// Checks if a node has any children and if it is the last sibling
dTree.prototype.setCS = function(node)
{
	var lastId;
	for (var n=0; n<this.aNodes.length; n++)
	{
		if (this.aNodes[n].pid == node.id) node._hc = true;
		if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
	}
	if (lastId==node.id) node._ls = true;
};

// Returns the selected node
dTree.prototype.getSelected = function()
{
	var sn = this.getCookie('cs' + this.obj);
	return (sn) ? sn : null;
};

// Highlights the selected node
dTree.prototype.s = function(id)
{
	if (!this.config.useSelection) return;
	var cn = this.aNodes[id];
	if (cn._hc && !this.config.folderLinks) return;
	if (this.selectedNode != id)
	{
		if (this.selectedNode || this.selectedNode==0)
		{
			eOld = document.getElementById("s" + this.obj + this.selectedNode);
			eOld.className = "node";
		}
		eNew = document.getElementById("s" + this.obj + id);
		eNew.className = "nodeSel";
		this.selectedNode = id;
		if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
	}
};

// Toggle Open or close
dTree.prototype.o = function(id)
{
	var cn = this.aNodes[id];
	this.nodeStatus(!cn._io, id, cn._ls);
	cn._io = !cn._io;

	if (cn._io == true && cn.id < 10)
	{
		document.getElementById("divnode"+cn.id).style.backgroundImage = 'url(../shared/img/dtree/stippels_uitvullen_niveau2.gif)';
	}
	else if (cn._io == true && cn.id > 10)
	{
		document.getElementById("divnode"+cn.id).style.backgroundImage = 'url(../shared/img/dtree/stippels_uitvullen_niveau3.gif)';
	}
	else if (cn._io == false && cn.id > 10)
	{
		document.getElementById("divnode"+cn.id).style.backgroundImage = 'url(../shared/img/dtree/stippels_uitvullen_niveau2.gif)';
	}
	if (this.config.closeSameLevel) this.closeLevel(cn);
	if (this.config.useCookies) this.updateCookie();
};

// Open or close all nodes
dTree.prototype.oAll = function(status)
{
	for (var n=0; n<this.aNodes.length; n++)
	{
		if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id)
		{
			this.nodeStatus(status, n, this.aNodes[n]._ls)
			this.aNodes[n]._io = status;
		}
	}
	if (this.config.useCookies) this.updateCookie();
};

// Opens the tree to a specific node
dTree.prototype.openTo = function(nId, bSelect, bFirst)
{
	if (!bFirst)
	{
		for (var n=0; n<this.aNodes.length; n++)
		{
			if (this.aNodes[n].id == nId)
			{
				nId=n;
				break;
			}
		}
	}
	var cn=this.aNodes[nId];
	if (cn.pid==this.root.id || !cn._p) return;
	cn._io = true;
	cn._is = bSelect;
	if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
	if (this.completed && bSelect) this.s(cn._ai);
	else if (bSelect) this._sn=cn._ai;
	this.openTo(cn._p._ai, false, true);
};

// Closes all nodes on the same level as certain node
dTree.prototype.closeLevel = function(node)
{
	for (var n=0; n<this.aNodes.length; n++)
	{
		if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc)
		{
			this.nodeStatus(false, n, this.aNodes[n]._ls);
			this.aNodes[n]._io = false;
			this.closeAllChildren(this.aNodes[n]);
		}
	}
}

// Closes all children of a node
dTree.prototype.closeAllChildren = function(node)
{
	for (var n=0; n<this.aNodes.length; n++)
	{
		if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc)
		{
			if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
			this.aNodes[n]._io = false;
			this.closeAllChildren(this.aNodes[n]);
		}
	}
}

// Change the status of a node(open or closed)
dTree.prototype.nodeStatus = function(status, id, bottom)
{
	eDiv	= document.getElementById('d' + this.obj + id);
	eJoin	= document.getElementById('j' + this.obj + id);
	if (this.config.useIcons)
	{
		eIcon	= document.getElementById('i' + this.obj + id);
		eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
	}
	eJoin.src = (this.config.useLines)?
	((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
	((status)?this.icon.nlMinus:this.icon.nlPlus);
	eDiv.style.display = (status) ? 'block': 'none';
};

// [Cookie] Clears a cookie
dTree.prototype.clearCookie = function()
{
	var now = new Date();
	var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
	this.setCookie('co'+this.obj, 'cookieValue', yesterday);
	this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};

// [Cookie] Sets value in a cookie
dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure)
{
	document.cookie =
	escape(cookieName) + '=' + escape(cookieValue)
	+ (expires ? '; expires=' + expires.toGMTString() : '')
	+ (path ? '; path=' + path : '')
	+ (domain ? '; domain=' + domain : '')
	+ (secure ? '; secure' : '');
};

// [Cookie] Gets a value from a cookie
dTree.prototype.getCookie = function(cookieName)
{
	var cookieValue = '';
	var posName = document.cookie.indexOf(escape(cookieName) + '=');
	if (posName != -1)
	{
		var posValue = posName + (escape(cookieName) + '=').length;
		var endPos = document.cookie.indexOf(';', posValue);
		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
		else cookieValue = unescape(document.cookie.substring(posValue));
	}
	return (cookieValue);
};

// [Cookie] Returns ids of open nodes as a string
dTree.prototype.updateCookie = function()
{
	var str = '';
	for (var n=0; n<this.aNodes.length; n++)
	{
		if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id)
		{
			if (str) str += '.';
			str += this.aNodes[n].id;
		}
	}
	this.setCookie('co' + this.obj, str);
};

// [Cookie] Checks if a node id is in a cookie
dTree.prototype.isOpen = function(id)
{
	var aOpen = this.getCookie('co' + this.obj).split('.');
	for (var n=0; n<aOpen.length; n++)
		if (aOpen[n] == id) return true;
	return false;
};

// If Push and pop is not implemented by the browser
if (!Array.prototype.push)
{
	Array.prototype.push = function array_push()
	{
		for(var i=0;i<arguments.length;i++)
			this[this.length]=arguments[i];
		return this.length;
	}
};

if (!Array.prototype.pop)
{
	Array.prototype.pop = function array_pop()
	{
		lastElement = this[this.length-1];
		this.length = Math.max(this.length-1,0);
		return lastElement;
	}
};

//---------------------------------------------------------------------------------------------------------------------
// SCRIPTS LADEN
//---------------------------------------------------------------------------------------------------------------------

		function scriptsladen_onbeforeload()
		{
			MM_preloadImages('/shared/img/loading.gif');
			laden();
		}
		function scriptsladen_onload()
		{
			MM_preloadImages('/shared/img/loading.gif');
			calc_sizes();
			correctPNG();
			alphaBackgrounds();
			//klaarmetladen();
		}
		function scriptsladen_onresize()
		{
			calc_sizes();
		}

		//window.onbeforeload = scriptsladen_onbeforeload;
		window.onload = scriptsladen_onload;
		window.onresize = scriptsladen_onresize;

//---------------------------------------------------------------------------------------------------------------------
// EINDE SCRIPTS LADEN
//---------------------------------------------------------------------------------------------------------------------

		function MM_preloadImages()
			{
			var d=document;
			if(d.images)
			{
				if(!d.MM_p) d.MM_p=new Array();
				var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
				for(i=0; i<a.length; i++)
				if (a[i].indexOf("#")!=0)
				{
					d.MM_p[j]=new Image;
					d.MM_p[j++].src=a[i];
				}
			}
		}

		function laden()
		{
			document.getElementById('body_laden').className 			= 'body_laden_hidden';
		}
		function klaarmetladen()
		{
			document.getElementById('body_laden').className 			= 'body_laden_normal';
			document.getElementById('laden_background').className 		= 'hide_display';
			document.getElementById('laden_content').className 			= 'hide_display';
		}
//---------------------------------------------------------------------------------------------------------------------
// CALCULATIE
//---------------------------------------------------------------------------------------------------------------------

		function calc_sizes()
		{

			var windowname										= window.name;

			var main_container_width							= 950;
			var height_of_footer 								= 26;
			var paddingcontent_ALL								= 10;
			if(document.getElementById("header"))
			    var height_of_header 								= document.getElementById("header").clientHeight;
			else
			    var height_of_header = 0;

			var kruimelpad_height								= 20;
			var kruimelpad_width								= main_container_width - (paddingcontent_ALL * 2);
			var containerelement_small_height					= 95;
			var containerelement_large_height					= 240;
			var containerelement_small_width					= 300;
			var containerelement_smaller_width					= 250;
			var containerelement_large_width					= 310;
			var hoofdscherm_width								= 620;
			var div_small_height								= 74;
			var div_large_height								= 219;
			var buttons											= 24;

			// browser ophalen
			var non_IE 											= (typeof( window.innerWidth ) == 'number');
			var IE_6 											= (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ));
			var IE_4 											= (document.body && ( document.body.clientWidth || document.body.clientHeight ));

			if( non_IE )
			{
				//Non-IE
				bodywidth 										= window.innerWidth;
				bodyheight 										= window.innerHeight;
				paddingcontent_FF								= 10;
				borders_FF										= 2;
				paddingcontent_IE								= 0;
				borders_IE										= 0;
				cursor 											= 'pointer';
				//alert ("geen IE");
			}

			else if( IE_6 )
			{
				//IE 6+ in 'standards compliant mode'
				bodywidth 										= document.documentElement.clientWidth;
				bodyheight 										= document.documentElement.clientHeight;
				paddingcontent_FF								= 0;
				borders_FF										= 0;
				paddingcontent_IE								= 10;
				borders_IE										= 2;
				cursor 											= 'hand';
				//alert ("IE 6+");
			}
			else
			{
				//IE 4 compatible
				bodywidth 										= document.body.clientWidth;
				bodyheight 										= document.body.clientHeight;
				paddingcontent_FF								= 0;
				borders_FF										= 0;
				paddingcontent_IE								= 10;
				borders_IE										= 2;
				cursor											= 'hand';
				//alert ("IE 4+");
			}


			// voor allemaal gelijk (popup en gewone paginas)
			kruimelpad_height									= kruimelpad_height - borders_FF;
			kruimelpad_height_inc								= kruimelpad_height + (paddingcontent_ALL * 2) + (borders_FF * 2); // borders en paddings
			kruimelpad_width									= kruimelpad_width - borders_FF;
			containerelement_small_height						= containerelement_small_height - borders_FF;
			containerelement_large_height						= containerelement_large_height - borders_FF;
			containerelement_small_width						= containerelement_small_width - borders_FF;
			containerelement_large_width						= containerelement_large_width - borders_FF;
			hoofdscherm_width									= hoofdscherm_width - borders_FF;
			div_titel_height									= kruimelpad_height - (1 + (borders_FF / 2));
			div_small_height									= div_small_height - paddingcontent_FF;
			div_large_height									= div_large_height - paddingcontent_FF;

				// hand cursor op de player buttons
				for (var i = 1; i<= 9; i++)
				{
					if (document.getElementById("audioplayer_btn"+i))
					{
						document.getElementById("audioplayer_btn"+i).style.cursor 		= cursor;
					}
				}

			// als het een popup is



			if (windowname == 'popup' || document.getElementById("agendapuntList")) // aanpassing NCOD niet in popup
			{

				if(document.getElementById("content_container"))
				{
				    document.getElementById("content_container").style.height 				= bodyheight - (height_of_header + height_of_footer + (paddingcontent_FF / 2) + borders_FF) + "px";
				}
				document.getElementById("main_container").style.width 					= bodywidth + "px";
				// player, zoeken en sprekerinformatie content
				if (document.getElementById("buttons_audio"))
				{
					document.getElementById("buttons_audio").style.height 				= buttons - (borders_FF / 2) + "px";
				}
				if (document.getElementById("div_content_videofragment"))
				{
					document.getElementById("div_content_videofragment").style.height 	= div_large_height - buttons + "px";
				}
				if (document.getElementById("div_content_audiofragment"))
				{
					document.getElementById("div_content_audiofragment").style.height 	= div_small_height - buttons + "px";
				}

				// bij notucastvideo
				if (document.getElementById("container_mediafragment2"))
				{
				    if (document.getElementById("agendapuntList"))
				    {
						document.getElementById("agendapuntList").style.height 				= bodyheight - (paddingcontent_ALL * 5) - height_of_header -  height_of_footer + paddingcontent_IE + "px";
				    }

				    document.getElementById("container_mediafragment").style.height 		= bodyheight - (paddingcontent_ALL * 2) - height_of_header -  height_of_footer + (borders_FF / 2) + "px";
				    document.getElementById("container_mediafragment").style.width 			= bodywidth - ((paddingcontent_ALL * 2) + 300) - (borders_FF * 2) + "px";

				    //document.getElementById("container_mediafragment2").style.height 		= bodyheight - (paddingcontent_ALL * 2) - height_of_header -  height_of_footer + "px";
				    document.getElementById("container_mediafragment2").style.height 		= 218 + paddingcontent_IE + paddingcontent_IE + paddingcontent_FF + paddingcontent_FF + borders_FF + "px";
				    document.getElementById("container_mediafragment2").style.width 		= 290 + "px";

				    document.getElementById("container_mediafragment3").style.height 		= bodyheight - (paddingcontent_ALL * 2) - height_of_header -  height_of_footer - 251 + "px";
				    document.getElementById("container_mediafragment3").style.width 		= 290 + "px";
				}
				else if(document.getElementById("container_mediafragmentA"))
				{	// bij notucastAudio
				    if (document.getElementById("agendapuntList"))
				    {
						document.getElementById("agendapuntList").style.height 				= bodyheight - (paddingcontent_ALL * 5) - height_of_header -  height_of_footer + paddingcontent_IE + "px";
				    }

				    document.getElementById("container_mediafragment").style.height 		= bodyheight - (paddingcontent_ALL * 2) - height_of_header -  height_of_footer + (borders_FF / 2) + "px";
				    document.getElementById("container_mediafragment").style.width 			= bodywidth - ((paddingcontent_ALL * 2) + 300) - (borders_FF * 2) + "px";

				    //document.getElementById("container_mediafragmentA").style.height 		= 200 + paddingcontent_IE + paddingcontent_IE + paddingcontent_FF + paddingcontent_FF + borders_FF + "px";
				    document.getElementById("container_mediafragmentA").style.width 		= 290 + "px";
				    document.getElementById("container_mediafragmentA").style.height = 45+"px";

				    document.getElementById("container_mediafragment3").style.height 		= bodyheight - (paddingcontent_ALL * 2) - height_of_header -  height_of_footer - 56+ "px";
				    document.getElementById("container_mediafragment3").style.width 		= 290 + "px";
				}
				// bij niet notucast
				else
				{
				    if(document.getElementById("container_mediafragment"))
				    {
					document.getElementById("container_mediafragment").style.height 		= bodyheight - (paddingcontent_ALL * 2) - height_of_header -  height_of_footer - borders_IE - borders_FF + "px";
					document.getElementById("container_mediafragment").style.width 			= bodywidth - (paddingcontent_ALL * 2) - borders_IE - borders_FF + "px";

					height_container_mediafragment 											= document.getElementById("container_mediafragment").clientHeight;
					height_container_titel 													= document.getElementById("mediafragment_titel").clientHeight;
					document.getElementById("popuptekst").style.height 						= height_container_mediafragment - buttons - height_container_titel - (borders_FF / 2) - (borders_IE / 2) + "px";
					if (document.getElementById("div_content_videofragment"))
					{
						videodivwidth 														= document.getElementById("div_content_videofragment").clientWidth;
						padding																= (videodivwidth - 298) / 2;
						document.getElementById("div_content_videofragment").style.paddingLeft  	= padding + "px";
						document.getElementById("div_content_videofragment").style.height  			= 201 + "px";
						document.getElementById("div_content_videofragment").style.paddingTop  		= 6 + "px";
					}
				    }
				}
			}
			// zo niet
			else
			{
				if(document.getElementById("content_container"))
				{
				    document.getElementById("content_container").style.height 				= bodyheight - (height_of_header + height_of_footer + paddingcontent_FF) + "px";
				}
				if(document.getElementById("navig"))
				{
				    document.getElementById("navig").style.cursor 							= cursor;
				}
				if(document.getElementById("main_container"))
				{
				    document.getElementById("main_container").style.width 					= main_container_width + "px";
				}
				if(document.getElementById("rechterkolom"))
				{
				    document.getElementById("rechterkolom").style.width 					= bodywidth - main_container_width + "px";
				    document.getElementById("rechterkolom").style.height 					= bodyheight + "px";
				}

				// kijken welke layout er is
				var div = document.getElementsByTagName("div");
				for (var i = 0; i< div.length; i++)
				{
					if( div[i].className == 'empty' )
					{
						layout = div[i].id;
					}
					if( div[i].className == 'div_titel' | div[i].className == 'div_titel_kruimel' )
					{
						div[i].style.height 				= div_titel_height + "px";
					}
				}
				if (typeof(layout)!='undefined' && layout == 'layout0')
				{
					// index
					for (var i = 0; i< div.length; i++)
					{
						if( div[i].className == 'containers_content' | div[i].className == 'containers_content_hidden' )
						{
							div_containers_content_id = div[i].id;
							document.getElementById(div_containers_content_id).style.width 				= main_container_width - (paddingcontent_ALL * 2) + "px";
							document.getElementById(div_containers_content_id).style.marginBottom 		= 10 + "px";
						}
					}
					// zoeken
					if (document.getElementById("search_results"))
					{
						document.getElementById('search_results').style.height							= 200 + 'px';
						height_of_zoeken																= document.getElementById("container_start1").clientHeight;
						document.getElementById("container_hoofdscherm_zoeken").style.height 			= bodyheight - (height_of_zoeken + height_of_header + height_of_footer + kruimelpad_height_inc + paddingcontent_ALL + 1) + (borders_FF / 2) + "px";
					}
				}
				else if (typeof(layout)!='undefined' && layout == 'layout1')
				{
					// bepaalde elementen ophalen (om mee te rekenen)
					mediafragment_height_inc												= containerelement_small_height + (paddingcontent_ALL * 2) + (borders_FF); // borders en paddings (eronder)

					// content containers
					document.getElementById("container_hoofdscherm").style.height 			= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + paddingcontent_ALL + 1) + (borders_FF / 2) + "px";
					document.getElementById("container_hoofdscherm").style.width 			= hoofdscherm_width + "px";
					document.getElementById("container_overzichtsmenu").style.height 		= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + mediafragment_height_inc + 1) + (borders_FF / 2) + "px";
					document.getElementById("container_overzichtsmenu").style.width 		= containerelement_small_width + "px";
					document.getElementById("container_kruimelpad").style.height 			= kruimelpad_height + "px";
					document.getElementById("container_kruimelpad").style.width 			= kruimelpad_width + "px";
					document.getElementById("container_mediafragment").style.height 		= containerelement_small_height + "px";
					document.getElementById("container_mediafragment").style.width 			= containerelement_small_width + "px";

					// content divs
					document.getElementById("div_content_hoofdscherm").style.height 		= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + paddingcontent_ALL + 22 + paddingcontent_FF) + borders_FF + (borders_FF / 2) + "px";
					document.getElementById("div_content_overzichtsmenu").style.height 		= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + mediafragment_height_inc + 22 + paddingcontent_FF) + borders_FF + (borders_FF / 2) + "px";
					document.getElementById("div_content_overzichtsmenu").style.width 		= containerelement_small_width - paddingcontent_FF - borders_IE + "px";
					document.getElementById("div_content_audiofragment").style.height 		= div_small_height - buttons + "px";

					// player, zoeken en sprekerinformatie content
					document.getElementById("buttons_audio").style.height 					= buttons - (borders_FF / 2) + "px";
				}
				else if (typeof(layout)!='undefined' && layout == 'layout2')
				{
					// bepaalde elementen ophalen (om mee te rekenen)
					mediafragment_height_inc												= containerelement_small_height + (paddingcontent_ALL * 2) + (borders_FF); // borders en paddings (eronder)
					document.getElementById("zoekbutton").style.cursor 						= cursor;

					// content containers
					document.getElementById("container_hoofdscherm").style.height 			= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + mediafragment_height_inc + 1) + (borders_FF / 2) + "px";
					document.getElementById("container_hoofdscherm").style.width 			= hoofdscherm_width + "px";
					document.getElementById("container_overzichtsmenu").style.height 		= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + mediafragment_height_inc + 1) + (borders_FF / 2) + "px";
					document.getElementById("container_overzichtsmenu").style.width 		= containerelement_small_width + "px";
					document.getElementById("container_kruimelpad").style.height 			= kruimelpad_height + "px";
					document.getElementById("container_kruimelpad").style.width 			= kruimelpad_width + "px";
					document.getElementById("container_mediafragment").style.height 		= containerelement_small_height + "px";
					document.getElementById("container_mediafragment").style.width 			= containerelement_small_width + "px";
					document.getElementById("container_sprekersinformatie").style.height 	= containerelement_small_height + "px";
					document.getElementById("container_sprekersinformatie").style.width 	= containerelement_large_width + "px";
					document.getElementById("container_zoeken").style.height 				= containerelement_small_height + "px";
					document.getElementById("container_zoeken").style.width 				= containerelement_small_width + "px";

					// content divs
					document.getElementById("div_content_hoofdscherm").style.height 		= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + mediafragment_height_inc + 22 + paddingcontent_FF) + borders_FF + (borders_FF / 2) + "px";
					document.getElementById("div_content_overzichtsmenu").style.height 		= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + mediafragment_height_inc + 22 + paddingcontent_FF) + borders_FF + (borders_FF / 2) + "px";
					document.getElementById("div_content_overzichtsmenu").style.width 		= containerelement_small_width - (2 + paddingcontent_FF - borders_FF) + "px";
					if (document.getElementById("div_content_audiofragment"))
					{
						document.getElementById("div_content_audiofragment").style.height 		= div_small_height - buttons + "px";
					}
					if (document.getElementById("div_content_videofragment"))
					{
						document.getElementById("div_content_videofragment").style.height 		= div_small_height - buttons + "px";
					}
					document.getElementById("div_content_zoeken").style.height 				= div_small_height - buttons + "px";
					document.getElementById("div_content_zoeken").style.overflow 			= "hidden";
					document.getElementById("div_content_sprekersinformatie").style.width 	= containerelement_smaller_width - paddingcontent_FF + "px";
					document.getElementById("div_content_sprekersinformatie").style.height 	= div_small_height - buttons + "px";
					document.getElementById("div_content_sprekersinformatie_foto").style.width 	= 60 - (borders_FF / 2) + "px";

					// player, zoeken en sprekerinformatie content
					if(document.getElementById("buttons_audio"))
					    document.getElementById("buttons_audio").style.height 					= buttons - (borders_FF / 2) + "px";
					document.getElementById("buttons_zoeken").style.height 					= buttons - (borders_FF / 2) + "px";
					document.getElementById("buttons_sprekersinformatie").style.height 		= buttons - (borders_FF / 2) + "px";
				}
				else if (typeof(layout)!='undefined' && layout == 'layout3')
				{
					// bepaalde elementen ophalen (om mee te rekenen)
					mediafragment_height_inc												= containerelement_large_height + (paddingcontent_ALL * 2) + (borders_FF); // borders en paddings (eronder)
					zoeken_height_inc														= containerelement_small_height + (paddingcontent_ALL * 2) + (borders_FF); // borders en paddings (eronder)
					document.getElementById("zoekbutton").style.cursor 						= cursor;

					// content containers
					document.getElementById("container_hoofdscherm").style.height 			= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + zoeken_height_inc + 1) + (borders_FF / 2) + "px";
					document.getElementById("container_hoofdscherm").style.width 			= hoofdscherm_width + "px";
					document.getElementById("container_overzichtsmenu").style.height 		= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + mediafragment_height_inc + 1) + (borders_FF / 2) + "px";
					document.getElementById("container_overzichtsmenu").style.width 		= containerelement_small_width + "px";
					document.getElementById("container_kruimelpad").style.height 			= kruimelpad_height + "px";
					document.getElementById("container_kruimelpad").style.width 			= kruimelpad_width + "px";
					document.getElementById("container_mediafragment").style.height 		= containerelement_large_height + "px";
					document.getElementById("container_mediafragment").style.width 			= containerelement_small_width + "px";
					document.getElementById("container_sprekersinformatie").style.height 	= containerelement_small_height + "px";
					document.getElementById("container_sprekersinformatie").style.width 	= containerelement_large_width + "px";
					document.getElementById("container_zoeken").style.height 				= containerelement_small_height + "px";
					document.getElementById("container_zoeken").style.width 				= containerelement_small_width + "px";

					// content divs
					document.getElementById("div_content_hoofdscherm").style.height 		= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + zoeken_height_inc + 22 + paddingcontent_FF) + borders_FF + (borders_FF / 2) + "px";
					document.getElementById("div_content_overzichtsmenu").style.height 		= bodyheight - (height_of_header + height_of_footer + kruimelpad_height_inc + mediafragment_height_inc + 22 + paddingcontent_FF) + borders_FF + (borders_FF / 2) + "px";

					if (document.getElementById("div_content_audiofragment"))
					{
						document.getElementById("div_content_audiofragment").style.height 		= div_large_height - buttons + paddingcontent_FF + "px";
					}
					if (document.getElementById("div_content_videofragment"))
					{
						document.getElementById("div_content_videofragment").style.height 		= div_large_height - buttons + paddingcontent_FF + "px";
					}

					document.getElementById("div_content_zoeken").style.height 				= div_small_height - buttons + "px";
					document.getElementById("div_content_zoeken").style.overflow 			= "hidden";
					document.getElementById("div_content_sprekersinformatie").style.width 	= containerelement_smaller_width - paddingcontent_FF + "px";
					document.getElementById("div_content_sprekersinformatie").style.height 	= div_small_height - buttons + "px";
					document.getElementById("div_content_sprekersinformatie_foto").style.width 	= 60 - (borders_FF / 2) + "px";

					// player, zoeken en sprekerinformatie content
					if(document.getElementById("buttons_video"))
					{
					    document.getElementById("buttons_video").style.height 					= buttons - (borders_FF / 2) + "px";
					}
					document.getElementById("buttons_zoeken").style.height 					= buttons - (borders_FF / 2) + "px";
					document.getElementById("buttons_sprekersinformatie").style.height 		= buttons - (borders_FF / 2) + "px";
				}
			}
		}

//---------------------------------------------------------------------------------------------------------------------
// EINDE CALCULATIE
//---------------------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------------------
// POPUP CONTENT
//---------------------------------------------------------------------------------------------------------------------

		function popup_content(name, type,  popupwidth, popupheight,opts)
		{
			var leftstart = (screen.width/2) - (popupwidth/2);
			var topstart = (screen.height/2) - (popupheight/2);
			var properties = "width="+popupwidth+", height="+popupheight+", left="+leftstart+", top="+topstart+", toolbar=no, titlebar=no, title=0, location=no,scrollbars=yes,status=no,resizable=no";
			var popup = "/popup.php?i="+name+"&type="+type+'&'+opts;
			window.open(popup,'popup',properties);
		}

		function popupRaadsInfo(name, type,  popupwidth, popupheight,opts)
		{
			var leftstart = (screen.width/2) - (popupwidth/2);
			var topstart = (screen.height/2) - (popupheight/2);
			var properties = "width="+popupwidth+", height="+popupheight+", left="+leftstart+", top="+topstart+", toolbar=no, titlebar=no, title=0, location=no,scrollbars=yes,status=no,resizable=no";
			var popup = "/popup.php?i="+name+"&type="+type+'&'+opts;
			window.open(popup,'popup',properties);
		}


//---------------------------------------------------------------------------------------------------------------------
// EINDE POPUP CONTENT
//---------------------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------------------
// STATUSBALK VERBERGEN
//---------------------------------------------------------------------------------------------------------------------

		function hidestatus()
		{
			window.status=''
			return true
		}
		if (document.layers)
		document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

		document.onmouseover=hidestatus
		document.onmouseout=hidestatus

//---------------------------------------------------------------------------------------------------------------------
// EINDE STATUSBALK VERBERGEN
//---------------------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------------------
// PAGINALINK (BV OP TD OF DIV)
//---------------------------------------------------------------------------------------------------------------------

		function paginalink(theURL,winName)
			{ //v2.0
			window.open(theURL,winName);
			}

//---------------------------------------------------------------------------------------------------------------------
// EINDE PAGINALINK (BV OP TD OF DIV)
//---------------------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------------------
// PNG FIX
//---------------------------------------------------------------------------------------------------------------------

		var strGif = "/shared/img/spacer.gif"
		var strFilter = "progid:DXImageTransform.Microsoft.AlphaImageLoader"
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])

		function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
		{
		   var arVersion = navigator.appVersion.split("MSIE")
		   var version = parseFloat(arVersion[1])
		   if ((version >= 5.5 && version < 7) && (document.body.filters))
		   {
			  for(var i=0; i<document.images.length; i++)
			  {
				 var img = document.images[i]
				 var imgName = img.src.toUpperCase()
				 if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
				 {
					var imgID = (img.id) ? "id='" + img.id + "' " : ""
					var imgClass = (img.className) ? "class='" + img.className + "' " : ""
					var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
					var imgStyle = "display:inline-block;" + img.style.cssText
					if (img.align == "left") imgStyle = "float:left;" + imgStyle
					if (img.align == "right") imgStyle = "float:right;" + imgStyle
					if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
					if (img.useMap)
					  {
						 strAddMap = "<img style=\"position:relative; left:0px; top:-" + img.height + "px;"
						 + "height:" + img.height + "px;width:" + img.width +"\" "
						 + "src=\"" + strGif + "\" usemap=\"" + img.useMap
						 + "\" border=\"" + img.border + "\">"
					  }
					var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + " width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
					if (img.useMap) strNewHTML += strAddMap
					img.outerHTML = strNewHTML
					i = i-1
				 }
			  }
		   }
		}

		function findImgInputs(oParent)
		{
		   var oChildren = oParent.children
		   if (oChildren)
		   {
			  for (var i=0; i < oChildren.length; i++ )
			  {
				 var oChild = oChildren(i)
				 if ((oChild.type == 'image') && (oChild.src))
				 {
					 var origSrc = oChild.src
					 oChild.src = strGif
					 oChild.style.filter = strFilter + "(src='" + origSrc + "')"
				 }
				 findImgInputs(oChild)
			  }
		   }
		}

		function alphaBackgrounds() // correctly handle PNG "BACKGROUNDCOLOUR" transparency in Win IE 5.5 or higher.
			{
			var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
			var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

			var div = document.getElementsByTagName("div");
			for (var i = 0; i< div.length; i++)
			{
				if (itsAllGood)
				{
					var bg = div[i].currentStyle.backgroundImage;
					if (bg.match(/\.png/i) != null)
					{
						var mypng = bg.substring(5,bg.length-2);
						div[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
						div[i].style.backgroundImage = "url('/shared/img/spacer.gif')";
					}
				}
			}
		}

//---------------------------------------------------------------------------------------------------------------------
// EINDE PNG FIX
//---------------------------------------------------------------------------------------------------------------------



function switchMedia(newType)
{
    sendRequest('/shared/switchMedia.php?mediaPref='+newType,catchSwitchMedia);
}

function switchMediaNoReload(newType)
{
    streamPreference=newType;
    sendRequest('/shared/switchMedia.php?mediaPref='+newType,catchSwitchMediaNoReload);
}


function catchSwitchMedia(req)
{
    var text = req.responseText;
    window.location.reload();
}

function catchSwitchMediaNoReload(req)
{
    var text = req.responseText;
}


function selectTxt(item)
{
    if(document.getElementById(item))
    {
	document.getElementById(item).focus();
	document.getElementById(item).select();

    }
}


function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent( obj, type, fn )
{
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent)
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}


function openInNewWindow() {
    var newWindow = window.open(this.getAttribute('href'), '_blank');
    newWindow.focus();
    return false;
}


function getNewWindowLinks() {

	if (document.getElementById && document.createElement && document.appendChild) {
		var links = document.getElementsByTagName('a');
		var link;
		for (var i = 0; i < links.length; i++) {
			link = links[i];
			if (/\bnon\-target\b/.exec(link.className)) {
				link.onclick = openInNewWindow;
			}
		}

	}
}

addEvent(window, 'load', getNewWindowLinks);