var ayAudio = new Array();
// Source for sound files to be preloaded
ayAudio[0] = "res/vacuum-sound.wav";
ayAudio[1] = "res/hover-menu.wav";

function AudioCheck() {
	var n = navigator.appName
	if (n=="Netscape") this.ns = true;
	else if (n=="Microsoft Internet Explorer" && document.all) this.ie = true;
	else this.noAudio = true;
}
onload = function()
{
	is = new AudioCheck();
	if (is.noAudio)
		return;

	var s = '';
	for (i=0; i<ayAudio.length; i++)
		s += "<EMBED SRC='"+ayAudio[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>";

	if (is.ns)
	{
		auEmb = new Layer(0);
		with (auEmb.document)
		{ 
			open();
			write(s);
			close()
		};
	}
	else 
		document.body.insertAdjacentHTML("BeforeEnd", s);

	auCon = is.ns? auEmb.document.embeds:auIEEmb;
	auCon.ctrl = function(au, play, loops)
	{
		auCon.loop = loops;

		if (is.ie)
			this.src = play? ayAudio[au]:'';
		else
			eval( "this[au]." + (play? "play()":"stop()") );
	}
	
	is.auDone = true;
}

function playAudio(whAu, loops) { if (window.auCon) auCon.ctrl(whAu, 1, loops) }
function stopAudio(whAu, loops) { if (window.auCon) auCon.ctrl(whAu, 0, loops) }

