/*--------------------------------------------------|
| 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                               |
|--------------------------------------------------*/


function swapVisibleElm(elmId)
{
    if(document.getElementById(elmId)){
	if(document.getElementById(elmId).style.visibility=='hidden' || document.getElementById(elmId).style.visibility==''){
	    document.getElementById(elmId).style.visibility='visible';
	    document.getElementById(elmId).style.display='block';
	}else{
	    document.getElementById(elmId).style.visibility='hidden';
	    document.getElementById(elmId).style.display='none';	
	}
    }
}

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





// getElementsByClassName omdat de browser uit de hell dit niet ondersteunt
var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
};





//---------------------------------------------------------------------------------------------------------------------
// 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
//---------------------------------------------------------------------------------------------------------------------

// check for WMP7 and activeX, if not available, display non activeX version
AX=true;
var IE    = (navigator.userAgent.indexOf("MSIE") != -1);
var WMP7;
if (IE)
{
     WMP7 = new ActiveXObject('WMPlayer.OCX');
}
if (! WMP7)
    AX=false;
if (! IE)
    AX=false;


		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";
					}
				    }
				}
			}
			// geen popup
			else
			{
				if(document.getElementById("content_container"))
				{
				    heightOfMainpart=bodyheight - (height_of_header + height_of_footer + paddingcontent_FF);
				    document.getElementById("content_container").style.height 				=  heightOfMainpart+ "px";
				    if(document.getElementById("help_content"))
				    {
					helpHeight=bodyheight - (height_of_header + height_of_footer + paddingcontent_FF)-100;
					document.getElementById("help_content").style.height= helpHeight+"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.height 		= getVideoHeight()+buttons + "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";
					

					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"))
					{
						vidHeight=getVideoHeight() +div_titel_height+borders_FF+borders_IE+buttons;
						
						if(!document.getElementById('controlbuttons'))
						    vidHeight-=24; // flash video object
						    
						document.getElementById("container_mediafragment").style.height 	=  vidHeight+"px";

						heightOfOverzicht= heightOfMainpart-kruimelpad_height_inc-vidHeight-(borders_IE)-(borders_FF)-(paddingcontent_FF)-(paddingcontent_IE*2);
						if(AX) heightOfOverzicht+=1; // yaieh
						
						document.getElementById("container_overzichtsmenu").style.height	= heightOfOverzicht+"px";
						
						document.getElementById("div_content_overzichtsmenu").style.height	= (heightOfOverzicht-30)+"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") && !AX)
					{
					    //document.getElementById("buttons_video").style.height 					= buttons - (borders_FF / 2) +14000+ "px";
					    document.getElementById("buttons_video").style.height = 200+ "px";
					    //alert(document.getElementById("buttons_video").style.height);
					} 
					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;
			}
		}

	}
}

function pollSwap(pollId)
{
    swapVisibleElm('pollObj_'+pollId);

    if(document.getElementById('pollImage_'+pollId))
    {
	imgValue=document.getElementById('pollImage_'+pollId).src;
	if(imgValue.substr((imgValue.length-10),6)=='goOpen' || imgValue.substr((imgValue.length-13),9)=='goOpen_mo'){
	    type='closed';
	}else{ type='opened'; }

	if(type=='closed')
    	    setIdImage('pollImage_'+pollId,'/shared/img/icons/stemming_goClose_mo.png');
	else
	    setIdImage('pollImage_'+pollId,'/shared/img/icons/stemming_goOpen_mo.png');
    }
}

function pollHover(ad,pollId)
{
    if(document.getElementById('pollImage_'+pollId))
    {
	imgValue=document.getElementById('pollImage_'+pollId).src;
	if(imgValue.substr((imgValue.length-10),6)=='goOpen' || imgValue.substr((imgValue.length-13),9)=='goOpen_mo'){
	    type='closed';
	}else{ type='opened'; }

	if(ad=='active'){
	    if(type=='closed')
		setIdImage('pollImage_'+pollId,'/shared/img/icons/stemming_goOpen_mo.png');
	    else
		setIdImage('pollImage_'+pollId,'/shared/img/icons/stemming_goClose_mo.png');
        }else if(ad=='deactive'){
	    if(type=='closed')
		setIdImage('pollImage_'+pollId,'/shared/img/icons/stemming_goOpen.png');
	    else
		setIdImage('pollImage_'+pollId,'/shared/img/icons/stemming_goClose.png');
	}
	
	//alert(ad+' '+type);
    }
}

