﻿var FlagCheckForVideoPlay = "N";
var screeningRoomtimer = "";
/*To avoid double clicking*/
var intScreeningClickCount = 0;
function funScreeningClickReset() {
    intScreeningClickCount = 0;
}
function funHideControls() {
    if (window.document.getElementById("bcContainer")) {
        window.document.getElementById("bcContainer").style.display = "none";
    }
    if (window.document.getElementById("titleTypeLegend")) {
        window.document.getElementById("titleTypeLegend").style.display = "none";
    }
}

function funScrDefPlayerHeader() {
    //Added by Anil on 26.02.2009 for displaying the quicktime player div.(ScreeningRoom Header)
    if (window.document.getElementById("QTPlayer")) {
        window.document.getElementById("QTPlayer").style.display = "block";
        window.document.getElementById("QTPlayer").innerHTML = "<div style='z-index:1;width:94%;height:41px;position:absolute;background-image:url(../images/spacer.gif);'>&nbsp;</div>" +
        "<div style='margin-left:98%;z-index:1;width:1%;height:41px;position:absolute;background-image:url(../images/spacer.gif);'>&nbsp;</div>" +
        "<div id='screeningHead' class='screeningHeadClosed'>" +
        "<div class='title' id='divScrRoomTitle'>Screening Room</div>" +
        "<div class='subtitle' id='divVideosubtitle'></div>" +
        "<div class='info' id='divVideoInfo'></div>" +
        "</div>" +
         "<div id='QTBody'>" +
        "<div style='position:relative;TEXT-ALIGN: center;'>" +
        "</div>" +
        "</div>";
        funQTBody();
        $("#QTBody").slideUp("fast");
        $("#screeningHead").removeClass('screeningHeadOpen');
        $("#screeningHead").addClass('screeningHeadClosed');
    }
}
function funBuildLiveStream() {
    var strHeader = "";
    var strStreamMode = document.getElementById("ctl00_ctl00_MainMenu1_hdnStreamCategory");
    if (strStreamMode && strStreamMode.value != "") {
        strHeader = "<div class='subtitle' id='divVideosubtitle'>Live Stream</div>";
    }
    if (window.document.getElementById("QTPlayer")) {
        window.document.getElementById("QTPlayer").style.display = "block";
    }
    window.document.getElementById("QTPlayer").innerHTML = "<div style='z-index:1;width:93%;height:41px;position:absolute;background-image:url(../images/spacer.gif);'>&nbsp;</div>" +
            "<div style='margin-left:97.7%;z-index:1;width:2%;height:41px;position:absolute;background-image:url(../images/spacer.gif);'>&nbsp;</div>" +
            "<div id='screeningHead' class='screeningHeadOpen'>" +
            "<div class='title' id='divScrRoomTitle'>Screening Room</div>" +
            strHeader +
            "<div class='info'></div>" +
            "</div>" +
            "<div id='QTBody'>" +
            "<div style='text-align:center;' id='divQTIFrame'>" +
            "<IFRAME id='QT_Player_iframe' name=QT_Player_iframe' style='vertical-align:top' src='../aspxfiles/Livestream.aspx'  width='990' height='327' scrolling='no' frameborder='0'></IFRAME>" +
            "</div></div>";
    funQTBody();

    var obj = window.document.getElementById("ctl00_ctl00_SpotLight1_divSpotLight");
    funRemoveTogglerLinkClass(obj, 'toggler', '', '');
    window.document.getElementById("ctl00_ctl00_hdnLiveStreamMode").value = "";

    var strFailureFlag = document.getElementById("ctl00_ctl00_MainMenu1_hdnFailureFlag");
    var strStreamMessage = document.getElementById("ctl00_ctl00_MainMenu1_hdnStreamMessage");
    if (strFailureFlag && strFailureFlag.value.toLowerCase() == "n" && DetectFlashVer(10, 0, 2) && strStreamMode.value != "") {
        funBuildAlterMsg(strStreamMessage.value, "Close");
        toggleVis('saveSearchDialog');
    }

}
//---------------------------------------------------------------------------------------------  
//Description		: Adding/Removing all the CategoryIds to Hiddenvariable.
//Remarks		    : On Click of All CheckBox from LeftNav.
//Input Params		: CheckBoxGroupName, CheckBoxId
//---------------------------------------------------------------------------------------------
function funCheckAllFilOptionsForScrRoom(chkAllObj, chkObj) {
    var obj = new Array();
    var objAll;
    var intCount;
    var vardate = new Date();
    var hdnCategories = window.document.getElementById("ctl00_ctl00_Playlist1_hdnCategoryIds");
    hdnCategories.value = "";
    var objAll = window.document.getElementById(chkObj);
    obj = window.document.getElementsByName(chkAllObj);
    if (objAll.checked) {
    }
    else {
        for (intCount = 0; intCount < obj.length; intCount++) {
            if (!obj[intCount].disabled) {
                var strValue = obj[intCount].value;
                hdnCategories.value += strValue + ",";
            }
        }
    }
    clearTimeout(screeningRoomtimer);
    screeningRoomtimer = window.setTimeout("funBuildUserPlaylist()", 2000);
}

