
var popupWin = null;

function playtrack(release)
{
    return playtrack(release, '');
}
   
function playtrack(release, track)
{
    return playtrack(release, track, '');
}

function playtrack(release, track, disc)
{
    var date = new Date();
    date.setTime(date.getTime()+(60*1000));//expire in one minute
    var expires = "expires="+date.toGMTString();

    document.cookie = 'playercookie=' + release + '-' + track + '-' + disc +";"+ expires + ';path=/';

    try
    {
        var url = "http://www.chemical-records.co.uk/sc/deck";

        popupWin = open("", "popupWin", "width=515, height=705");

        if(!popupWin || popupWin.closed || popupWin.location != "http://www.chemical-records.co.uk/sc/deck")
        {
            popupWin = window.open(url, "popupWin", "width=515, height=705");
        }
    }catch(e){}
    if( popupWin )
    {
        popupWin.focus();
    }

    //      poll(release, track, disc);

    if( window.event)
    {
        window.event.returnValue = false;
    }

    return false;
}

function closePlayer()
{

    popupWin = open("", "popupWin", "");
    
    if( popupWin && !popupWin.closed )
    {
        popupWin.close();
    }
}

function poll(release, track, disc)
{
    if (popupWin && popupWin.document && popupWin.document.MP3Player && popupWin.document.MP3Player.playTrack)
    {
        popupWin.document.MP3Player.playTrack(release, track, disc);
    }
    else
    {
        setTimeout(new Function("poll('"+ release +"', '"+ track +"', '"+ disc +"')"), 500);
    }
}
