function setcookie(n,w,e)
{
	var a = new Date();
	a = new Date(a.getTime() +e);
	document.cookie = n+'='+w+'; expires='+a.toGMTString()+';';
}

function getcookie(n)
{
	a = document.cookie;
	res = '';
	while(a != '')
	{
	    while(a.substr(0,1) == ' '){a = a.substr(1,a.length);}
	    cookiename = a.substring(0,a.indexOf('='));
	    if(a.indexOf(';') != -1)
	    {cookiewert = a.substring(a.indexOf('=')+1,a.indexOf(';'));}
	    else{cookiewert = a.substr(a.indexOf('=')+1,a.length);}
	    if(n == cookiename){res = cookiewert;}
	    i = a.indexOf(';')+1;
	    if(i == 0){i = a.length}
	    a = a.substring(i,a.length);
	}
	return(res);
}

function killcookie(n)
{
	document.cookie = n+'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}

function checksoundcontroler()
{
	if (getcookie('soundoff')==1) document.getElementById('soundcontroler').innerHTML="Sound ON";
	else document.getElementById('soundcontroler').innerHTML="Sound OFF";
}

function soundonoff()
{
	if (getcookie('soundoff')==1)
	{
		soundon();
	}
	else 
	{
		soundoff();
	}
	checksoundcontroler();
}

function soundcontrol()
{
	if (getcookie('soundoff')==1)
	{
		soundoff();
	}
	else 
	{
		soundon();
	}	
}

function soundoff()
{
	setcookie('soundoff', 1);
	soundbox=document.getElementById('sound').innerHTML;
	document.getElementById('sound').innerHTML="";	
}

function soundon()
{
	killcookie('soundoff');
	document.getElementById('sound').innerHTML=soundbox;
}