function funGetSelectedCategoryDetailsForScrRoom(strValue) {
    var vardate = new Date();
    var hdnCategories = window.document.getElementById("ctl00_ctl00_Playlist1_hdnCategoryIds");

    if (hdnCategories.value.indexOf(strValue) > -1) {
        hdnCategories.value = hdnCategories.value.replace(strValue + ",", "");
    }
    else {
        hdnCategories.value += strValue + ",";
    }
    clearTimeout(screeningRoomtimer);
    screeningRoomtimer = window.setTimeout("funBuildUserPlaylist()", 2000);
}

function funBuildUserPlaylist() {
    var vardate = new Date();
    var hdnCategoryIds = window.document.getElementById("ctl00_ctl00_Playlist1_hdnCategoryIds").value;
    var hdnSortBy = window.document.getElementById("ctl00_ctl00_Playlist1_hdnPlaylistSortBy").value;
    var hdnCategoryType = window.document.getElementById("ctl00_ctl00_Playlist1_hdnCategoryType").value;
    var hdnPlaylistAccessOpt = window.document.getElementById("ctl00_ctl00_Playlist1_hdnPlaylistAccessOpt").value;

    var strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "SortBy=" + hdnSortBy + "~@$~" + vardate + "&CategoryIds=" + hdnCategoryIds + "&CategoryType=" + hdnCategoryType + "&AccFil=" + hdnPlaylistAccessOpt + "&Type=builduserplaylist");
    if (Trim(strResult) == "session expired") {
        funSessionExpiryNav(strResult);
    }
    else {
        window.document.getElementById("ctl00_ctl00_Playlist1_divPlaylistContent").innerHTML = Trim(strResult);
        funSetPlaylistCartYN();
        funSetHoverforTitles1();
        //Call for Playlist Row Hover. 
        funSetPlaylistRowHover();
    }
}
//function SetCategorySelected()
//{
//    var id = window.document.getElementById("ctl00_ctl00_Playlist1_hdnCategoryType").value;
//    window.document.getElementById("All").style.backgroundColor = "";
//    window.document.getElementById("MyPlaylist").style.backgroundColor = "";
//    window.document.getElementById("FoxRecommends").style.backgroundColor = "";
//    window.document.getElementById("MySeasonPass").style.backgroundColor = "";
//    window.document.getElementById("ClearPlaylist").style.backgroundColor = "";    
//    window.document.getElementById(id).style.backgroundColor = "#ffac13";
//}
function funSetScnRoomMenu(strvalue) {
    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
    window.setTimeout("funSetScnRoomMenu1('" + strvalue + "')", 100);
}
function funSetScnRoomMenu1(strvalue) {

    window.document.getElementById("ctl00_ctl00_Playlist1_hdnCategoryType").value = strvalue;
    //SetCategorySelected();
    funBuildUserPlaylist();

    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
}
function funAsynCallScripts() {
    $().cssFilterCheckbox();
    $('div.toggler-sidebar').toggleElements(
            { fxAnimation: 'slide', fxSpeed: 'fast', className: 'togglerSide' });
    //function for Cart icon class changing when the document is onready.
    SetAddtoCartYN();
    funBuildTreeView();
    //function for Playlist icon class changing when the document is onready.
    SetPlaylistYN();
}
function funInsAssetintoPlaylist(strAssetObjObjId, obj, strMode, strPlaylist, WprTitleId, strTitleName, strTitleType, strVideoType, strAssetType, strAssetFormatType, strAssetName, strFileName, strFileSize) {

    var vardate = new Date();
    var strResult;
    if (obj.title.toLowerCase() == "add to playlist") {
        obj.title = "remove from playlist";
        if (strMode.toLowerCase() == "tv") {
            obj.src = "../images/btnPlRemove.gif";
        }
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "FileObjObjId=" + strAssetObjObjId + "~@$~" + vardate + "&Type=InsPlaylist");
        funPBTrends(strTitleName, WprTitleId, strTitleType, "", "addtoplaylist", strVideoType, strAssetFormatType, strAssetName, strFileName, strFileSize);
    }
    else {
        obj.title = "add to playlist";
        if (strMode.toLowerCase() == "tv") {
            obj.src = "../images/btnPlAdd.gif";
        }
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "FileObjObjId=" + strAssetObjObjId + "~@$~" + vardate + "&Type=DelPlaylist");
        funPBTrends(strTitleName, WprTitleId, strTitleType, "", "removefromplaylist", strVideoType, strAssetFormatType, strAssetName, strFileName, strFileSize);
    }
    if (strPlaylist.toLowerCase() == "y") {
        funBuildUserPlaylist();
        funSessionExpiryNav(strResult);
    }
    else if (strPlaylist.toLowerCase() == "n") {
        if (window.document.getElementById("ctl00_ctl00_Playlist1_hdnCategoryType") != null && (window.document.getElementById("ctl00_ctl00_Playlist1_hdnCategoryType").value != "MySeasonPass")) {
            funBuildUserPlaylist();
        }
        window.document.forms[0].__VIEWSTATE.name = "";
        window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain", "");
    }

    FlagCheckForVideoPlay = "Y";

    return false;
}
function setTheatricalTrailerInfo(TitleName, strTitleObjObjid, strIPAssetName, strWprTitle_id, strRunTime, strSource, strSourceurl2, strFilename, strSourceurl1, strVideoType, strVideoAspectRatio, strFullScreen, strFileObjObjId, strWatchYN, strTitleType, strAssetName, strAssetType, strAssetFormatType, strFileSize) {
    //Added by Anil on 14.04.2009 for closing Title hover.  
    funCloseVideoDialog();
    if (FlagCheckForVideoPlay == "N") {
        funSetTrailer(strIPAssetName, strWprTitle_id, TitleName, strRunTime, strSource, strSourceurl2, strFilename, strTitleObjObjid, strSourceurl1, strVideoType, strVideoAspectRatio, strFullScreen, strFileObjObjId, strWatchYN, strTitleType, strAssetName, strAssetType, strAssetFormatType, strFileSize);
    }
    else {
        FlagCheckForVideoPlay = "N";
    }
    return false;
}
function funCancelPlay() {
    FlagCheckForVideoPlay = "Y";
    return false;
}
function funGetVideoAssetsforTitle(strTitObjObjId, strMode, obj) {
    if (obj.className.toLowerCase().indexOf("title collapsable") > -1) {
        if (window.document.getElementById("li_" + strTitObjObjId).innerHTML == "") {
            var vardate = new Date();
            var strResult;
            var strVideoFilters;
            if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions")) {
                strVideoFilters = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value;
            }
            strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TitObjObjId=" + strTitObjObjId + "~@$~" + vardate + "&Mode=" + strMode + "&Type=scrroomvideos&VideoFilters=" + strVideoFilters);
            if (window.document.getElementById("li_" + strTitObjObjId)) {
                window.document.getElementById("li_" + strTitObjObjId).innerHTML = strResult;
            }
        }
    }
    else {
        window.document.getElementById("li_" + strTitObjObjId).innerHTML = "";
    }
}
function funAddVideoAssetstoCart(TitObjObjId) {
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAddtoCartTitObjId").value = TitObjObjId;
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCartMode").value = "AddtoCart";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain", "");
}
//This Function is used to Delete and Insert Assets into MemberAssetsCart using Jquery.
function funInsAssetintoCartScreeningRoom(strAssetObjObjId, obj, strPostBack, TitleName, WprTitleId, TitleCat, AssetType, AssetFormatType, AssetName, FileName, FileSize) {
    var vardate = new Date();
    var strResult;
    var lblAssetsInCart = window.document.getElementById("ctl00_ctl00_MainMenu1_lblAssetsInCart");
    var lblBQAssetsInCart = window.document.getElementById("ctl00_ctl00_MainMenu1_lblBQAssetsInCart");
    if (obj.title.toLowerCase() == "add to cart") {
        obj.title = "remove from cart";
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "FileObjObjId=" + strAssetObjObjId + "~" + vardate + "&Type=InsAsset");
        funPBTrends(TitleName, WprTitleId, TitleCat, "", "addtocart", AssetType, AssetFormatType, AssetName, FileName, FileSize);
    }
    else {
        obj.title = "add to cart";
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "FileObjObjId=" + strAssetObjObjId + "~" + vardate + "&Type=delasset");
        funPBTrends(TitleName, WprTitleId, TitleCat, "", "removefromcart", AssetType, AssetFormatType, AssetName, FileName, FileSize);
    }
    if (lblAssetsInCart != null && strResult != null) {
        var strAssetCartCount = Trim(strResult.split('~')[0]);
        lblAssetsInCart.innerHTML = (strAssetCartCount == "1") ? strAssetCartCount + " asset" : strAssetCartCount + " assets";
    }
    if (lblBQAssetsInCart != null && strResult != null) {
        var strBQAssetCartCount = Trim(strResult.split('~')[1]);
        lblBQAssetsInCart.innerHTML = (strBQAssetCartCount == "1") ? strBQAssetCartCount + " BQ Asset" : strBQAssetCartCount + " BQ Assets";
    }
    if (strPostBack.toLowerCase() == "y") {
        window.document.forms[0].__VIEWSTATE.name = "";
        window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain", "");
    }
    else if (strPostBack.toLowerCase() == "n") {
        funBuildUserPlaylist();
    }
    else {
        funSessionExpiryNav(strResult);
    }
    FlagCheckForVideoPlay = "Y";
    return false;
}
function funInsAssetintoeditbayScreeningRoom(strAssetObjObjId, obj, strPostBack, TitleName, WprTitleId, TitleCat, AssetType, AssetFormatType, AssetName, FileName, FileSize) {
    var vardate = new Date();
    var strResult;
    var lblAssetsinEditBay = window.document.getElementById("ctl00_ctl00_MainMenu1_lblAssetsinEditBay");
    if (obj.title.toLowerCase() == "add to edit bay") {
        obj.title = "remove from edit bay";
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "FileObjObjId=" + strAssetObjObjId + "~@$~" + vardate + "&Type=InsEditbay");
        try {
            funPBTrends(TitleName, WprTitleId, TitleCat, "", "addtoeditbay", AssetType, AssetFormatType, AssetName, FileName, FileSize);
        }
        catch (e) {
        }
    }
    else {
        obj.title = "add to edit bay";
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "FileObjObjId=" + strAssetObjObjId + "~@$~" + vardate + "&Type=DelEditbay");
        try {
            funPBTrends(TitleName, WprTitleId, TitleCat, "", "removefromeditbay", AssetType, AssetFormatType, AssetName, FileName, FileSize);
        }
        catch (e) {
        }
    }
    if (lblAssetsinEditBay != null && strResult != null && strResult.toLowerCase() != "session expired") {
        var strEditBayCount = Trim(strResult);
        lblAssetsinEditBay.innerHTML = strEditBayCount + " Edit Bay";
    }
    if (strPostBack.toLowerCase() == "y") {
        window.document.forms[0].__VIEWSTATE.name = "";
        window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain", "");
    }
    else if (strPostBack.toLowerCase() == "n") {
        funBuildUserPlaylist();
    }
    else {
        funSessionExpiryNav(strResult);
    }
    FlagCheckForVideoPlay = "Y";
    return false;
}
function funClearPlaylist() {
    funBuildConfirmationMsg("Click OK to remove all videos from your Playlist.", "OK", "Cancel", "funClearPlaylist1()");
    toggleVis('saveSearchDialog');
}

