 
function CheckWmp10()
{
    try
    {
        var ver = GetWmpVer();
        var idx = -1;
        
        if(ver != null && ver.length > 0)
            idx = ver.indexOf(".");

        if(idx != -1 && ver.substr(0, idx) == "10")
            return true;
    }
    catch(e)
    {
    }
            
    return false;
}
 function Cookie(document, name, hours, path, domain, secure)
{
    this.$document = document;
    this.$name = name;
    
    if( hours ) {
        this.$expiration = new Date((new Date()).getTime() + hours * 3600000);
    } else {
        this.$expiration = new Date(2049, 1, 1, 1, 1, 1, 1);
    }
    
    if( path ) { this.$path = path; } else { this.$path = "/";  }
    if( domain ) { this.$domain = domain; } else { this.$domain = domain; }
    if( secure ) { this.$secure = true; } else { this.$secure = false; }
}
function _Cookie_store()
{
    var cookieval = "";
    for( var prop in this ) {
        if( (prop.charAt(0) == '$') || ((typeof this[prop]) == 'function') )
            continue;
        if( cookieval != "" )
            cookieval += '&';
        cookieval += prop + '=' + escape(this[prop]);
    }
    var cookie = this.$name + '=' + cookieval;
    if( this.$expiration ) cookie += '; expires=' + this.$expiration.toGMTString();
    if( this.$path ) cookie += '; path=' + this.$path;
    if( this.$domain ) cookie += '; domain=' + this.$domain;
    if( this.$secure ) cookie += '; secure';
    this.$document.cookie = cookie;
}
function _Cookie_load()
{
    var allcookies = this.$document.cookie;
    if( allcookies == "" )
        return false;
    var start = allcookies.indexOf(this.$name + '=');
    if( start == -1 )
        return false;
    start += this.$name.length + 1;
    var end = allcookies.indexOf(';', start);
    if( end == -1 )
        end = allcookies.length;
    var cookieval = allcookies.substring(start, end);
    var a = cookieval.split('&');
    var i = a.length;
    while( i-- )
    {
        if(a[i].indexOf(':') != -1)
            a[i] = a[i].replace(':', '=');
            
        a[i] = a[i].split('=');
    }
    i = a.length;
    while( i-- )
        this[a[i][0]] = unescape(a[i][1]);
    return true;
}
function _Cookie_remove()
{
    var cookie;
    cookie = this.$name + '=';
    if( this.$path ) cookie += '; path=' + this.$path;
    if( this.$domain ) cookie += '; domain=' + this.$domain;
    cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
    this.$document.cookie = cookie;
}

new Cookie();
Cookie.prototype.store = _Cookie_store;
Cookie.prototype.load = _Cookie_load;
Cookie.prototype.remove = _Cookie_remove;

function GetCkVal(sName)
{
    var aCookie = document.cookie.split("; ");
    
    for (var i=0; i < aCookie.length; i++)
    {
        var aCrumb = aCookie[i].split("=");
        
        if (sName == aCrumb[0]) 
            return unescape(aCrumb[1]);
    }
    
    return null;
}

    
// Clips in page code
var CurrentPlayImage;
var timeHandle = -1;
var skipFlag = 0;

function StopPlayer()
{
    if(GE('ClipPlayer') != null)
    {
        GE('ClipPlayer').controls.stop();
        GE('ClipPlayer').settings.setMode("loop", wmplp);
        GE('ClipPlayer').settings.setMode("shuffle", wmpsh);
    }
        
    if(CurrentPlayImage != null)
    {
        var item = CurrentPlayImage;

        var tmp = CurrentPlayImage.children[0].alt;
        tmp = tmp.replace("Stop", "Play");

        CurrentPlayImage.children[0].alt = tmp;
        
        CurrentPlayImage = null;
        clpot(item);
    }
}
function StopPlayerNow()
{
    skipFlag = 1;
    
    if(GE('ClipPlayer') != null)
    {
        GE('ClipPlayer').controls.stop();
        GE('ClipPlayer').settings.setMode("loop", wmplp);
        GE('ClipPlayer').settings.setMode("shuffle", wmpsh);
    }
}
function ClipPlayState(NewState)
{
    if(skipFlag == 1)
        return;
        
    if(timeHandle != -1)
    {
        window.clearTimeout(timeHandle);
        timeHandle = -1;
    }
    
    if(NewState == 3 && CurrentPlayImage != null)
    {
        CurrentPlayImage.children[0].isLoading = false;
        CurrentPlayImage.children[0].src = imgPre + "/img_play/bt_stop.gif";

        var tmp = CurrentPlayImage.children[0].alt;
        tmp = tmp.replace("Play", "Stop");

        CurrentPlayImage.children[0].alt = tmp;
    }
    
    if(NewState == 1)
        StopPlayer();
        
    if(NewState == 10 && CurrentPlayImage != null)
    {
        timeHandle = window.setTimeout(StopPlayer, 1000);
    }
}
function CreatePlayer(redir)
{
    if(GE('ClipPlayer') == null)
    {
        try
        {
            var doc = GE("clipSpan");

            var tag = '<object id="ClipPlayer" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="0" height="0">';
            tag += '<param name="autoStart" value="true">';
            tag += '<param name="uimode" value="invisible">';
            tag += '<param name="enableContextMenu" value="false">';
            tag += '</object>';
            tag += '<script for="ClipPlayer" event="PlayStateChange(NewState)" language="javascript">ClipPlayState(NewState);</script>';
            tag += '<script for="ClipPlayer" event="error()" language="javascript">StopPlayer();</script>';
            
            doc.innerHTML = tag;
            doc.style.display = 'none';
            
            var idx = -1;
            var ver = GE('ClipPlayer').versionInfo;

            if(ver != null && ver.length > 0)
            {
                idx = ver.indexOf(".");
            }
            else
            {
                throw "wrong version";
            }

            if(idx != -1 && parseInt(ver.substr(0, idx)) < 7)
            {
                throw "wrong version";
            }
        }
        catch(e)
        {
            if(redir == true)
                location.href = "/help/index.php";
                
            return;
        }
    }
}

