//
// Play Mouseover Sound.js
//
// Versie 0.1, 2009
//
// Copyright: Roger Jolly, 2009
// This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License
// http://creativecommons.org/licenses/by-nc/3.0/
//
// Dit script 
//


var menuSoundPath;


(function() {
	// Deze anonymous functie zorgt dat links met de class "external" in een ander window geopend worden.
	var menuId = "hoofdmenu";
	var soundDivId = "sounddiv";

	function init() {
		if (menuSoundPath == null ) return;
		var menuBase = document.getElementById(menuId);
		var links = menuBase.getElementsByTagName("a");
		for (var i=0; i<links.length; i++) {
			if (window.addEventListener) {
				links[i].addEventListener("mouseover", playMenuSound, false);
			} else if (window.attachEvent) {
				links[i].attachEvent("onmouseover", playMenuSound);
			}
		}
	};
	
	function playMenuSound() {
		var anElement = document.createElement("embed");
		anElement.src = menuSoundPath;
		anElement.hidden = "true";
		anElement.autostart = "true";
		anElement.loop = "false";
		anElement.style.visibility = "hidden";
		anElement.style.height = 0;
		anElement.style.width = 0;
		
//		document.getElementById(soundDivId).appendChild(anElement);
		document.getElementById("sounddiv").appendChild(anElement);
		anElement = null;
		
		setTimeout('document.getElementById("sounddiv").removeChild( document.getElementById("sounddiv").firstChild)', 500);

	}

	// Zorg dat init wordt aangeroepen als de pagina is geladen.
	if (window.addEventListener) {
		window.addEventListener("load", init, false);
	} else if (window.attachEvent) {
		window.attachEvent("onload", init);
	} else {
		window.onload = init;
	}
})(); // Roep de functie aan nu hij gedefinieerd is.

