var mycookie = document.cookie;  
var timeid = 0;
function GetCookie(name) 
{ 
    var start1 = mycookie.indexOf(name + "="); 
    if (start1== -1) 
        return false;
    else 
    { 
        start=mycookie.indexOf("=",start1)+1;  
        var end = mycookie.indexOf(";",start); 
        if (end==-1) 
        { 
            end=mycookie.length;
        } 
        var value=unescape(mycookie.substring(start,end)); 
        return value;
    } 
}
function SetCookie(name, value)
{
    var expdate = new Date();
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
    document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
        +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
        +((secure == true) ? "; secure" : "");
}
function DelCookie(name)
{
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var cval = GetCookie (name);
    document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
function setPlay(aid, auto_link)
{
    clearTimeout(timeid);
    var class_name = document.getElementById( 'playbutton' ).className;
    if(class_name == 'play')
    {
        autoPlay(auto_link);
        document.getElementById( 'playbutton' ).className="pause";
        SetCookie('autoflag'+aid, '0');
    }
    else
    {
        document.getElementById( 'playbutton' ).className="play";
        SetCookie('autoflag'+aid, '1');
    }
}
function autoPlay(auto_link)
{
    timeid = window.setTimeout("window.location='" +auto_link+ "'", 7000);
}

