// JavaScript Document

// 	cristian.visan update 
//	by default the browser is ready to play different audio formats but we have to be sure that this is possible 
//	otherwise we have to check before using it. in this case we do the test for wav files plugin
//
//	navigator.mimeTypes['audio/x-wav'].type, 
//	navigator.mimeTypes['audio/x-wav'].description, 
//	navigator.mimeTypes['audio/x-wav'].suffixes, 
//	navigator.mimeTypes['audio/x-wav'].enabledPlugin.name);

// document.writeln(navigator.mimeTypes['audio/x-wav'].enabledPlugin.name);


var sounds = 'on';

if(navigator.mimeTypes['audio/x-wav'].enabledPlugin.name != '')
{
	sounds = 'on';
	window.document.title = ' OnSiteTag ';	
}
else
{
	sounds = 'off';
	window.document.title = ' onsite tag ';
}

//document.writeln(sounds);


function play_sound(soundobj) {
	if(sounds == 'on'){
		var thissound= eval("document."+soundobj);
		var thissound = document.getElementById(soundobj);
		 try {
			 thissound.Play();
		 }
		 catch (e) {
			 //alert(e);
			 
			 try{
			 	thissound.DoPlay();
			 
			 } 
			 catch (e) {
				 try{
					 thissound.playlist.play();
				 }
				 catch(e){
						//alert('You do not have a compatible browser plugin to play wav files.\nThe alert functionality has been disabled.\nIf you want to use the alerts, please install the latest quicktime plugin.'); 
					//sounds = 'off';
					disable_sound();
				 }
				//thissound.play();
				
			 }
		 }
	}
}


function volume(){
	var s = document.getElementById('vol').src;
	if(s == "http://www.onsitetag.com/images/mute.jpg"){
		sounds = 'on';
		document.getElementById('vol').src = 'http://www.onsitetag.com/images/sound.jpg';
		document.getElementById('vol').title = "Alerts Active! Click to Mute the Alerts";
		
		
	} 
	else{
		sounds = 'off';
		document.getElementById('vol').src = 'http://www.onsitetag.com/images/mute.jpg';
		document.getElementById('vol').title = 'Alerts Muted! Click to Turn On Alerts';		
	}
}

function disable_sound(){
	sounds = 'off';
	document.getElementById('vol').src = 'http://www.onsitetag.com/images/mute.jpg';
	document.getElementById('vol').title = 'Alerts Muted! Please Install the latest Quicktime plugin in order to use this feature.';
	document.getElementById('vol').onClick = '';
	document.getElementById('vol').style.cursor = 'default';
}
