function rollout(that, waarheen, stap)
{
	if (parseInt(that.style.height) < waarheen)
	{
		that.style.height = (parseInt(that.style.height) + stap) + 'px';
		setTimeout(function() {rollout(that, waarheen, stap);},10);
	}
}

function rollback(that, waarheen, stap)
{
	if (parseInt(that.style.height) >= parseInt(waarheen)+stap)
	{
		that.style.height = (parseInt(that.style.height) - stap) + 'px';
		setTimeout(function() {rollback(that, waarheen, stap);},10);
	}
	else
	{
		if (parseInt(that.style.height) > parseInt(waarheen))
		{
			setTimeout(function() {rollback(that, waarheen, (parseInt(that.style.height) - waarheen));},10);
		}
	}
}

function klappic(wat, waarheen)
{
	if (document.getElementById('pic'))
	{
		var picje = document.getElementById('pic');
		
		if (picje.offsetWidth < waarheen && wat == 1)
		{
			
			picje.style.width = picje.offsetWidth + 10 + 'px';
			if (document.getElementById('ipijl'))
			{
				document.getElementById('ipijl').style.right = parseInt(document.getElementById('ipijl').style.right) + 10 + 'px';
				document.getElementById('ipijl').style.top = parseInt(document.getElementById('ipijl').style.top) + parseInt(10*(picje.offsetHeight/picje.offsetWidth)) + 'px';
			}
			setTimeout(function() { klappic(wat,waarheen);}, 5);
		}
		else
		{
			
			if (picje.offsetWidth > waarheen && wat == 0)
			{
				picje.style.width = picje.offsetWidth - 10 + 'px';
				if (document.getElementById('ipijl'))
				{
					document.getElementById('ipijl').style.right = parseInt(document.getElementById('ipijl').style.right) - 10 + 'px';
					document.getElementById('ipijl').style.top = parseInt(document.getElementById('ipijl').style.top) - parseInt(10*(picje.offsetHeight/picje.offsetWidth)) + 'px';
				}				
				setTimeout(function() { klappic(wat,waarheen);}, 5);
			}
			if (wat == 1)
			{
				document.getElementById('pic').className = document.getElementById('pic').offsetHeight + 'px';
				if (waarheen > 200)
				{
					picje.title = "klik om te verkleinen";
					if (document.getElementById('ipijl'))
					{
						document.getElementById('ipijl').getElementsByTagName('img')[0].src = '/images/ipijlb.gif';
						document.getElementById('ipijl').style.top = (picje.offsetHeight + 5) + 'px';
						document.getElementById('ipijl').style.right =  (picje.offsetWidth - 18) + 'px';
					}
				}
				else
				{
					picje.title = "klik om te vergroten";
					if (document.getElementById('ipijl'))
					{
						document.getElementById('ipijl').getElementsByTagName('img')[0].src = '/images/ipijl.gif';
						document.getElementById('ipijl').style.top = (picje.offsetHeight + 5) + 'px';
						document.getElementById('ipijl').style.right =  (picje.offsetWidth - 18) + 'px';
					}
				}
			}
			else
			{
				if (waarheen == 0)
				{
					picje.title = "klik om te verkleinen";
					if (document.getElementById('ipijl'))
					{
						document.getElementById('ipijl').getElementsByTagName('img')[0].src = '/images/ipijlb.gif';
						document.getElementById('ipijl').style.top = (picje.offsetHeight + 5) + 'px';
						document.getElementById('ipijl').style.right =  (picje.offsetWidth - 18) + 'px';
					}
					
				}
				else
				{
					picje.title = "klik om te vergroten";
					if (document.getElementById('ipijl'))
					{
						document.getElementById('ipijl').getElementsByTagName('img')[0].src = '/images/ipijl.gif';
						document.getElementById('ipijl').style.top = (picje.offsetHeight + 5) + 'px';
						document.getElementById('ipijl').style.right =  (picje.offsetWidth - 18) + 'px';
					}
					
				}
			}				
		}
	}
}

