var agt=navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_opera = (agt.indexOf("opera") != -1);
var is_ff = (agt.indexOf("firefox") != -1);
var is_win = (agt.indexOf("windows") != -1);

function soundnow(){
	newAudio('sound/zip.wav', 'glass', 12, 0); 
	return false;
}

/*** START "JS AUDIO ENGINE" ***/
/*******************************************
CREATED BY JULES GRAVINESE OF WEBVETERAN.COM
Feel free to use the followin audio engine.
But please give credit where it's due.
In other words, leave this disclaimer here.

Usage:
newAudio(filename, trackname[, duration, delay])

Verson 1.3 :: AUGUST 28 2007
Better Windows FF support. Now uses WMV, not QT.

Verson 1.2 :: MARCH 1 2007
Much better performance, less lag.
IE gets bgsound. Others get embed.
A special case for IE? Nah, really?
No Sounds in FF if no QT (ff requires qt).

Verson 1.1 :: FEBRUARY 23 2007
No longer excluding any browser.
Using embed+noembed+object.

Verson 1 :: JANUARY 12 2007
*******************************************/
function newAudio(audioFile, trackName, dur, del) {
	delay = (del*1000); 
	duration = (dur*1000)+delay+300;// Add 300 for the browser to do the work
	
	//if (!is_ff || haveqt) {
	
		// The programmer giveth
			// if I knew how to do variable variable names, I'd no have to use another function...
			// this is important for queueing sound effects and possible overlapping. 
		setTimeout("buildAudio('"+audioFile+"', '"+trackName+"');", delay);
	
		// And the programmer taketh
		setTimeout("document.body.removeChild($('"+trackName+"'));", duration);
	//}
}

function buildAudio(audioFile, trackName) {
	// 'track' would be the variable variable name, making this function unnecessary
	if (is_ie) {
     	// IE GETS BGSOUND
     	track = Builder.node('bgsound',{id:trackName, src:audioFile, loop:1, autostart:'true'});
	} else if (is_ff && is_win) {
		// FF ON WIN GETS WMV
		track = Builder.node('embed', {type:'application/x-mplayer2', pluginspage:'http://microsoft.com/windows/mediaplayer/en/download/',        id:'mediaPlayer', name:'mediaPlayer', displaysize:'4', autosize:'-1', bgcolor:'darkblue', showcontrols:'false', showtracker:'-1', showdisplay:'0', showstatusbar:'-1', videoborder3d:'-1', width:'0', height:'0', src:audioFile, autostart:'true', designtimesp:'5311', loop:'false'});
	} else {
		// ALL OTHERS ARE GENERIC
		track = Builder.node('embed',{id:trackName, src:audioFile, loop:'false', autostart:'true', hidden:'true'});
	}
	document.body.appendChild(track);
}

/*** END AUDIO ENGINE ***/