function funClearPlaylist1() {
    toggleVis('saveSearchDialog');
    var vardate = new Date();
    var strResult;
    strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "Type=clearplaylist" + "~" + vardate);
    funBuildUserPlaylist();
    window.document.forms[0].__VIEWSTATE.name = "";
    window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain", "");
}

/*Function to Change background color of selected Item (Used for ScreeningRoom and CategoryLinks)*/
function funChangeBgcolor(strLinkName) {
    if (window.document.getElementById("liMainScreeningRoom")) {
        window.document.getElementById("liMainScreeningRoom").style.backgroundColor = "";
    }
    window.document.getElementById("liMainHome").style.backgroundColor = "";
    window.document.getElementById("aTitles").style.backgroundColor = "";
    if (window.document.getElementById("liMainIntLinks")) {
        window.document.getElementById("liMainIntLinks").style.backgroundColor = "";
    }
    if (window.document.getElementById("liMainTakeaTour")) {
        window.document.getElementById("liMainTakeaTour").style.backgroundColor = "";
    }
    if (strLinkName) {
        strLinkName = strLinkName.split('~')[0];
        if (window.document.getElementById("liMain" + strLinkName)) {
            window.document.getElementById("liMain" + strLinkName).style.backgroundColor = "#ffac13";
            if (window.document.getElementById("hdnCatLinkBackground") && window.document.getElementById("li" + strLinkName)) {
                window.document.getElementById("li" + strLinkName).style.backgroundColor = "#ffac13";
                window.document.getElementById("hdnCatLinkBackground").value = strLinkName;
            }
        }
        var hdnPageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
        if (hdnPageName && hdnPageName.value == "TitleList") {
            window.document.getElementById("aTitles").style.backgroundColor = "#ffac13";
        }

    }
}
function SetScrroomPlaylistOnOff(obj) {
    if (obj.className.indexOf('titlePlaylist_remove') > -1) {
        $("#" + obj.id).removeClass('titlePlaylist_remove');
        $("#" + obj.id).addClass('titlePlaylist_add');
    }
    else {
        $("#" + obj.id).removeClass('titlePlaylist_add');
        $("#" + obj.id).addClass('titlePlaylist_remove');
    }
}
function SetScrroomTextModePlaylistOnOff(obj) {
    if (obj.className.indexOf('plCart_on') > -1) {
        $("#" + obj.id).removeClass('plCart_on');
        $("#" + obj.id).addClass('plCart_off');
    }
    else {
        $("#" + obj.id).removeClass('plCart_off');
        $("#" + obj.id).addClass('plCart_on');
    }
}
function SetScrroomTextModeEditbayOnOff(obj) {
    if (obj.className.indexOf('editbayplCart_on') > -1) {
        $("#" + obj.id).removeClass('editbayplCart_on');
        $("#" + obj.id).addClass('editbayplCart_off');
    }
    else {
        $("#" + obj.id).removeClass('editbayplCart_off');
        $("#" + obj.id).addClass('editbayplCart_on');
    }
}
function funUpdateAssetsinCart() {
    var lblAssetsInCart = window.document.getElementById("ctl00_ctl00_MainMenu1_lblAssetsInCart");
    if (lblAssetsInCart != null) {
        var strAssetCartCount = Trim(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAssetsInCart").value);
        lblAssetsInCart.innerHTML = (strAssetCartCount == "1") ? strAssetCartCount + " asset" : strAssetCartCount + " assets";
    }
    funBuildUserPlaylist();
}
function funSetTrailer(strIPAssetname, strTitleId, strTitleName, strRuntime, source, sourceurl2, strFileName, TitObjObjId, sourceurl1, strVideoType, strVideoAspectRatio, strFullScreen, strFileObjObjId, strWatchYN, strTitleType, strAssetName, strAssetType, strAssetFormatType, strFileSize) {
    toggleVideoLoadingMsg('');
    window.setTimeout("funSetTrailer1('" + strIPAssetname + "','" + strTitleId + "','" + strTitleName + "','" + strRuntime + "','" + source + "','" + sourceurl2 + "','" + strFileName + "','" + TitObjObjId + "','" + sourceurl1 + "','" + strVideoType + "','" + strVideoAspectRatio + "','" + strFullScreen + "','" + strFileObjObjId + "','" + strWatchYN + "','" + strTitleType + "','" + strAssetName + "','" + strAssetType + "','" + strAssetFormatType + "','" + strFileSize + "')", 1000);
    return false;
}
function funSetTrailer1(strIPAssetname, strTitleId, strTitleName, strRuntime, source, sourceurl2, strFileName, TitObjObjId, sourceurl1, strVideoType, strVideoAspectRatio, strFullScreen, strFileObjObjId, strWatchYN, strTitleType, strAssetName, strAssetType, strAssetFormatType, strFileSize) {
    if (intScreeningClickCount == 0 && funCheckMacSpecifications().toLowerCase() == "y") {
        window.document.body.style.cursor = 'wait';
        intScreeningClickCount = 1;
        var GuidForPalyClick = "";
        try {
            GuidForPalyClick = guid();
        }
        catch (e) {
            GuidForPalyClick = guid();
        }
        var vardate = new Date();
        var FoxFastVideoPlayerType = "";
        if (source.toLowerCase() == "origin" && strVideoType.toLowerCase() == "long form drm low res") {
            //Added By Anil on 13.Oct.09 for not loading the player if the user wmv player is less than 11.0
            if (funKnowPlayerVersions() == false) {
                window.document.body.style.cursor = 'default';
                toggleVideoLoadingMsg('none');

                if (strFileName.lastIndexOf(".mov") != -1) {
                    FoxFastVideoPlayerType = "QTP";
                }
                else if (strFileName.lastIndexOf(".wmv") != -1) {
                    FoxFastVideoPlayerType = "WMP";
                }
                window.setTimeout("funScreeningClickReset()", 2000);
                return false;
            }
            else {
                funGetHtmlFromJQuery("Xmlhttp.aspx", "FileObjObjId=" + strFileObjObjId + "~" + vardate + "&Type=videowatch");
                funCreateDRMLicense(sourceurl1);
            }
        }
        if (source == "foxretail") {
            funRemoveTogglerLinkClass(obj, 'toggler', '', '');
            funPlayVideoForFoxRetail(strIPAssetname, strTitleId, strTitleName, strRuntime, source, sourceurl2, strFileName, sourceurl1, TitObjObjId, strVideoType, strVideoAspectRatio, strFullScreen, strFileObjObjId, strWatchYN, strTitleType, strAssetName, strAssetType, strAssetFormatType, strFileSize);
            window.document.getElementById("WMVPlayer").style.display = "block";
            window.document.getElementById("QTPlayer").style.display = "none";
            window.document.getElementById("divDefaultPlayer").style.display = "block";

        }
        else {
            var PBTitleName = strTitleName;
            var PBAssetName = strAssetName;
            var PBFileName = strFileName;
            if (strTitleName != "") {
                strTitleName = strTitleName.replace("~@@~", "'");
            }
            if (strFileName != "") {
                strFileName = strFileName.replace("~@@~", "'");
            }
            if (strAssetName != "") {
                strAssetName = strAssetName.replace("~@@~", "'");
            }

            var strPlayerHeader = "";
            if (strRuntime == "" || strRuntime == "0") {
                strPlayerHeader = strTitleName + " - " + strTitleId;
            }
            else {
                strPlayerHeader = strTitleName + " - " + strTitleId + " (" + strRuntime + " Minutes)";
            }

            if (strFileName.lastIndexOf(".wmv") != -1 && strFileName != "") {
                FoxFastVideoPlayerType = "WMP";
                window.document.getElementById("WMVPlayer").style.display = "block";
                window.document.getElementById("QTPlayer").style.display = "none";
                if (navigator.appName.toLowerCase() == "netscape") {
                    funQuickTimeoverShowHide('show');
                }
                var obj = window.document.getElementById("ctl00_ctl00_SpotLight1_divSpotLight");

                funRemoveTogglerLinkClass(obj, 'toggler', '', '');
                if (source.toLowerCase() == "origin" && sourceurl2 != "") {

                    var strVideoStreaming = "s";
                    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoStream")) {
                        strVideoStreaming = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoStream").value;
                    }
                    funGetHtmlFromJQuery("Xmlhttp.aspx", "FileObjObjId=" + strFileObjObjId + "~" + vardate + "&Type=videowatch");
                    if (source.toLowerCase() == "dapr") {
                        funMediaPlayerObjec(strIPAssetname, strVideoStreaming, strPlayerHeader, "", TitObjObjId, strVideoAspectRatio, strFullScreen, GuidForPalyClick);
                    }
                    else {
                        funMediaPlayerObjec(strFileName, strVideoStreaming, strPlayerHeader, "", TitObjObjId, strVideoAspectRatio, strFullScreen, GuidForPalyClick);
                    }
                }
                window.scrollTo(0, 0);
            }
            else if ((strFileName.lastIndexOf(".mov") != -1 && strFileName != "") || strAssetType.toString().toLowerCase() == "audio") {
                FoxFastVideoPlayerType = "QTP";
                window.document.getElementById("WMVPlayer").innerHTML = "";
                funGetHtmlFromJQuery("Xmlhttp.aspx", "FileObjObjId=" + strFileObjObjId + "~" + vardate + "&Type=videowatch");
                window.document.getElementById("QTPlayer").style.display = "block";
                window.document.getElementById("WMVPlayer").style.display = "none";
                var obj = window.document.getElementById("ctl00_ctl00_SpotLight1_divSpotLight");
                funRemoveTogglerLinkClass(obj, 'toggler', '', '');

                var strControl = "";
                var strIE = "Y";
                if (navigator.appName.toLowerCase() == "netscape") {
                    strIE = "N";
                    funQuickTimeoverShowHide('hide');

                }
                window.document.getElementById("QTPlayer").innerHTML = "<div style='z-index:1;width:93%;height:41px;position:absolute;background-image:url(../images/spacer.gif);'>&nbsp;</div>" +
            "<div style='margin-left:98%;z-index:1;width:2%;height:41px;position:absolute;background-image:url(../images/spacer.gif);'>&nbsp;</div>" +
            "<div id='screeningHead' class='screeningHeadOpen'>" +
            "<div class='title' id='divScrRoomTitle'>Screening Room</div>" +
            "<div class='subtitle' id='divVideosubtitle'>" + funReplaceWithActualChar(strPlayerHeader) + "</div>" +
            "<div class='info' style='z-index:2000;position:relative'><a class='hoverBox' href='javascript:void(0);' rel='popTitleHover.aspx?TitleId=" + TitObjObjId + "'><img src='../images/btnInfo.gif' border='0' /></a></div>" +
            "</div>" +
            "<div id='QTBody'>" +
            "<div style='text-align:center;' id='divQTIFrame'>" +
            "<IFRAME id='QT_Player_iframe' name=QT_Player_iframe' style='vertical-align:top' src='../aspxfiles/QTPlayer.aspx?FileName=" + strIPAssetname + "&PlayerSize=" + strVideoAspectRatio + "&IE=" + strIE + "'  width='990' height='327' scrolling='no' frameborder='0'></IFRAME>" +
            "</div>" +
            strControl +
            "</div>";

                funQTBody();
                window.scrollTo(0, 0);
            }

            strAssetFormatType = strAssetFormatType + "~@$" + GuidForPalyClick;
            window.setTimeout("funPlayerPbTrends('" + PBTitleName + "','" + strTitleId + "','" + strTitleType + "','" + strVideoType + "','" + strAssetType + "','" + strAssetFormatType + "','" + PBAssetName + "','" + PBFileName + "','" + strFileSize + "','" + FoxFastVideoPlayerType + "')", 7000);

        }
        window.setTimeout("funScreeningClickReset()", 2000);
        window.document.body.style.cursor = 'default';
    }
    toggleVideoLoadingMsg('none');
    funSetHoverforTitles1();
    return false;
}
function funHideDateSortOption(strMode) {
    if (strMode.toLowerCase() == "block") {
        if (window.document.getElementById("ctl00_ctl00_BodyContent_Views1_spanDateAddUpdate")) {
            window.document.getElementById("ctl00_ctl00_BodyContent_Views1_spanDateAddUpdate").style.display = "block";
        }
    }
    else {
        if (window.document.getElementById("ctl00_ctl00_BodyContent_Views1_spanDateAddUpdate")) {
            window.document.getElementById("ctl00_ctl00_BodyContent_Views1_spanDateAddUpdate").style.display = "none";
        }
    }
}
function funGetVideoOptions() {
    var obj = window.document.getElementsByName("filterVideoCategories");
    var intCatCount = 0;
    for (var intCount = 0; intCount < obj.length; intCount++) {
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value.indexOf(obj[intCount].id) != -1) {
            obj[intCount].checked = true;
            intCatCount = intCatCount + 1;
        }
    }
    obj1 = window.document.getElementsByName("filterVideoAll");
    if (obj1[0]) {
        if (intCatCount == obj.length) {
            obj1[0].checked = true;
        }
        else {
            obj1[0].checked = false;
        }
    }
}
//This funciton is used for video options in Leftnav for Checkall.
function funCheckAllVideoOptions(obj, Ids) {
    if (window.document.getElementById("hdnScreenNavMode")) {
        window.document.getElementById("hdnScreenNavMode").value = "";
    }
    if (obj.className == "filterUnchecked") {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value = "";
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value = Ids + ",";
    }
    else {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value = "";
    }
    /*Checkbox delay functionality*/
    clearTimeout(timer);
    timer = window.setTimeout("fnBuildDetails('', 'chk')", 2000);
}
//This funciton is used for video options in Leftnav.
function funGetSelectedVideoOptions(obj, Id) {
    if (window.document.getElementById("hdnScreenNavMode")) {
        window.document.getElementById("hdnScreenNavMode").value = "";
    }
    if (obj.className == "filterUnchecked") {
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value.indexOf(Id) < 0) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value += Id + ",";
        }
    }
    else {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value.replace(Id + ",", "");
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnVideoOptions").value.replace(Id, "");
    }

    /*Checkbox delay functionality*/
    clearTimeout(timer);
    timer = window.setTimeout("fnBuildDetails('', 'chk')", 2000);
}
//Check Access Filters in Leftnav.
function funCheckPlayAccOpt(obj, Id) {
    if (obj.className == "filterUnchecked") {
        if (window.document.getElementById("ctl00_ctl00_Playlist1_hdnPlaylistAccessOpt").value.indexOf(Id) < 0) {
            window.document.getElementById("ctl00_ctl00_Playlist1_hdnPlaylistAccessOpt").value += Id + ",";
        }
    }
    else {
        window.document.getElementById("ctl00_ctl00_Playlist1_hdnPlaylistAccessOpt").value = window.document.getElementById("ctl00_ctl00_Playlist1_hdnPlaylistAccessOpt").value.replace(Id + ",", "");
        window.document.getElementById("ctl00_ctl00_Playlist1_hdnPlaylistAccessOpt").value = window.document.getElementById("ctl00_ctl00_Playlist1_hdnPlaylistAccessOpt").value.replace(Id, "");
    }
    clearTimeout(screeningRoomtimer);
    screeningRoomtimer = window.setTimeout("funBuildUserPlaylist()", 2000);
}
function funNavScrRoomForSmartSearch(strValue, strMode) {
    if (strMode.toLowerCase() == "singlesearch") {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitObjObjId").value = strValue;
    }
    else {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitObjObjId").value = Trim(window.document.getElementById("ctl00_ctl00_Login1_titleSearch").value);
    }
    funLeftFilter_SessionMemberPreference_Update('All');
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo") != null) {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = "1";
    }
    window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "All";
    window.document.getElementById("hdnScreenNavMode").value = strMode;
    window.document.forms[0].action = "NewScreeningRoom.aspx";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}

