/*****************************
*	Copyright PotatoDie 2009
*	All rights reserved
******************************/
	
window.onload = function()
{
	maakHeaderLink();
	searchBoxClearer ( );
	
	// Plaats searchphrase terug in zoekveld
	var frase = getSearchValue( 'searchphrase' );
	if ( frase )
	{
		document.getElementById ( 'searchphrase' ).value = frase;
	}
	
	// Voeg print functie toe.
	var pf = document.createElement('a');
	pf.href = '#';
	pf.onclick = afdrukken;
	var t = document.createTextNode ( 'print this page' );
	pf.appendChild ( t );
	
	var illu = document.getElementById ( 'illustratie' );
	illu.parentNode.insertBefore ( pf, illu );
	
	ff_bg_fix();
}

function afdrukken()
{
	window.print();
}

function maakHeaderLink()
{
	var e = document.getElementById ( 'header' );
	e.style.cursor = 'pointer';
	e.onclick = function ()
	{
		location.href = "index.php";
	}
}

function searchBoxClearer ( )
{
	var input_e = document.getElementById ( 'searchphrase' );
	input_e.onfocus = function ()
	{
		if ( this.value == "search" )
		{
			this.value = "";
		} 
	}
	input_e.onblur = function ()
	{
		if ( this.value == "" )
		{
			this.value = "search";
		} 
	}	
}

function getSearchValue ( key )
{
	var a = maakSearchArray ();
	return a[key];
}

function maakSearchArray ( )
{
	var searchArray = new Array();
	
	// search is hier het gedeelte in de url beginnend met '?'
	var s = location.search;
	if ( s.length )
	{
		// Haal begin '?' eraf
		s = s.substring ( 1 );
		var pairs = s.split( "&" );
		for ( i in pairs )
		{
		    var keyval = pairs[ i ].split( "=" );
		    searchArray[ keyval[0] ] = keyval[1];
		}
	}
	return searchArray;
}

/*
BGfix voor FF
*/
function ff_bg_fix ( ) 
{
	if ( !self.innerWidth ) return; // Explorer is ok

	var minWidth = 958; 
		
	if ( self.innerWidth < minWidth )
	{
	// alert (self.innerWidth);
		document.body.style.backgroundPosition = "top left";
	}
	else
	{
		document.body.style.backgroundPosition = "top center";
	}
}
window.onresize = function () 
{
	ff_bg_fix();
}