function setIdImage(div,image)
{
    if(document.getElementById(div))
    {
	document.getElementById(div).src=image;
    }
}


/******* share ***/

function elmOC(elmId,type){
    elm=document.getElementById(elmId);
    
    if(elm){
	if(type=='open')
	{
	    elm.style.display='block';
	    elm.style.visibility='visible';
	}else if(type=='close'){
    	    elm.style.display='none';
    	    elm.style.visibility='hidden';	
	}
    }
}

function openTaF(){
    showBackground();
    elmOC('embedPopup','close');
    elmOC('tafPopup','open');
    
    if(document.getElementById('player')){
	document.getElementById('player').style.visibility='hidden';
    }
}
function closeTaF(){
    hideBackground();
    
    elmOC('tafPopup','close');
    
    if(document.getElementById('player')){
	document.getElementById('player').style.visibility='visible';
    }
}

function openEmbed(){
    showBackground();
    elmOC('tafPopup','close');
    elmOC('embedPopup','open');
    
    if(document.getElementById('embedCode')){
	document.getElementById('embedCode').focus();
	document.getElementById('embedCode').select();
    }
    if(document.getElementById('player')){
	document.getElementById('player').style.visibility='hidden';
    }
    
}
function closeEmbed(){
    hideBackground();
    elmOC('embedPopup','close');
    
    if(document.getElementById('player')){
	document.getElementById('player').style.visibility='visible';
    }

}

function showBackground(){
    elmOC('tafBg','open');
}
function hideBackground(){
    elmOC('tafBg','close');
}


var shareDescription='';
var shareUrl='';
var shareApId=false;

function openShare(e,apId,flvObjUrl,flvFileUrl,agendaId,flvKey,tafUrl,tafDescr)
{
//alert(e,apId,flvObjUrl,flvFileUrl,agendaId,flvKey,tafUrl,tafDescr);

    var top = 0, left = 0;
    if (!e) { e = window.event; }
    var myTarget = e.currentTarget;
    if (!myTarget) {
        myTarget = e.srcElement;
    }
    else if (myTarget == "undefined") {
        myTarget = e.srcElement;
    }
    
    myTarget.style.backgroundImage = "url('/shared/img/sharing/delen_button_mo.png')";
    
    while(myTarget!= document.body) {
        top += myTarget.offsetTop;
        left += myTarget.offsetLeft;
        myTarget = myTarget.offsetParent;
    }
    
    if(document.getElementById('div_content_hoofdscherm'))
    {
	if(document.getElementById('div_content_hoofdscherm').scrollTop){
	    top -= document.getElementById('div_content_hoofdscherm').scrollTop;
	}
    }
    
    // share menu opmaken
    if(document.getElementById('sharePopup')){
	shareDescription=tafDescr;
	shareUrl=tafUrl;
	shareApId=apId;

	menuContent='<a href="#" id="taf" onclick="openTaF()"></a>'+
            	    '<a href="http://www.hyves.nl/profilemanage/add/tips/?rating=5&amp;name='+shareDescription+'&amp;text='+shareUrl+'&amp;" id="shareHyves"></a>'+
            	    '<a href="http://nujij.nl/jij.lynkx?t='+shareDescription+'&amp;u='+shareUrl+'" id="shareNujij"></a>'+
            	    '<a href="http://twitter.com/home?status='+shareDescription+'%20'+shareUrl+'" id="shareTwitter"></a>'+
            	    '<a href="http://www.facebook.com/share.php?u='+shareUrl+'&amp;t='+shareDescription+'" id="shareFacebook"></a>'+
            	    '<a href="#" id="embed" onclick="openEmbed()"></a>';
	document.getElementById('sharePopup').innerHTML=menuContent;
	
	buildFlashEmbedCode('embedCode',flvObjUrl,flvFileUrl,agendaId,flvKey)
    }

    // alle flash votings dichtklappen
    votes = getElementsByClassName('pollObj');
    for (i=0;i<votes.length;i++){	
	if(votes[i].style.visibility=='visible'){
	    
	    tmpParentId=votes[i].id.substr(8,votes[i].id.length);
	    pollSwap(tmpParentId);
	    setIdImage('pollImage_'+tmpParentId,'/shared/img/icons/stemming_goOpen.png');
	}
    }

    // share menu tonen	
    sharePopup(top,left);


}
function sharePopup(top, left)
{
  var newTop = top - 5;
  var newLeft = left - 123;
  
  
  document.getElementById("closePopup").style.display = 'block'
  document.getElementById("sharePopup").style.visibility = 'visible';
  document.getElementById("sharePopup").style.top = newTop+'px';
  document.getElementById("sharePopup").style.left = newLeft+'px';
  
}