var klaps = document.getElementById('kmid').getElementsByTagName('div');
if (klaps.length > 0)
{

	for (i = 0; i < klaps.length; i++)
	{
		if (klaps[i].className.indexOf('txt') != -1)
		{
			
			var newdiv = document.createElement('a');
			newdiv.innerHTML = "meer lezen &raquo;";
			newdiv.setAttribute('href', '#');
			//newdiv.style.textAlign = 'right';
			newdiv.style.display = 'block';
			newdiv.style.color = '#F17BA2';
			newdiv.style.textDecoration = 'none';
			//newdiv.style.width = '200px';
			newdiv.style.position = 'absolute';
			newdiv.style.left = '90px';
			newdiv.style.bottom = '24px';
			newdiv.oldHeight = klaps[i].offsetHeight;
			klaps[i].style.height = klaps[i].offsetHeight + 'px';	
			rollback(klaps[i], 28, 55);
			newdiv.klap = klaps[i];
			newdiv.klaps = klaps;
			newdiv.onclick = function()
			{
				if (this.sstat == 'open')
				{
					this.doklap = true;
					k = 0;
					for (j = 0; j < this.klaps.length; j++)
					{
						if (this.klaps[j].className.indexOf('txt') != -1)
						{
							if (this.klaps[j] != this.klap && this.klaps[j].offsetWidth < 400 && this.klaps[j].offsetHeight > 60)
							{
								this.doklap = false;
								if (parseInt(document.getElementById('pic').className) > k * 90)
								{
									this.doklap = false;
								}
							}
							k++;
						}
					}
					if (this.doklap)
					{
						klappic(1,200);
					}
					rollback(this.klap, 28, 15);
					this.sstat = 'dicht';
					this.innerHTML = "meer lezen &raquo;";
				}
				else
				{
					if (this.klap.offsetWidth < 200)
					{
						klappic(0,0);
					}
					rollout(this.klap, this.oldHeight + 50, 15);
					this.sstat = 'open';
					this.innerHTML = "minder lezen &laquo;";
				}
				return false;
			}
			if (newdiv.oldHeight > 18)
			{
				klaps[i].parentNode.appendChild(newdiv, klaps[i]);
			}
		}
		if (klaps[i].className.indexOf('limit') != -1)
		{
			klaps[i].onclick = function(e)
			{
				
				var targ;
				if (!e) var e = window.event;
				if (e.target) targ = e.target;
				else if (e.srcElement) targ = e.srcElement;
				if (targ.nodeType == 3) // defeat Safari bug
				targ = targ.parentNode;
				if (targ.tagName != 'A' || (targ.className.indexOf('boek') != -1))
				{
					pageTracker._trackEvent('ClickOuts', 'OutAcco', this.getElementsByTagName('h3')[0].innerHTML);
					window.open(this.getElementsByTagName('a')[0].href);
				}
				
				return false;
			}
		}
		
	}
}

if (document.getElementById('pics'))
{
	var psubs = document.getElementById('pics').getElementsByTagName('img');
	
	for (i = 0; i < psubs.length; i++)
	{
		if (psubs[1].className != 'pic')
		{
			psubs[i].onclick = function()
			{

				if (document.getElementById('pic') && document.getElementById('pic').offsetWidth > 200 && this.src.replace('thumbs/', 'pics/') == document.getElementById('pic').src)
				{
					klappic(0, 200);
				}
				else
				{
					if (document.getElementById('pic'))
					{
						klappic(1, 460);
						document.getElementById('pic').src = this.src.replace('thumbs/', 'pics/');
					}

				}
			}
		}
	}
}


function do_atype(what, atypes)
{
	if (!atypes[what])
	{
		var newdiv = document.createElement('B');
		newdiv.innerHTML = 'GEEN ' + what;
		newdiv.style.color = '#000000';
		document.getElementById('atype').appendChild(newdiv);		
		
	}
	else
	{
	
	
	for (var i in atypes)
	{
		if (i == what)
		{
			document.getElementById('sel' + i).style.fontWeight = 'bold';
			document.getElementById('sel' + i).style.color = '#808080';
		}
		else
		{
			if (document.getElementById('atype').innerHTML != "" && document.getElementById('sel' + i))
			{
				document.getElementById('sel' + i).style.fontWeight = 'normal';
				document.getElementById('sel' + i).style.color = '#AAAAAA';
			}
		}
		for (j = 0; j < atypes[i].length - 1; j++)
		{
			var aar = atypes[i];
			if (i == what || what ==  'alles' && parseInt(aar[j]) != 0)
			{
				document.getElementById('acco' + aar[j]).style.display = 'block';
			}
			else
			{
				if (parseInt(aar[j]) != 0)
				{
					document.getElementById('acco' + aar[j]).style.display = 'none';
				}
			}
		}
	}
	
}
}


function do_sort(dear, deid)
{
	var ac = document.getElementById('accos');
	var tmp;	
	for (i = 0; i < dear.length; i++)
	{
		tmp = ac.removeChild(document.getElementById('acco'+dear[i]));
		ac.appendChild(tmp);
	}
	if (document.getElementById('apop'))
	{
		document.getElementById('apop').style.fontWeight = 'normal';
		document.getElementById('aprijs').style.fontWeight = 'normal';
		document.getElementById('aalfa').style.fontWeight = 'normal';
		document.getElementById('astars').style.fontWeight = 'normal';	
		document.getElementById('apop').style.color = '#AAAAAA';
		document.getElementById('aprijs').style.color = '#AAAAAA';
		document.getElementById('aalfa').style.color = '#AAAAAA';
		document.getElementById('astars').style.color = '#AAAAAA';
		document.getElementById(deid).style.color = '#808080';
		document.getElementById(deid).style.fontWeight = 'bold';
	}

}
	