var wmplp = false;
var wmpsh = false;

function AutoPlayClip(url)
{
    var ids = url.match(/song\=(\d+)/);
    if (ids != null && ids.length > 0)
    {
        var id = ids[1];
        var item = GE('clp_'+id);
        if (item != null)
        {
            clpup(item, id);
        }
    }
}
function PlayClip(url, id)
{
    if(CurrentPlayImage.children[0]) 
    {
        CurrentPlayImage.children[0].isLoading = true;
        CurrentPlayImage.children[0].src = imgPre + "/img_play/bt_load.gif";
    }
    
    var cp = GE('ClipPlayer');
    if(cp == null)
    {
        CreatePlayer(true);
        cp = GE('ClipPlayer');
    }
    
    if(!CheckWmp10())
        window.onbeforeunload = StopPlayerNow;

    if(cp != null)
    {
        wmplp = cp.settings.getMode("loop");
        wmpsh = cp.settings.getMode("shuffle");
        cp.settings.setMode("loop", false);
        cp.settings.setMode("shuffle", false);
        cp.URL = url;
        //cp.controls.play(); //bug 23931 >set autostart true and give url.never say play.
    }
}
function clpov(item)
{
    if(item == CurrentPlayImage)
    {
        if(CurrentPlayImage.children[0].isLoading != true)
            CurrentPlayImage.children[0].src = imgPre + "/img_play/stop.gif";
    }
    else if(item.children[0]) 
        item.children[0].src = imgPre + "/img_play/play.gif";
}
function clpot(item)
{
    if(item == CurrentPlayImage)
    {
        if(CurrentPlayImage.children[0].isLoading != true)
            CurrentPlayImage.children[0].src = imgPre + "/img_play/bt_stop.gif";
    }
    else if(item.children[0])
        item.children[0].src = imgPre + "/img_play/bt_play.gif";
}
function clpdn(item)
{
    if(event != null && event.button > 1)
        return;

    if(item == CurrentPlayImage)
    {
        if(CurrentPlayImage.children[0].isLoading != true)
            CurrentPlayImage.children[0].src = imgPre + "/img_play/bt_stop_d.gif";
    }
    else if(item.children[0]) 
        item.children[0].src = imgPre + "/img_play/bt_play_d.gif";
}
function clpup(item, id)
{
    if(event != null && event.button > 1)
        return;

    if(item.clipid == null)
    {
        var len = document.all.length;
        var fnd = false;
        
        for(var x = 0; x < len; x++)
        {
            var ele = document.all[x];
            
            if(ele.tagName.toLowerCase() == "a" && ele.clipid == id)
            {
                item = ele;
                fnd = true;
                break;
            }
        }
        
        if(fnd == false)
            return;
    }
    
    if(item == CurrentPlayImage)
    {
        var tmp = CurrentPlayImage.children[0].alt;
        tmp = tmp.replace("Stop", "Play");

        CurrentPlayImage.children[0].alt = tmp;

        GE('ClipPlayer').controls.stop();
        GE('ClipPlayer').settings.setMode("loop", wmplp);
        GE('ClipPlayer').settings.setMode("shuffle", wmpsh);

        CurrentPlayImage = null;
        clpot(item);
        
        return;
    }
    
    if(CurrentPlayImage != null)
    {
        var tmp = CurrentPlayImage;
        var tmps = CurrentPlayImage.children[0].alt;
        tmps = tmps.replace("Stop", "Play");

        GE('ClipPlayer').settings.setMode("loop", wmplp);
        GE('ClipPlayer').settings.setMode("shuffle", wmpsh);

        CurrentPlayImage.children[0].alt = tmps;
        CurrentPlayImage = null;
        clpot(tmp);
    }

    CurrentPlayImage = item;
    clpot(item);
    PlayClip(item.clipurl, id);
}
 