function countElementsByClass(className, elementTag){
    var count = new Array();
    var elements = document.getElementsByTagName(elementTag);
    for (var i = 0; i < elements.length; i++){
        if (elements[i].className == className){
            count[i] = "";
        }
    }
    return count.length;
}
function closePopup(){
    buttons = countElementsByClass('delen','div');
    for(i=1;i<buttons+1;i++)
    {
            button = document.getElementById("delen_"+i);
	    if(button){
		smatch=button.style.backgroundImage.match(/delen_button_mo.png/gi);
		if(smatch=='delen_button_mo.png')
            	    button.style.backgroundImage = 'url("/shared/img/sharing/delen_button.png")';
	    }
    }
    document.getElementById("sharePopup").style.visibility = 'hidden'
    document.getElementById("closePopup").style.display = 'none'
}

// oorspronkelijke naam: buildFlashObj (nu nog gebruikt bij NCOD, binnenkort gelijktrekken)
function buildFlashEmbedCode(id,playerUrl,flashUrl,agendaId,key)
{
    start=getSecond(agendaId)+'.00';
//    start='48.00';

    objectStr= '<object width="305" height="235" data="'+playerUrl+'flowplayer.commercial-3.1.5.swf?0.45915264269259337" type="application/x-shockwave-flash">';
    objectStr+='<param name="movie" value="'+playerUrl+'flowplayer.commercial-3.1.5.swf?0.45915264269259337" />';
    objectStr+='<param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" />';
    objectStr+='<param name="flashvars" value=\'config={"key":"'+key+'",';
    objectStr+='"contextMenu": [{"Powered by NotuBiz":"function()"},"-"],'; // : function() {location.href = "http://www.notubiz.nl";}}],';
    objectStr+='"clip":{"url":"'+flashUrl+'","provider":"rtmp","start":'+start+'},';
    objectStr+='"plugins":{"rtmp":{"url":"flowplayer.rtmp-3.1.3.swf","netConnectionUrl":"rtmp://flash2.notubiz.nl/nbvod"},"controls":{"url":"'+playerUrl+'flowplayer.controls-3.1.0.swf",';
    objectStr+='"height":20,"fullscreen":false,"tooltipColor":"#456","tooltips":{"buttons":true,"pause":"Pauzeren","play":"Afspelen","fullscreen":"Volledig Scherm",';
    objectStr+='"fullscreenExit":"Terug naar normaal formaat","mute":"Geluid uit","unmute":"Geluid terug aan"},"backgroundGradient":[0,0],"background":"#000000",';
    objectStr+='"timeColor":"#FFFFFF","scrubber":true}},"logo":{"url":"http://www.notubiz.nl/shared/img/flowplayer_NBLOGO.png","top":20,"right":20,"opacity":1,"fullscreenOnly":true,';
    objectStr+='"displaytime":0,"linkUrl":"http://www.notubiz.nl"}}\' />';
    objectStr+='</object>';

    if(document.getElementById(id))
    {
	document.getElementById(id).value=objectStr;
    }
}

function copyEmbed(){
	if(window.clipboardData && clipboardData.setData){
		clipboardData.setData("Text",document.getElementById('embedCode').text);
	}
}

function submitTaf(){
    enaam=document.getElementById('tafENaam');
    eemail=document.getElementById('tafEEmail');
    vnaam=document.getElementById('tafVNaam');
    vemail=document.getElementById('tafVEmail');
    
    errStr='';
    if(enaam.value.length<2)
	errStr+='Vul uw naam in.\n';
    if(eemail.value.length<5)
	errStr+='Vul uw e-mailadres in.\n';
    if(vnaam.value.length<2)
	errStr+='Vul de naam van de ontvanger in.\n';
    if(vemail.value.length<5)
	errStr+='Vul het e-mailadres van de ontvanger in.\n';

    if(errStr.length>0)
    {
	alert(errStr);
    }else{
	msg=document.getElementById('tafBericht').value;
	sendTaf(enaam.value,eemail.value,vnaam.value,vemail.value,msg,shareApId,shareDescription)
	//alert(shareDescription);
	//alert(shareUrl);
    }
    return false;
}

addEvent(window, 'load', getNewWindowLinks);