function do_accos()
{
	if(document.getElementById('accos'))
	{
		var accos = document.getElementById('accos').getElementsByTagName('div');
		for (i = 0; i < accos.length; i++)
		{ 
			if (accos[i].className == 'acco')
			{
				if (typeof(atype) != 'undefined')
				{
					atype['alles'].push(accos[i].id.substr(4, accos[i].id.length - 4));
				}
				accos[i].onclick = function()
				{
					document.location.href = this.getElementsByTagName('a')[0].href;
					return false;
				}
				
				accos[i].onmouseover = function()
				{
					this.oldbg = this.style.backgroundImage;
					this.style.background = '#ED2667';
					this.olda = this.getElementsByTagName('a')[0].style.color;
					this.getElementsByTagName('a')[0].style.color = '#FFFFFF';
				}
				
				accos[i].onmouseout = function()
				{
					this.style.backgroundImage = this.oldbg;
					this.style.backgroundRepeat = 'repeat-x';
					this.style.backgroundColor = '#FFFFFF';
					this.getElementsByTagName('a')[0].style.color = this.olda;
				}
			}
		}
		if (typeof(atype) != 'undefined')
		{
			atype['alles'].push(0);
			if (atype['alles'].length > 3)
			{
				if (document.getElementById('atype'))
				{
					document.getElementById('atype').innerHTML = 'Toon: ';
				
					for (var i in atype)
					{
						var newdiv = document.createElement('a');
						newdiv.innerHTML = i + " (" + (atype[i].length - 1) + ")";
						newdiv.href = '#';
						newdiv.style.color = '#AAAAAA';
						newdiv.style.marginRight = '20px';
						newdiv.atype = atype;
						newdiv.id = 'sel' + i;
						newdiv.i = i;
						if (i == 'alles')
						{
							newdiv.style.fontWeight = 'bold';
							newdiv.style.color = '#808080';
						}
						newdiv.onclick = function() 
						{
							do_atype(this.i, this.atype);
							Set_Cookie('atype', this.i,200,'/'); 				
							return false;
						}
						document.getElementById('atype').appendChild(newdiv);
					}
					document.getElementById('asort').innerHTML = 'Sorteer op: ';
					
					var newdiv = document.createElement('a');
					newdiv.innerHTML = "prijs";
					newdiv.href = '#';
					newdiv.id = 'aprijs';
					newdiv.style.color = '#808080';
					newdiv.style.marginRight = '20px';
					newdiv.style.fontWeight = 'bold';
			
					newdiv.onclick = function() 
					{
						do_sort(aprijs, this.id);
						Set_Cookie('asort', this.id,200,'/'); 
						return false;
					}
					document.getElementById('asort').appendChild(newdiv);		
					
					var newdiv = document.createElement('a');
					newdiv.innerHTML = "populariteit";
					newdiv.href = '#';
					newdiv.id = 'apop';
					newdiv.style.color = '#AAAAAA';
					newdiv.style.marginRight = '20px';
					newdiv.onclick = function() 
					{
						do_sort(apop, this.id);
						Set_Cookie('asort', this.id,200,'/'); 
						return false;
					}
					document.getElementById('asort').appendChild(newdiv);		
			
					var newdiv = document.createElement('a');
					newdiv.innerHTML = "alfabet";
					newdiv.href = '#';
					newdiv.id = 'aalfa';
					newdiv.style.color = '#AAAAAA';
					newdiv.style.marginRight = '20px';
					newdiv.onclick = function() 
					{
						do_sort(aalfa, this.id);
						Set_Cookie('asort', this.id,200,'/'); 
						return false;
					}
					document.getElementById('asort').appendChild(newdiv);		
							
					var newdiv = document.createElement('a');
					newdiv.innerHTML = "sterren";
					newdiv.href = '#';
					newdiv.id = 'astars';
					newdiv.style.color = '#AAAAAA';
					newdiv.style.marginRight = '20px';
					newdiv.onclick = function() 
					{
						do_sort(astars, this.id);
						Set_Cookie('asort', this.id,200, '/'); 
						return false;
					}
					document.getElementById('asort').appendChild(newdiv);	
				}	
				
			}	
		}
	}	
}
	

if (document.getElementById('accos'))
{
	do_accos();
}


