/*****************************
*	Copyright Potato Die 2009
*	All rights reserved
******************************/

window.onload = function ()
{
	registerEvents();
	activeerMenu ( huidige_pagina );
	xmlhttp_start ();
	plaatsFlash();
	koppelAudio();
}

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

function activeerMenu ( m )
{
	var onze_li = document.getElementById( m );	
	if ( onze_li ) onze_li.className = "actief";	
} 
function deactiveerMenu ( m )
{
	var onze_li = document.getElementById( m );	
	if ( onze_li ) onze_li.className = "";	
} 

function plaatsFlash ()
{
	var params = 
	{
		"src" : "components/mp3player.swf",
		"quality" : "high",
		"bgcolor" : "#f0e9da",
		"width" : 200,
		"height" : 42,
		"id" : "mp3player",
		"name" : "mp3player",
		"align" : "middle", 
		"allowScriptAccess" : "always", 
		"type" : "application/x-shockwave-flash",
		"pluginspage" :"http://www.macromedia.com/go/getflashplayer"		
	}

	var embedElem = '<embed ';
	for ( p in params )
	{
		embedElem += p + '="' + params[p] + '" ';
	}
	
	embedElem += '></embed>';

	// Voeg het element toe als laatste aan 'menu'
	var playerContainer = document.createElement( 'div');
	playerContainer.innerHTML = embedElem;
		
	/* 
	visibility werkt niet in IE: dan speelt ie niet af bij 'hidden'
	*/
	var onze_div = document.getElementById( 'menu' );
	onze_div.appendChild ( playerContainer );	
}

function koppelAudio()
{
	// Doorloop alle <a>
	var links = document.getElementById( 'content' ).getElementsByTagName ( 'a' );
	for ( var i = 0; i < links.length; i++ )
	{
		// Check extensie mp3
		var len = links[i].href.length;  
		if ( links[i].href.substring ( len - 4, len )  == ".mp3" )
		{
			links[i].onclick = playNow;
		}
	}	
}

function playNow()
{
	playUrl ( this.href );
	return false;
}