// link_group_id added by szarecor 20050705
function openAvPlayer(type, asset_id, product_id, link_group_id, format, speed) {
    //alert(type);
    /*
    //FORMAT-SPECIFIC LINKS NO LONGER USED
    if ((type == "video" || type == "audio") && (format != "" && speed != "")) {

        var formatAndSpeed = format + "-" + speed;

         switch (formatAndSpeed) {
            case "wm-high":
                var format_id = 1;
                break;
            case "wm-low":
                var format_id = 2;
                break;
            case "rm-low":
                var format_id = 3;
                break;
            case "rm-high":
                var format_id = 4;
                break;
            case "wm-medium":
                var format_id = 10;
                break;
            case "rm-medium":
                var format_id = 11;
                break;
         }

        setAVPCookie("AVFBID", format_id, "scramble.defjam.com");
    }
    */

    if (type == "lyrics") {
        //var url = "assets/popups/player/playlyrics.php";

        var url = "assets/popups/player/playlyrics.php?pid=" + product_id + "&aid=" + asset_id;
        //+ "&av_type_id=2&cms_site_id=1";

        var features = "width=522, height=550, scrollbars=yes, menu=yes, resizable=no";
    } else if (type == "video") {
        //var url = "assets/popups/player/playvideo.php";
        var url = "http://music.defjam.com/www2/av_player/AVPlayer.php?av_asset_id="
            +asset_id+(link_group_id ? "&av_link_group_id="+link_group_id : '')
            + "&av_type_id=2&cms_site_id=1";

        var features = "width=720, height=540, scrollbars=no, menu=no, resizable=no";
        //var features = "width=650, height=575, scrollbars=yes, menu=yes, resizable=no";
    } else {
        //var url = "assets/popups/player/playaudio.php";
        var url = "http://music.defjam.com/www2/av_player/AVPlayer.php?av_asset_id="
            + asset_id + (link_group_id ? "&av_link_group_id="+link_group_id : '')
            + "&av_type_id=1&cms_site_id=1";

        //var features = "width=600, height=550, scrollbars=yes, menu=yes, resizable=no";
        var features = "width=720, height=540, scrollbars=no, menu=no, resizable=no";
    }

    if (type != "lyrics") {

        if (format != '' && format != "undefined") {
            url += "&av_format=" + format;
        }

        //alert("24");

        if (speed != '' && speed != "undefined") {
            url += "&av_speed=" + speed;
        }

        //alert("30");

        if ((format == 'wm' && (speed == 'low' || speed == 'high')) || format == 'rm') {
            url += '&play_p=true';
        }
    }


    var avwin = window.open(url, "avwin", features);
    avwin.focus();
}

/*
-----------------------------------------------------------
*/

function setAVPCookie(name, value, domain) {
    var cur_time = new Date();
    var exp = cur_time.getTime() + (3600 * 1000 * 24); // live for a day
    cur_time.setTime(exp);

    document.cookie = name + "=" + escape(value) + "; expires=" + cur_time.toGMTString() + "; path=/;" + ((domain) ? "; domain=" + domain : "");
}

/*
-----------------------------------------------------------
*/
function openAvPlayerNoFormat(type, asset_id, product_id, link_group_id) {
    //alert(type);

    if (type == "video") {
        //var url = "assets/popups/player/playvideo.php";
        var url = "http://scramble.defjam.com/www2/av_player/AVPlayer.php?av_asset_id=" + asset_id + "&av_link_group_id=" + link_group_id + "&av_type_id=2&cms_site_id=1";

        var features = "width=720, height=540, scrollbars=no, menu=no, resizable=no";
        //var features = "width=650, height=575, scrollbars=yes, menu=yes, resizable=no";
    } else if (type == "audio") {
        //var url = "assets/popups/player/playaudio.php";
        var url = "http://scramble.defjam.com/www2/av_player/AVPlayer.php?av_asset_id=" + asset_id + "&av_link_group_id=" + link_group_id + "&av_type_id=1&cms_site_id=1";

        //var features = "width=600, height=550, scrollbars=yes, menu=yes, resizable=no";
        var features = "width=720, height=540, scrollbars=no, menu=no, resizable=no";
    }

    var avwin = window.open(url, "avwin", features);
    avwin.focus();
}

/*
-----------------------------------------------------------
*/