if (typeof(customIcons) != 'undefined')
{
	for(var i in customIcons) 
	{
		if (document.getElementById('mgroup' + i))
		{
			document.getElementById('mgroup' + i).innerHTML =
			'<img border="0" src="'+ customIcons[i].image+'" /> ' +  
			document.getElementById('mgroup' + i).innerHTML; 
		}
		
		if (document.getElementById('rtd' + i))
		{
			document.getElementById('rtd' + i).style.height = '89px';
			var newdiv = document.createElement('a');
			if (document.getElementById('rtd' + i).getElementsByTagName('a').length > 4)
			{
				newdiv.innerHTML = (document.getElementById('rtd' + i).getElementsByTagName('a').length - 4) + " more " + document.getElementById('rtd' + i).getElementsByTagName('b')[0].innerHTML  + " &raquo;";
				newdiv.setAttribute('href', '#');
				newdiv.style.color = '#808080';
				
				

				newdiv.onclick = function()
				{
					if (this.sstat == 'open')
					{
						rollback(this.previousSibling, 89, 8);
						this.sstat = 'dicht';
						this.innerHTML = (this.previousSibling.getElementsByTagName('a').length - 4) + " more " + this.previousSibling.getElementsByTagName('b')[0].innerHTML + " &raquo;";
					}
					else
					{
						rollout(this.previousSibling, (this.previousSibling.getElementsByTagName('a').length * 20) + 15, 8);
						this.sstat = 'open';
						this.innerHTML = "less " + this.previousSibling.getElementsByTagName('b')[0].innerHTML + " &laquo;";
					}
						
					return false;
				}	
				document.getElementById('rtd' + i).getElementsByTagName('b')[0].style.cursor = 'pointer';
				document.getElementById('rtd' + i).getElementsByTagName('b')[0].klootje = newdiv;
				document.getElementById('rtd' + i).getElementsByTagName('b')[0].onclick = function()
				{
					if (this.klootje.sstat == 'open')
					{
						rollback(this.parentNode, 89, 8);
						this.klootje.sstat = 'dicht';
						this.parentNode.nextSibling.innerHTML = (this.parentNode.getElementsByTagName('a').length - 4) + " more " + this.innerHTML + " &raquo;";
					}
					else
					{
						rollout(this.parentNode, (this.parentNode.getElementsByTagName('a').length * 20) + 15, 8);
						this.klootje.sstat = 'open';
						this.parentNode.nextSibling.innerHTML = "less " + this.innerHTML + " &laquo;";
					}
						
					return false;
				}					
				
				
							
			}
			else
			{
				newdiv.innerHTML = " &nbsp;";
				newdiv.style.color = '#000000';
			}
			newdiv.style.backgroundColor = '#000000';
			newdiv.style.textAlign = 'right';
			newdiv.style.paddingBottom = '2px';
			newdiv.style.paddingTop = '3px';
			newdiv.style.paddingRight = '5px';
			newdiv.style.width = '139px';			
			insertAfter(newdiv, document.getElementById('rtd' + i))						
		}
	}
}

if (typeof(uitrollen) != 'undefined')
{
	if (uitrollen != '' && document.getElementById("rtd"+uitrollen))
	{
		rollout(document.getElementById("rtd"+uitrollen), (document.getElementById("rtd"+uitrollen).getElementsByTagName('a').length * 22) + 15, 16);
		document.getElementById("rtd"+uitrollen).nextSibling.innerHTML = "less " + document.getElementById("rtd"+uitrollen).getElementsByTagName('b')[0].innerHTML + " &laquo;";
		document.getElementById("rtd"+uitrollen).nextSibling.sstat = "open";
		document.getElementById("rtd"+uitrollen).getElementsByTagName('b')[0].style.color = "yellow";
	}
}	

if (document.getElementById("mlimit"))
{
	var maxth = 190;
	var oldth = document.getElementById("mlimit").offsetHeight;
	if (document.getElementById("pic"))
	{
		maxth = document.getElementById("pic").offsetHeight;
	}
	document.getElementById("mlimit").style.height = (oldth + 10) + 'px';
	if (oldth  > maxth + 10)
	{
		var newdiv = document.createElement('a');
		newdiv.innerHTML = "meer lezen &raquo;";
		newdiv.setAttribute('href', '#');
		newdiv.oldth = oldth;
		newdiv.maxth = maxth;
		newdiv.style.width = '200px';
		newdiv.style.float = 'left';
		newdiv.style.color = '#808080';
		newdiv.onclick = function()
		{
			if (this.sstat == 'open')
			{
				rollback(this.previousSibling, this.maxth, 20);
				this.sstat = 'dicht';
				this.innerHTML = "meer lezen &raquo;";
			}
			else
			{
				rollout(this.previousSibling, this.oldth, 20);
				this.sstat = 'open';
				this.innerHTML = "verbergen &laquo;";
			}
			return false;
		}		
		insertAfter(newdiv, document.getElementById('mlimit'))	
		rollback(document.getElementById("mlimit"), maxth, 20);
	}
}

