if(typeof(innerWidth) == 'undefined')
{
	innerWidth = document.body.clientWidth;
	innerHeight = document.body.clientHeight;
	displaytype = 'block';
}
else
{
	displaytype = 'table-cell';
}

function bold()
{
	var bold = prompt('Voeg de text in', '');
	if(bold)
	{
		bold2 = "[b]"+bold+"[/b]";
		insert_tekst(bold2);
	}
}
function italic()
{
	var italic = prompt('Voeg de text in', '');
	if(italic)
	{
		italic2 = "[i]"+italic+"[/i]";
		insert_tekst(italic2);
	}
}
function underline()
{
	var underline = prompt('Voeg de text in', '');
	if(underline)
	{
		underline2 = "[u]"+underline+"[/u]";
		insert_tekst(underline2);
	}
}
function quote()
{
	var quote = prompt('Voeg de quote in', '');
	if(quote)
	{
		var quotepersoon = prompt('Voeg gequote persoon in of laat leeg', '')
		if(quotepersoon)
		{
quote2 = "[quote=\""+quotepersoon+"\"]"+quote+"[/quote]";
insert_tekst(quote2);
		}
		else
		{
quote2 = "[quote]"+quote+"[/quote]";
insert_tekst(quote2);
		}
	}
}
function code()
{
	codeif1 = "0";
	if(codeif1 != "1")
	{
		codeif = "0";
	}
	if(codeif == "1")
	{
		sjaak = "koekje1";
		insert_tekst(sjaak);
		insert_tekst(codeif);
		codeif = "0";
	}
	else
	{
		sjaak = "koekje2";
		insert_tekst(sjaak);
		insert_tekst(codeif);
		codeif = "1";
	}
}
function img()
{
	var img = prompt('Voeg de url in', '');
	if(img)
	{
		img2 = "[img]"+img+"[/img]";
		insert_tekst(img2);
	}
}
function url()
{
	var url = prompt('Voeg de url in, beginnend met http://', '');
	if(url)
	{
		var urlnaam = prompt('Voeg websitenaam in of laat leeg', '')
		if(urlnaam)
		{
url2 = "[url=\""+url+"\"]"+urlnaam+"[/url]";
insert_tekst(url2);
		}
		else
		{
url2 = "[url=\""+url+"\"]"+url+"[/url]";
insert_tekst(url2);
		}
	}
}
function insert_tekst(code)
{
	bericht = document.post.topictext.value;
	document.post.topictext.value = bericht + code;
}
function smilie(code)
{
	code = " "+code+" ";
	bericht = document.post.topictext.value;
	document.post.topictext.value = bericht + code;
}
function displayOn(nr)
{
	if (document.all)
	{
		document.all[nr].style.display = displaytype;
	}
	else if (document.getElementById)
	{
		document.getElementById(nr).style.display = displaytype;
	}
}
function displayOff(nr)
{
	if (document.all)
	{
		document.all[nr].style.display = 'none';
	}
	else if (document.getElementById)
	{
		document.getElementById(nr).style.display = 'none';
	}
}
function nieuws()
{
	displayOn('normaal1');
	displayOn('nieuws1');
	displayOn('nieuws2');
	displayOn('nieuws3');
	displayOn('nieuws4');
	displayOn('nieuws5');
	displayOn('nieuws6');
	displayOn('nieuws7');
	displayOn('algemeen');
	displayOff('interview1');
	displayOff('interview2');
	displayOff('album1');
	displayOff('album2');
	displayOff('album3');
	displayOff('album4');
	displayOff('album5');
}
function interview()
{
	displayOn('algemeen');
	displayOn('normaal1');
	displayOn('interview1');
	displayOn('interview2');
	displayOff('album2');
	displayOff('nieuws1');
	displayOff('nieuws2');
	displayOff('nieuws3');
	displayOff('nieuws4');
	displayOff('nieuws5');
	displayOff('nieuws6');
	displayOff('nieuws7');
	displayOff('album1');
	displayOff('album2');
	displayOff('album3');
	displayOff('album4');
	displayOff('album5');
}
function normaal()
{
	displayOn('normaal1');
	displayOn('algemeen');
	displayOff('interview1');
	displayOff('interview2');
	displayOff('nieuws1');
	displayOff('nieuws2');
	displayOff('nieuws3');
	displayOff('nieuws4');
	displayOff('nieuws5');
	displayOff('nieuws6');
	displayOff('nieuws7');
	displayOff('album1');
	displayOff('album2');
	displayOff('album3');
	displayOff('album4');
	displayOff('album5');
}
function f_album()
{
	document.getElementById("album1").style.display = displaytype;
	document.getElementById("album2").style.display = displaytype;
	document.getElementById("album3").style.display = displaytype;
	document.getElementById("album4").style.display = displaytype;
	document.getElementById("album5").style.display = displaytype;
	document.getElementById("algemeen").style.display = 'none';
	document.getElementById("interview1").style.display = 'none';
	document.getElementById("interview2").style.display = 'none';
	document.getElementById("normaal1").style.display = 'none';
	document.getElementById("nieuws1").style.display = 'none';
	document.getElementById("nieuws2").style.display = 'none';
	document.getElementById("nieuws3").style.display = 'none';
	document.getElementById("nieuws4").style.display = 'none';
	document.getElementById("nieuws5").style.display = 'none';
	document.getElementById("nieuws6").style.display = 'none';
	document.getElementById("nieuws7").style.display = 'none';
}

