function setCookie(name, value, expire, domain, path, secure){
	var thisCookie = escape(name)+"="+escape(value);
	thisCookie += (expire) ? ("; expires=" + expire.toGMTString()) : "";
	thisCookie += (domain) ? ("; domain="+domain) : "";
	thisCookie += (path)   ? ("; path="+path) : "";
	thisCookie += (secure) ? "; Secure" : "";
	document.cookie = thisCookie;
}
function getCookie(name){
	var cookies=document.cookie.split(";");
	for (var n=0;n<cookies.length;n++){
		cookies[n]=cookies[n].replace(/^\s+/g,""); cookies[n]=unescape(cookies[n]);
		if(cookies[n].substring(0,cookies[n].indexOf('='))==name) return cookies[n].substring(cookies[n].indexOf('=')+1,cookies[n].length);
	}
}
function viewSound2(){
var name = getCookie("sound");
	if (name){
		var kakval = "on";
		var namny = getCookie("sound");
		if (namny == kakval){
			if (document.images["speaker"]){document.images["speaker"].src = "images/s_on.gif"}
		}else{
            if (document.images["speaker"]){document.images["speaker"].src = "images/s_off.gif"}
		}
	}else{
        var value = "on";
        var expdate = new Date ();
        expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
        setCookie("sound", value, expdate);
        if (document.images){document.images["speaker"].src = "images/s_on.gif"}
    }
}
function soundSwitch2(){
	var name = getCookie("sound");
	if (name){
        var preVal = "on";
        var expdate = new Date ();
        expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
        if (name == preVal){
            preVal="off";
            if (document.images["speaker"]){
                document.images.speaker.src = "images/s_off.gif";
   			}   
        }else{
            if (document.images["speaker"]){
                document.images.speaker.src = "images/s_on.gif";
            }
        }
        setCookie("sound", preVal, expdate);
    }
}
function playsound(resultid,gameId){
var value = "on";
var name = getCookie(resultid);
var expdate = new Date ();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000));
	if (window.name == "subscribe"){
		selectedGames=get_cookie("gamecookie");
		selectedGameArray=selectedGames.split("_");
		i=0;
		while (i<selectedGameArray.length){
			if(gameId==selectedGameArray[i]){
				if(!name){
					setCookie(resultid, "on", expdate);
					setCookie("sound2", "on", expdate);
				}
			}
			i++
		}
	}else{
		if(!name){
			setCookie(resultid, "on", expdate);
			setCookie("sound2", "on", expdate);
		}
	}
}
function pling() {
var value = "on";
var playSound = getCookie("sound2");
var soundOn = getCookie("sound");
	if (value == soundOn){
		if (value == playSound){
		var html="<embed src=sound/doorb2.wav hidden=true align=baseline border=0 width=0 height=0 autostart=true autoplay=true>";
            var container = document.getElementById("sound");
            container.innerHTML = html;
        setCookie("sound2", "off");
		}
	}
}