function addlines(lines,appie, soort)
{
	if (lines.length > 1)
	{	
		var parts = lines[0].split(";");
		switch (soort)
		{
			case 'dda':
				appie.innerHTML += "<dd><a href='"+parts[0]+"'>"+parts[1]+"</a> ("+parts[2]+")</dd>";
			break;
			
			case 'ddal':
				appie.innerHTML += "<dd><a href='"+parts[0]+"'>"+parts[1]+"</a> ("+parts[2]+")</dd>";
			break;
		}
		lines.shift();
		setTimeout(function() { addlines(lines,appie,soort);}, 20);
	}
	else
	{
		if (soort == 'ddal')
		{
			do_landen();
		}
	}
	
}

function land2best(that)
{
	if (that.parentNode.previousSibling && that.parentNode.previousSibling.tagName == 'DL')
	{
		that.andere = that.parentNode.previousSibling;
	}
	else
	{
		if (that.parentNode.nextSibling && that.parentNode.nextSibling.tagName == 'DL')
		{
			that.andere = that.parentNode.nextSibling;
		}
	}
	
	if (that.parentNode.firstChild != that)
	{
		that.parentNode.removeChild(that.parentNode.firstChild);
		if (that.andere && that.andere.hasChildNodes())
		{
			that.andere.removeChild(that.andere.firstChild);
		}
	}
	else
	{
		that.parentNode.removeChild(that.parentNode.lastChild);
		if (that.andere && that.andere.hasChildNodes())
		{
			that.andere.removeChild(that.andere.lastChild);
		}
	}
	
	if (that.parentNode.firstChild != that.parentNode.lastChild)
	{
		setTimeout(function() { land2best(that);}, 20);
	}
	else
	{
		setTimeout(function() { 
			if (that.andere)
			{
				that.andere.parentNode.removeChild(that.andere);
			}
			that.parentNode.style.width = '200px';
			that.removeChild(that.lastChild);
			
			that.innerHTML = '<b>' + that.firstChild.innerHTML + '</b> <br /><a onclick="catchland(this);return false" id="alleland" href="#">alle landen &raquo;</a>';
			
			var xmlhttp = getHTTPObject();
			xmlhttp.open("GET", "/engine.php?func=getbests&vars="+escape('id='+that.firstChild.innerHTML),true); // Open verbinding via GET, via deze URL en communiceer asynchroon
			xmlhttp.onreadystatechange = function()  
			{ 
	    		if (xmlhttp.readyState == 4) 
	    		{
		    		var lines = xmlhttp.responseText.split("|");
		    		var newdl = document.createElement('dl');
		    		newdl.style.width = '200px';
		    		that.appendChild(newdl);
		    		setTimeout(function() { addlines(lines, newdl, 'dda');},10);
	    		}
			}
			xmlhttp.send(null) // Verstuur de request
		},5);
	}
	return;
}
	
function do_landen()
{
	if (document.getElementById('landen'))
	{
		var landen = document.getElementById('landen').getElementsByTagName('a');
		for (i = 0; i < landen.length; i++)
		{
			landen[i].onclick = function()
			{
				land2best(this.parentNode);
				return false;
			}
			
		}
	}
}

if (document.getElementById('allebest'))
{
	document.getElementById('allebest').onclick = function()
	{
		var xmlhttp = getHTTPObject();
		xmlhttp.open("GET", "/engine.php?func=getbests&vars="+escape('id='+this.parentNode.parentNode.parentNode.firstChild.innerHTML),true); // Open verbinding via GET, via deze URL en communiceer asynchroon
		
		xmlhttp.onreadystatechange = function()  
		{ 
    		if (xmlhttp.readyState == 4) 
    		{
	    		var lines = xmlhttp.responseText.split("|");
	    		addlines(lines, document.getElementById('allebest').parentNode.parentNode, 'dda');
	    		document.getElementById('allebest').parentNode.parentNode.removeChild(document.getElementById('allebest').parentNode.parentNode.firstChild);
    		}
		}
		xmlhttp.send(null) // Verstuur de request
		return false;
	}
}

function emptyit(that, run)
{
	that.removeChild(that.firstChild);
	if (that.hasChildNodes())
	{
		setTimeout(function() {emptyit(that,run);}, 20);
	}
	else
	{
		if (run != "")
		{
			eval(run);
		}
	}
}


function getlanden()
{
		var xmlhttp = getHTTPObject();
		xmlhttp.open("GET", "/engine.php?func=getlanden",true); // Open verbinding via GET, via deze URL en communiceer asynchroon
		
		xmlhttp.onreadystatechange = function()  
		{ 
    		if (xmlhttp.readyState == 4) 
    		{
	    		var lines = xmlhttp.responseText.split("|");
	    		document.getElementById('landen').getElementsByTagName('dl')[0].removeChild(document.getElementById('landen').getElementsByTagName('dl')[0].firstChild);
	    		addlines(lines, document.getElementById('landen').getElementsByTagName('dl')[0], 'ddal');
    		}
		}
		xmlhttp.send(null) // Verstuur de request	
}

