function toggle_sound() {	
	var was_muted = get_cookie("mute") == "true";	
	var newMute =  was_muted ? "false" : "true";
	set_cookie("mute", newMute.toString());
	var f = get_sounds_flash();	
	if(f)
		f.SetVariable("mute", newMute);
	var link = document.getElementById("sound_control");
	if(link) {
		link.innerHTML = was_muted ? sr_turn_off : sr_turn_on;
	}
}
function play_sound(name) {
	var f = get_sounds_flash();
	if(f)
		f.SetVariable("s", name);
}
function get_sounds_flash() {
	return window.document.sounds_flash;
}

var ssCache = null;
function toggle_menu(id) {
	var ss = get_ss_elements();
	for(var index in ss)
		ss[index].style.display = ss[index].id == id ? "block" : "none";
}
function get_ss_elements() {
	if(ssCache == null) {
		ssCache = [];
		var divs = document.getElementsByTagName("div");
		for(var index = 0; index < divs.length; ++index) {
			if(divs[index].className == "ss")
				ssCache[ssCache.length] = divs[index];
		}
	}		
	return ssCache;
}

function get_cookie(name, defaultValue) {
	var cookies = document.cookie.split(/\;\s*/);		
	var pair;
	for(var i in cookies) {		
		pair = cookies[i].split("=");		
		if(pair[0] == name)		
			return unescape(pair[1]);
	}
	return defaultValue;
}
function set_cookie(name, value) {
	var expire = new Date(2099, 1, 1);
	document.cookie = name + "=" + escape(value) + "; expires=" + expire.toGMTString() + "; path=/";
}