function youtube(id)
{
	htmlstring = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/'+id+'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+id+'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
	document.getElementById("popup").innerHTML = htmlstring;
}
function stats()
{
	htmlstring = '<table width="100%" cellspacing="0" cellpadding="3"><tr><td class="td1" align="center" colspan="3"><b>&nbsp;&nbsp;&nbsp;&nbsp;STATS</b></td><td class="td1" onclick="javascript:sluit()"><b>X</b></td></tr><tr><td class="td5" valign="top" align="left">Aantal albums</td><td class="td5" valign="top" align="left"><b>269</b></td><td class="td5" valign="top" align="left">Aantal verzamelalbums</td><td class="td7" valign="top" align="left"><b>70</b></td></tr><tr><td class="td5" valign="top" align="left">Aantal tracks op albums</td><td class="td5" valign="top" align="left"><b>3843</b></td><td class="td5" valign="top" align="left">Aantal tracks op verzamelalbums</td><td class="td7" valign="top" align="left"><b>1249</b></td></tr><tr><td class="td5" valign="top" align="left">Gemiddeld aantal tracks per album</td><td class="td5" valign="top" align="left"><b>14.29</b></td><td class="td5" valign="top" align="left">Gemiddeld aantal tracks per verzamelalbum</td><td class="td7" valign="top" align="left"><b>17.84</b></td></tr><tr><td class="td5" valign="top" align="left">Aantal skits op albums</td><td class="td5" valign="top" align="left"><b>42</b></td><td class="td5" valign="top" align="left">Aantal skits op verzamelalbums</td><td class="td7" valign="top" align="left"><b>7</b></td></tr><tr><td class="td6" valign="top" align="left">Gemiddeld aantal skits per album</td><td class="td6" valign="top" align="left"><b>0.16</b></td><td class="td6" valign="top" align="left">Gemiddeld aantal skits per verzamelalbum</td><td class="td3b" valign="top" align="left"><b>0.03</b></td></tr><tr><td class="td3" valign="top" align="left" colspan="4">&nbsp;</td></tr><tr><td class="td5" valign="top" align="left">Aantal artiesten</td><td class="td5" valign="top" align="left"><b>180</b></td><td class="td5" valign="top" align="left">Gemiddeld aantal albums per artiest</td><td class="td7" valign="top" align="left"><b>1.49</b></td></tr><tr><td class="td6" valign="top" align="left">Gemiddeld aantal tracks per artiest</td><td class="td6" valign="top" align="left"><b>21.35</b></td><td class="td6" valign="top" align="left">Gemiddeld aantal skits per artiest</td><td class="td3b" valign="top" align="left"><b>0.23</b></td></tr></table>';
	document.getElementById("popup").innerHTML = htmlstring;
	document.getElementById("popup").style.visibility = 'visible';
}
function browserwidth()
{
	document.getElementById("width").style.visibility = 'visible';
}
function sluit()
{	
	document.getElementById("popup").innerHTML = '';
	document.getElementById("popup").style.visibility = 'hidden';
}
function verander(id)
{
	if(id == 1)
	{
		document.getElementById('td1').style.display = displaytype;
		document.getElementById('td2').style.display = 'none';
	}
	else
	{
		document.getElementById('td1').style.display = displaytype;
		document.getElementById('td2').style.display = 'table-cell';
	}
}
function albumaan(id)
{
	album1 = id+"-1";
	album2 = id+"-2";
	album3 = id+"-3";
	document.getElementById(album1).style.backgroundColor = '#CEAA56';
	document.getElementById(album2).style.backgroundColor = '#CEAA56';
	document.getElementById(album3).style.backgroundColor = '#CEAA56';
}
function albumuit(id)
{
	album1 = id+"-1";
	album2 = id+"-2";
	album3 = id+"-3";
	document.getElementById(album1).style.backgroundColor = '#DFC48B';
	document.getElementById(album2).style.backgroundColor = '#DFC48B';
	document.getElementById(album3).style.backgroundColor = '#DFC48B';
}
function aan(id, nummer)
{
	for(i=1;i<=nummer;i++)
	{
		var nummeri = id+'-'+i;
		document.getElementById(nummeri).style.backgroundColor = '#CEAA56';
	}
}
function uit(id, nummer)
{
	for(i=1;i<=nummer;i++)
	{
		var nummeri = id+'-'+i;
		document.getElementById(nummeri).style.backgroundColor = '#DFC48B';
	}
}
function uit2(id, nummer)
{
	for(i=1;i<=nummer;i++)
	{
		var nummeri = id+'-'+i;
		document.getElementById(nummeri).style.backgroundColor = '#DFC17C';
	}
}
function inuitklap(id)
{
	if(document.getElementById(id).style.display != 'none')
	{
		document.getElementById(id).style.display = 'none';
		document.getElementById(id).colSpan = '2';
	}
	else
	{
		document.getElementById(id).style.display = displaytype;
		document.getElementById(id).colSpan = '2';
	}
}
function leegzoekveld()
{
	var zvtext = document.getElementById('zoekveld').value;

	if(zvtext == 'Zoek in archief')
	{
		document.getElementById('zoekveld').value = '';
	}
}