function catchland(that)
{
	if (document.getElementById('bests'))
	{
		document.getElementById('bests').id = 'landen';
	}
	emptyit(that.nextSibling, 'getlanden()');
	that.parentNode.removeChild(that.parentNode.firstChild);
	that.parentNode.removeChild(that.parentNode.firstChild);
	that.parentNode.removeChild(that.parentNode.firstChild);

	return false;
	
}

if (document.getElementById('pic'))
{
	document.getElementById('pic').title = "klik om te vergroten";
	if (document.getElementById('pic').offsetWidth == 0)
	{
		klappic(1,200);
	}
	document.getElementById('pic').onmouseover = function()
	{
		if (!document.getElementById('ipijl'))
		{
			ipijl = document.createElement('a');
			ipijl.id = 'ipijl';
			ipijl.href = '#';
			ipijl.innerHTML = '<img src="/images/ipijl.gif" border="0" />';
			ipijl.style.position = 'absolute';
			ipijl.style.top = (this.offsetHeight + 5) + 'px';
			ipijl.style.right =  (this.offsetWidth - 18) + 'px';
			ipijl.onclick = klikpic;
			if (this.offsetWidth > 200)
			{
				ipijl.getElementsByTagName('img')[0].src = '/images/ipijlb.gif';
			}
				
			document.getElementById('kmid').appendChild(ipijl);
		}
	}
		
	document.getElementById('pic').onclick = klikpic;
	
}
	

function klikpic()
{
	if (document.getElementById('pic').offsetWidth == 200)
	{
		klappic(1, 460);
		if (document.getElementById('mlimit'))
		{
			document.getElementById('mlimit').style.overflow = 'visible';
			this.oldh = document.getElementById('mlimit').offsetHeight;
			document.getElementById('mlimit').style.height = 'auto';
		}
	}
	else
	{
		klappic(0, 200);
		if (document.getElementById('mlimit'))
		{
			document.getElementById('mlimit').style.overflow = 'hidden';
			document.getElementById('mlimit').style.height = this.oldh + 'px';
		}
		
		
	}
	return false;
}
		
	

if (document.getElementById('landen'))
{
	do_landen();
}

if (document.getElementById('accos') && document.getElementById('accos').getElementsByTagName('div').length > 4)
{
	if (Get_Cookie('asort'))
	{
		do_sort(eval(Get_Cookie('asort')), Get_Cookie('asort'));
	}
	if (Get_Cookie('atype'))
	{
		do_atype(Get_Cookie('atype'), atype);
	}
}

var cookiename = 'jrhasbeenseen';
var pageid = document.body.id.substr(4, document.body.id.length - 4);
var barray = Array();

if (Get_Cookie(cookiename))
{
	var cook = Get_Cookie(cookiename);
	barray = cook.split(',');
	var teveel = Array()
	for (i = 0; i < barray.length; i++)
	{
		if (pageid != barray[i])
		{
			teveel.push(barray[i]);
		}
	}
	barray = teveel;		
}

if (barray.length > 24)
{
	barray.reverse();
	barray.length = 24;
	barray.reverse();
}

if (document.body.className == 'body13')
{
	barray.push(pageid);
	Set_Cookie(cookiename, barray, 200, '/');
}