function funDownloadSingleFileFromScrRoom(titleObjObjId, fileObjObjId, mode, source, strTitleName, sourceurl1, AdRestObjObjId, videotype) {
    var Browser = funGetBrowserType();
	  
if (videotype.toLowerCase() == "long form drm low res" && Browser.toLowerCase() != "microsoft internet explorer") {

        funBuildPswdPolicyAlterMsg("Sorry, this video is protected with security features and cannot be downloaded with the browser you are currently using.&nbsp;&nbsp;You must be on a Windows operating system with <B>Internet Explorer version 6 or above</B> to successfully download FoxFast’s secured video.", "OK")
        toggleVis('saveSearchDialog');
        return false;
    }

    strTitleName = strTitleName.replace("~@@~", "'");

    if (mode == "PL") {
        FlagCheckForVideoPlay = "Y";
    }

    var vardate = new Date();
    var downloadmode = "single";
    var strresult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TtlObjObjId=" + titleObjObjId + "~" + vardate + "&Type=AdRestriction&mode=scrRoom&downloadmode=single&fileObjObjId=" + fileObjObjId + "&source=" + source + "&strTitleName=" + strTitleName + "&sourceurl1=" + sourceurl1 + "&AdRestObjObjId=" + titleObjObjId + "&Mode=" + mode);

    var strArray = strresult.split('~^~^');
    if (Trim(strArray[0]) != "") {
        funCloseVideoDialog();
        window.document.getElementById("adRestrictDetailsWrapper").innerHTML = strArray[0];
        toggleVis("adRestrictionsClick");
    }
    else {
        var hdnFoxFastDownloaderGroupYN = document.getElementById("ctl00_ctl00_hdnFoxFastDownloaderGroupYN").value;
        if (source.toLowerCase() == "esprit") {
            funDownloadVideoForEsprit(strTitleName, sourceurl1)
        }
        else if (source.toLowerCase() == "origin" && hdnFoxFastDownloaderGroupYN == "Y") {
            funDownloadVideoForOrigin(fileObjObjId);
        }
        else {
            funDownloadSingleFile(fileObjObjId);
        }
    }

    return false;
}

function funChangeDefaultPlaylistSortOrder() {
    if ($("#ScrPlaylistSortOrderOptions>#sortPlaylistID1")) {
        $("#ScrPlaylistSortOrderOptions>#sortPlaylistID1").removeClass('sortOptions_on');
        $("#ScrPlaylistSortOrderOptions>#sortPlaylistID1").removeClass('sortOptions_off');
        $("#ScrPlaylistSortOrderOptions>#sortPlaylistID3").removeClass('sortOptions_on');
        $("#ScrPlaylistSortOrderOptions>#sortPlaylistID3").removeClass('sortOptions_off');
        $("#ScrPlaylistSortOrderOptions>#sortPlaylistID1").addClass('sortOptions_off');
        $("#ScrPlaylistSortOrderOptions>#sortPlaylistID3").addClass('sortOptions_on');
    }
}

function funShowSCRQuickVideoPlayMsg() {
    funBuildAlterMsg("Sorry, the request to play this video was not designed for the login account you entered.  Please try again or contact foxtvdigital@fox.com for assistance.", "OK");
    toggleVis('saveSearchDialog');
}