function AutoSuggest(elem, suggestions)
{
	//The 'me' variable allow you to access the AutoSuggest object
	//from the elem's event handlers defined below.
	var me = this;

	//A reference to the element we're binding the list to.
	this.elem = elem;

	this.suggestions = suggestions;

	//Arrow to store a subset of eligible suggestions that match the user's input
	this.eligible = new Array();

	//The text input by the user.
	this.inputText = null;

	//A pointer to the index of the highlighted eligible item. -1 means nothing highlighted.
	this.highlighted = -1;

	//A div to use to create the dropdown.
	this.div = document.getElementById("autosuggest");


	//Do you want to remember what keycode means what? Me neither.
	var TAB = 9;
	var ENTER = 13;
	var ESC = 27;
	var KEYUP = 38;
	var KEYDN = 40;
	

	//The browsers' own autocomplete feature can be problematic, since it will 
	//be making suggestions from the users' past input.
	//Setting this attribute should turn it off.
	elem.setAttribute("autocomplete","off");

	//We need to be able to reference the elem by id. If it doesn't have an id, set one.
	if(!elem.id)
	{
		var id = "autosuggest" + idCounter;
		idCounter++;

		elem.id = id;
	}


	/********************************************************
	onkeydown event handler for the input elem.
	Tab key = use the highlighted suggestion, if there is one.
	Esc key = get rid of the autosuggest dropdown
	Up/down arrows = Move the highlight up and down in the suggestions.
	********************************************************/
	elem.onkeydown = function(ev)
	{
		var key = me.getKeyCode(ev);

		switch(key)
		{
			case TAB:
			me.useSuggestion();
			break;

			case ENTER:
			me.useSuggestion();
			break;

			case ESC:
			me.hideDiv();
			break;

			case KEYUP:
			if (me.highlighted > 0)
			{
				me.highlighted--;
			}
			me.changeHighlight(key);
			break;

			case KEYDN:
			if (me.highlighted < (me.eligible.length - 1))
			{
				me.highlighted++;
			}
			me.changeHighlight(key);
			break;
		}
	};

	/********************************************************
	onkeyup handler for the elem
	If the text is of sufficient length, and has been changed, 
	then display a list of eligible suggestions.
	********************************************************/
	elem.onkeyup = function(ev) 
	{
		var key = me.getKeyCode(ev);
		switch(key)
		{
		//The control keys were already handled by onkeydown, so do nothing.
		case ENTER:
		case TAB:
		case ESC:
		case KEYUP:
		case KEYDN:
			return;
		default:

			if (this.value != me.inputText && this.value.length > 0)
			{
				me.inputText = this.value;
				me.getEligible();
				me.createDiv();
				me.positionDiv();
				me.showDiv();
			}
			else
			{
				me.hideDiv();
			}
		}
	};


	/********************************************************
	Insert the highlighted suggestion into the input box, and 
	remove the suggestion dropdown.
	********************************************************/
	this.useSuggestion = function()
	{
		if (this.highlighted > -1)
		{
			this.elem.value = this.eligible[this.highlighted];
			this.hideDiv();
			//It's impossible to cancel the Tab key's default behavior. 
			//So this undoes it by moving the focus back to our field right after
			//the event completes.
			setTimeout("document.getElementById('" + this.elem.id + "').focus()",0);
		}
	};

	/********************************************************
	Display the dropdown. Pretty straightforward.
	********************************************************/
	this.showDiv = function()
	{
		this.div.style.display = 'block';
	};

	/********************************************************
	Hide the dropdown and clear any highlight.
	********************************************************/
	this.hideDiv = function()
	{
		this.div.style.display = 'none';
		this.highlighted = -1;
	};

	/********************************************************
	Modify the HTML in the dropdown to move the highlight.
	********************************************************/
	this.changeHighlight = function()
	{
		var lis = this.div.getElementsByTagName('LI');
		for (i in lis)
		{
			var li = lis[i];

			if (this.highlighted == i)
			{
				li.className = "selected";
			}
			else
			{
				li.className = "";
			}
		}
	};

	/********************************************************
	Position the dropdown div below the input text field.
	********************************************************/
	this.positionDiv = function()
	{
		var el = this.elem;
		var x = 0;
		var y = el.offsetHeight;
	
		//Walk up the DOM and add up all of the offset positions.
		while (el.offsetParent && el.tagName.toUpperCase() != 'BODY')
		{
			x += el.offsetLeft;
			y += el.offsetTop;
			el = el.offsetParent;
		}

		x += el.offsetLeft;
		y += el.offsetTop;

		this.div.style.left = x + 'px';
		this.div.style.top = y + 'px';
	};

	/********************************************************
	Build the HTML for the dropdown div
	********************************************************/
	this.createDiv = function()
	{
		var ul = document.createElement('ul');
	
		//Create an array of LI's for the words.
		for (i in this.eligible)
		{
			var word = this.eligible[i];
	
			var li = document.createElement('li');
			var a = document.createElement('a');
			a.href="javascript:false";
			a.innerHTML = word;
			li.appendChild(a);
	
			if (me.highlighted == i)
			{
				li.className = "selected";
			}
	
			ul.appendChild(li);
		}
	
		this.div.replaceChild(ul,this.div.childNodes[0]);
	

		/********************************************************
		mouseover handler for the dropdown ul
		move the highlighted suggestion with the mouse
		********************************************************/
		ul.onmouseover = function(ev)
		{
			//Walk up from target until you find the LI.
			var target = me.getEventSource(ev);
			while (target.parentNode && target.tagName.toUpperCase() != 'LI')
			{
				target = target.parentNode;
			}
		
			var lis = me.div.getElementsByTagName('LI');
			
	
			for (i in lis)
			{
				var li = lis[i];
				if(li == target)
				{
					me.highlighted = i;
					break;
				}
			}
			me.changeHighlight();
		};

		/********************************************************
		click handler for the dropdown ul
		insert the clicked suggestion into the input
		********************************************************/
		ul.onclick = function(ev)
		{
			me.useSuggestion();
			me.hideDiv();
			me.cancelEvent(ev);
			return false;
		};
	
		this.div.className="suggestion_list";
		this.div.style.position = 'absolute';

	};

	/********************************************************
	determine which of the suggestions matches the input
	********************************************************/
	this.getEligible = function()
	{
		this.eligible = new Array();
		for (i in this.suggestions) 
		{
			var suggestion = this.suggestions[i];
			
			if(suggestion.toLowerCase().indexOf(this.inputText.toLowerCase()) == "0")
			{
				this.eligible[this.eligible.length]=suggestion;
			}
		}
	};

	/********************************************************
	Helper function to determine the keycode pressed in a 
	browser-independent manner.
	********************************************************/
	this.getKeyCode = function(ev)
	{
		if(ev)			//Moz
		{
			return ev.keyCode;
		}
		if(window.event)	//IE
		{
			return window.event.keyCode;
		}
	};

	/********************************************************
	Helper function to determine the event source element in a 
	browser-independent manner.
	********************************************************/
	this.getEventSource = function(ev)
	{
		if(ev)			//Moz
		{
			return ev.target;
		}
	
		if(window.event)	//IE
		{
			return window.event.srcElement;
		}
	};

	/********************************************************
	Helper function to cancel an event in a 
	browser-independent manner.
	(Returning false helps too).
	********************************************************/
	this.cancelEvent = function(ev)
	{
		if(ev)			//Moz
		{
			ev.preventDefault();
			ev.stopPropagation();
		}
		if(window.event)	//IE
		{
			window.event.returnValue = false;
		}
	}
}

//counter to help create unique ID's
var idCounter = 0;