function sound()
{       
    if(checkCoderPresent!=1) return;

    snd = document.getElementById("soundbg");

    if (!snd.src)
        sound_on();
    else
        sound_off();
}

function sound_on()
{
    if(checkCoderPresent!=1) return;

    snd = document.getElementById("soundbg");
    a   = document.getElementById("soundlink");
//    snd.src="/i/startup.wav";
snd.src="/i/st.mp3";        
    a.innerHTML = '<img src="/i/sound2.gif" border=0> Выключить музыку';
    WriteCookie("soundbg", 'on');    
}

function sound_off()
{
    if(checkCoderPresent!=1) return;

    snd = document.getElementById("soundbg");
    a   = document.getElementById("soundlink");
    snd.src="";

    a.innerHTML = '<img src="/i/sound2.gif" border=0> Включить музыку';
    WriteCookie("soundbg", 'off');    
}

function WriteCookie(cookiename, cookieval)
{
    if(checkCoderPresent!=1) return;

    var todayDate = new Date(); 
    expiredays='10'; 
    todayDate.setDate(todayDate.getDate() + expiredays);
    document.cookie = cookiename + "=" + escape(cookieval)+"; expires="+todayDate.toGMTString()+"; path=/;";
}

function check_sound()
{
    if(checkCoderPresent!=1) return;

    var aCookie = document.cookie.split("; ");
    str = "soundbg";
    for (var i=0; i < aCookie.length; i++)
    {   
        var aCrumb = aCookie[i].split("=");
        if (aCrumb[0].indexOf(str)==0)
            return aCrumb[1];
    }  
    return false;
}



function soundEn()
{       
    if(checkCoderPresent!=1) return;

    snd = document.getElementById("soundbg");

    if (!snd.src)
        sound_onEn();
    else
        sound_offEn();
}

function sound_onEn()
{
    if(checkCoderPresent!=1) return;

    snd = document.getElementById("soundbg");
    a   = document.getElementById("soundlink");
//    snd.src="/i/startup.wav";
snd.src="/i/st.mp3";        
    a.innerHTML = '<img src="/i/sound2.gif" border=0> Stop music';
    WriteCookie("soundbg", 'on');    
}

function sound_offEn()
{
    if(checkCoderPresent!=1) return;

    snd = document.getElementById("soundbg");
    a   = document.getElementById("soundlink");
    snd.src="";

    a.innerHTML = '<img src="/i/sound2.gif" border=0> Play music';
    WriteCookie("soundbg", 'off');    
}