// Sound functions 

// GLOBAL variables - DO NOT EDIT -
	var no_of_children = 0;
	var play_sound = 0;
	var sound_src_name = '';
	var using_embed_tag = 0;
				
// Load a MIDI or MP3 background file (music)
// Takes: soundfile URL
function loadSound(filename) {
		sound_src_name = filename;
		
	if (sound_src_name) {	
							
		if (navigator.appName == "Microsoft Internet Explorer") {
			document.writeln ('<BGSOUND id="background_music" SRC="' + sound_src_name + '">');
			document.writeln ('<a href="javascript:void(0);" onclick="toggleSound(\'background_music\'); return false;" id="background_music_control" class="bmgcontrol">Stop Music</a>');
		} else {
			document.writeln ('<EMBED id="background_music" SRC="' + sound_src_name + '" AUTOSTART="TRUE" WIDTH="144" HEIGHT="18" LOOP="3" enablejavascript="true"><P>');
				using_embed_tag = 1;
		}
								
		play_sound = 1;
		
	} else {
		
		play_sound = 0;
		
	}	
}

// Toggle the background sound ON or OFF
// Takes: ID of BGSOUND/EMBED tag
function toggleSound(id) {
		var sound_id = document.getElementById(id);
		var control_id = document.getElementById(id + '_control');

	// if control_id exists, then change the text of it
	// if not, then the sound is coming from an embed tag

	if (play_sound) {
		// Turn sound OFF
		if (!using_embed_tag) {
				sound_id.src = '';

			if (control_id) {
				control_id.innerHTML = 'Start Music';
			}
		} else {
			sound_id.Stop();	
		}		

			play_sound = 0;
	} else {
		// Turn sound ON
		if (!no_of_children) {
						
			if (!using_embed_tag) {
		 		sound_id.src = sound_src_name;

				if (control_id) {
					control_id.innerHTML = 'Stop Music';
				}
			} else {
				sound_id.Play();
			}	

				play_sound = 1;
		}
	}
}

function musicOff(id) {
	if (play_sound) {
		toggleSound(id);
	}
}