if (barray.length > 0)
{
	var lastseen = document.createElement('div');
	lastseen.innerHTML = '<h6>Laatst bezocht</h6><i></i>';
	lastseen.style.position = 'absolute';
	lastseen.style.top = '148px';
	lastseen.style.left = '720px';
	lastseen.style.width = '300px';
	lastseen.style.height = '77px';
	lastseen.style.overflow = 'hidden';
	lastseen.id = 'lastseen';
	lastseen.className = 'accos';

	lastseen.onmouseover = function()
	{
		if (!document.getElementById('lastpijl') && this.getElementsByTagName('div').length > 2)
		{
			newdiv = document.createElement('a');
			newdiv.href = '#';
			newdiv.innerHTML = '<img src="/images/pijld.gif" border="0" />';
			newdiv.style.position = 'absolute';
			newdiv.style.top = '43px';
			newdiv.style.right = '10px';
			newdiv.id = 'lastpijl';
			
			newdiv.onmouseover = function()
			{
				this.old = this.getElementsByTagName('img')[0].src;
				if (this.sstat != 'open')
				{
					this.getElementsByTagName('img')[0].src = '/images/pijlda.gif';
				}
				else
				{
					this.getElementsByTagName('img')[0].src = '/images/rijlda.gif';
				}
			}
			
			newdiv.onmouseout = function()
			{
				this.getElementsByTagName('img')[0].src = this.old;
			}
			
			newdiv.onclick = function()
			{
				if (this.sstat != 'open')
				{
					rollout(this.parentNode, (this.parentNode.getElementsByTagName('div').length/2 * 72), 20);
					this.sstat = 'open';

					this.getElementsByTagName('img')[0].src = '/images/rijlda.gif';
					this.old = '/images/rijld.gif';
				}
				else
				{
					rollback(this.parentNode, 77, 40);
					this.sstat = 'dicht'
					this.getElementsByTagName('img')[0].src = '/images/pijlda.gif';
					this.old = '/images/pijld.gif';
				}	
				return false;		
			}
			lastseen.appendChild(newdiv);
		}
	}
	
	document.getElementById('container').appendChild(lastseen);
	barray.reverse();
	xmlhttp = getHTTPObject();
	xmlhttp.open("GET", "/engine.php?func=lastseen&vars="+escape('ar='+barray.join(',')),true); // Open verbinding via GET, via deze URL en communiceer asynchroon
	xmlhttp.onreadystatechange = function()  
	{ 
		if (xmlhttp.readyState == 4) 
		{
			lastseen.innerHTML += xmlhttp.responseText;
			if (lastseen.getElementsByTagName('div').length/2 > 1)
			{
				lastseen.getElementsByTagName('i')[0].innerHTML = ' (' + (lastseen.getElementsByTagName('div').length/2) + ')';
			}
			var acs = lastseen.getElementsByTagName('div');
			for (i = 0; i < acs.length; i++)
			{
				if (acs[i].className == 'acco')
				{
					acs[i].onclick = function()
					{
						document.location.href = this.getElementsByTagName('a')[0].href;
						return false;
					}
					
					acs[i].onmouseover = function()
					{
						this.old = this.style.backgroundImage;
						this.style.background = '#303030';
					}
					acs[i].onmouseout = function()
					{
						this.style.backgroundImage = this.old;
						this.style.backgroundRepeat = 'repeat-x';
						this.style.backgroundColor = '#FFFFFF';
					}
				}
			}
		}
	}
	xmlhttp.send(null) // Verstuur de request
}

if (document.getElementById('topaanb'))
{
	var acst = document.getElementById('topaanb').getElementsByTagName('div');
	for (i = 0; i < acst.length; i++)
	{
		if (acst[i].className == 'acco')
		{
			acst[i].onclick = function()
			{
				if (this.getElementsByTagName('a')[0].rel == 'nofollow')
				{
					pageTracker._trackEvent('ClickOuts', 'OutAanb', this.getElementsByTagName('a')[0].innerHTML);
					window.open(this.getElementsByTagName('a')[0].href);
				}
				else
				{
					document.location.href = this.getElementsByTagName('a')[0].href;
				}
				return false;
			}
			
			acst[i].onmouseover = function()
			{window.status = '';
				this.old = this.style.backgroundImage;
				this.style.background = '#303030';return true;
			}
			acst[i].onmouseout = function()
			{
				this.style.backgroundImage = this.old;
				this.style.backgroundRepeat = 'repeat-x';
				this.style.backgroundColor = '#FFFFFF';
			}
		}
	}	
}


function do_login()
{
	
		xxxmlhttp = getHTTPObject();
		xxxmlhttp.open("GET", "/engine.php?func=login&vars="+escape('lnm=' + document.getElementById('s_user').value + '&pwd=' + document.getElementById('s_pwd').value),true); 
		
		xxxmlhttp.onreadystatechange = function()  
		{ 
			if (xxxmlhttp.readyState == 4) 
			{	
				if (xxxmlhttp.responseText != "")
				{
					document.getElementById('login').innerHTML = xxxmlhttp.responseText;
				}
				else
				{
					if (document.getElementById('lastseen'))
					{
						document.location.href = document.getElementById('lastseen').getElementsByTagName('a')[0].href;
					}
					else
					{
						document.location.href = '/';
					}				
				}
			}
		}		
		xxxmlhttp.send(null);
		return false;	
	
	
}


if (document.getElementById('login'))
{
	document.getElementById('login').onsubmit = function()
	{
		do_login();
		return false;
	}
}		

if (document.getElementById('aanmelden'))
{
	document.getElementById('aanmelden').onsubmit = function()
	{
		if (this.document.getElementById('i_naam').value.length < 3)
		{
			alert('Kies een wat langere (nick)naam');
			return false;
		}
		if (this.document.getElementById('i_eml').value.length < 6 || this.document.getElementById('i_eml').value.indexOf('@') == -1)
		{
			alert('Controleer je emailadres');
			return false;
		}
		if (this.document.getElementById('i_pwd').value.length < 6)
		{
			alert('Kies een wat langer wachwoord');
			return false;
		}
		if (this.document.getElementById('i_pwd').value != this.document.getElementById('i_pwd2').value)
		{
			alert('Je moet wel twee keer hetzelfde wachtwoord intypen');
			return false;
		}
		
		axml = getHTTPObject();
		axml.open("GET", "/engine.php?func=aanmelden&vars="+escape('i_naam=' + document.getElementById('i_naam').value + '&i_pwd=' + document.getElementById('i_pwd').value + '&i_eml=' + document.getElementById('i_eml').value),true); 
		
		axml.onreadystatechange = function()  
		{ 
			if (axml.readyState == 4) 
			{	
				if (axml.responseText.indexOf('err:') != -1)
				{
					alert(axml.responseText.replace('err:', ''));
				}
				else
				{
					document.getElementById('aanmelden').innerHTML = axml.responseText;
				}
			}
		}		
		axml.send(null);
		return false;		
	}
	
	if (document.location.hash != '')
	{
		var urid = document.location.hash.substr(1, document.location.hash.length -1);
		axml = getHTTPObject();
		axml.open("GET", "/engine.php?func=bevestig&vars="+escape('uid=' + urid),true); 
		
		axml.onreadystatechange = function()  
		{ 
			if (axml.readyState == 4) 
			{	
				if (axml.responseText.indexOf('err:') != -1)
				{
					alert(axml.responseText.replace('err:', ''));
				}
				else
				{
					var pts = axml.responseText.split('|');
					document.getElementById('kmid').innerHTML = pts[0];
					document.getElementById('s_user').value = pts[1];
					document.getElementById('s_pwd').value = pts[2];
				}
			}
		}		
		axml.send(null);			
	}
}

function do_search(what)
{
		tn_xml2div('kmid','search','search='+what,'');
}

if (document.getElementById('searchform'))
{
	
	document.getElementById('searchform').onsubmit = function()
	{
		do_search(document.getElementById('search').value);
		return false;
	}
	

}

if (Get_Cookie('jr_search'))
{
	var lastsearch = document.createElement('a');
	lastsearch.id = 'lastsearch';
	lastsearch.href = '#';
	lastsearch.title = 'terug naar zoekresultaat ' + unescape(Get_Cookie('jr_search').replace('+', ' ').replace('+', ' ').replace('+', ' ').replace('+', ' '));
	lastsearch.onclick = function()
	{
		do_search(Get_Cookie('jr_search'));
		return false;
	}
	lastsearch.innerHTML = 'zoekresultaat ' + unescape(Get_Cookie('jr_search').replace('+', ' ').replace('+', ' ').replace('+', ' ').replace('+', ' ')) + ' &raquo';
	document.getElementById('tabs').appendChild(lastsearch);
	//alert('laatst gezocht op' + Get_Cookie('jr_search'));
}


if (Get_Cookie('jr_kans'))
{
	var lastsearch = document.createElement('a');
	lastsearch.id = 'lastkans';
	lastsearch.href = '#';
	lastsearch.title = 'kanshebbers van ' + unescape(Get_Cookie('jr_kans').split('x**kans**x')[1].replace('+', ' ').replace('+', ' ').replace('+', ' ').replace('+', ' '));
	lastsearch.onclick = function()
	{
		do_favs(Get_Cookie('jr_kans').split('x**kans**x')[0]);
		return false;
	}
	lastsearch.innerHTML = 'kanshebbers ' + unescape(Get_Cookie('jr_kans').split('x**kans**x')[1].replace('+', ' ').replace('+', ' ').replace('+', ' ').replace('+', ' ')) + ' &raquo';
	document.getElementById('tabs').appendChild(lastsearch);
	//alert('laatst gezocht op' + Get_Cookie('jr_search'));
}

function catch_favreactie()
{
	document.getElementById('favreactie').onsubmit = function()
	{
		var pid = document.getElementById('uid').value;
		
		xmlhttp = getHTTPObject();
		xmlhttp.open("GET", "/engine.php?func=addfavreactie&vars=" + escape('id=' + pid + '&txt=' + this.getElementsByTagName('textarea')[0].value),true); // Open verbinding via GET, via deze URL en communiceer asynchroon
		xmlhttp.onreadystatechange = function()  
		{ 
			if (xmlhttp.readyState == 4) 
			{	
				do_favs(pid);				
			}
		}
		xmlhttp.send(null) // Verstuur de request			
		return false;
	}
}


function do_favs(what)
{
	tn_xml2div('kmid','favs','id='+what, 'do_accos();catch_favreactie()');	
	return false;
}

// counter	
var pagetype = document.body.className.substr(4, document.body.className.length - 4);
var uxmlhttp = getHTTPObject();
uxmlhttp.open("GET", "/engine.php?func=update&vars="+escape('id='+pageid+'&tp='+pagetype),true); 
uxmlhttp.send(null) // Verstuur de request
	
	
if (document.getElementById('s_user') && document.getElementById('s_user').value != '' && document.getElementById('s_pwd').value != '')
{
	do_login();
}
	
	
if (document.location.href.indexOf('?') != -1 && document.location.href.indexOf('=') == -1)
{
	var modus = document.location.href.substr(document.location.href.indexOf('?')+1, document.location.href.length);
	
	tn_xml2div('geil','geil','id='+modus);	
}
	
	
