﻿function funShowExpandCollapse() {
    window.document.getElementById("spanExpCollapse").style.display = "block";
}

function funOpenMetaData(userName, memberId) {
    if (window.screen.availWidth == 800)
        window.open('http://www.foxfast.com/FoxCentral/aspxfiles/Login.aspx?_L=' + userName + '&_M=' + memberId, 'metadata', ''); // 'width=700,height=500,status=yes,scrollbars=yes,resizable=yes,top=40,left=40,alwaysRaised=yes');
    else
        window.open('http://www.foxfast.com/FoxCentral/aspxfiles/Login.aspx?_L=' + userName + '&_M=' + memberId, 'metadata', ''); // 'width=900,height=600,status=yes,scrollbars=yes,resizable=yes,top=40,left=40,alwaysRaised=yes');
}

function funopenfoxflyer(logonname, email) {
    window.open("../aspxfiles/FoxFlyerEmail.aspx", "foxflyer", "");
}

function EmailTrim(obj) {
    var firstIndex, lastIndex;
    var value = obj.value;
    firstIndex = 0;
    lastIndex = value.length;
    for (i = 0; i < value.length; i++)
        if (value.charAt(i) == " ")
        firstIndex++;
    else
        break;
    for (i = (value.length - 1); i >= firstIndex; i--)
        if (value.charAt(i) == " ")
        lastIndex--;
    else
        break;
    return value.substring(firstIndex, lastIndex);
}

function funShowSeriesNav(strTitleObjObjId) {
    var vardate = new Date();
    var strResult;
    strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TitObjObjId=" + strTitleObjObjId + "~" + vardate + "&Type=SeriesNav");
    if (window.document.getElementById("ctl00_ctl00_Menu1_divSeriesNav")) {
        window.document.getElementById("ctl00_ctl00_Menu1_divSeriesNav").innerHTML = strResult;
    }

    $(function() {
        $("#seriesNavList").treeview({
    });
    if (window.document.getElementById("ulseriesexpand")) {
        $("#ulseriesexpand").removeAttr("style");
        $("#ulseriesexpand").attr("src", "display:block");
    }
    if (window.document.getElementById("ulseasonexpand")) {
        $("#ulseasonexpand").removeAttr("style");
        $("#ulseasonexpand").attr("src", "display:block");
    }
});

}
function funTitleDetailsHome(Id) {
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitObjObjId").value = Id;
    window.document.forms[0].action = "TitleDetailsList.aspx";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}
function funMoreNav(Id, strPageName) {
    if (strPageName == "TitleCastCrew.aspx") {
        var vardate = new Date();
        funGetHtmlFromJQuery("Xmlhttp.aspx", "TitObjObjId=" + Id + "~" + vardate + "&Type=otherassetrightslevel3");
    }
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitObjObjId").value = Id;
    window.document.forms[0].action = strPageName;
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}

function funeSalesSheetNav(Id) {
    window.open('../aspxfiles/eSalesSheetPortal.aspx', 'eSalesSheetPortal', 'toolbar=no,location=no,status=no,menubar=no,width=920px,height=600px,scrollbars=no,resizable=no');
}

function funMoreNavLegal(Id, strPageName, strClickMode) {
    if (strPageName == "TitleCastCrew.aspx") {
        var vardate = new Date();
        funGetHtmlFromJQuery("Xmlhttp.aspx", "TitObjObjId=" + Id + "~" + vardate + "&Type=otherassetrightslevel3");
    }
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitObjObjId").value = Id;
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleClickMode").value = strClickMode;
    window.document.forms[0].action = strPageName;
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}

//function to trim leading and trailing white spaces
function Trim(str) {
    return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


//function to trim leading and trailing charactors
function TrimChar(str, chars) {
    return LTrimChar(RTrimChar(str, chars), chars);
}

//function to trim leading charactors
function LTrimChar(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

//function to trim trailing charactors
function RTrimChar(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function funCreateXmlhttpObj() {
    var oXMLHTTP = false;

    try {
        // Firefox, Opera 8.0+, Safari
        oXMLHTTP = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            oXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                funBuildAlterMsg("Your browser does not support AJAX!", "OK")
                toggleVis('saveSearchDialog');
            }
        }
    }

    return oXMLHTTP;
}

/*  Common Method for getting the CheckBox values appended with comma separator. */
function funGetCheckedValues(objCheckBox, strHiddenVariable) {
    if (objCheckBox.checked) {
        window.document.getElementById(strHiddenVariable).value += objCheckBox.value + ",";

    }
    else {
        window.document.getElementById(strHiddenVariable).value = window.document.getElementById(strHiddenVariable).value.replace(objCheckBox.value + ",", "");
        window.document.getElementById("chkProductCategoryAll").checked = false;
    }
}


function funGetValues(objCheckBox, strHiddenVariable) {
    var Id = objCheckBox.id;
    if (objCheckBox.checked) {
        strHiddenVariable.value += Id + ",";
    }
    else {
        strHiddenVariable.value = strHiddenVariable.value.replace(Id + ",", "");
    }
}

function funLogout() {
    window.document.forms[0].action = "Login.aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}
function funAdvancedSearch() {
    window.document.forms[0].action = "AdvancedSearch.aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}


function funGetHtmlFromJQuery(pageName, parameters) {
    var html = $.ajax({
        url: pageName,
        data: parameters,
        async: false
    }).responseText;
    html = html.replace(html.substring(html.indexOf("<!DOC") - 2), "");

    return html;
}
//This Function is used to Delete and Insert Title into Favourites using Jquery
function funInsTitleintoFav(strTitleId, TitleName, WprTitleId, TvdProductType, obj) {
    var strResult;
    var vardate = new Date();
    if (obj.className == "favoff") {
        obj.className = "favon";
        obj.title = "remove from favorites";
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TitleId=" + strTitleId + "~" + vardate + "&Type=Favourites");
        funPBTrends(TitleName, WprTitleId, TvdProductType, "", "addtofavorites", "", "", "", "", "");
    }
    else {
        obj.title = "add to favorites";
        obj.className = "favoff";
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TitleId=" + strTitleId + "~" + vardate + "&Type=DeleteFav");
        funPBTrends(TitleName, WprTitleId, TvdProductType, "", "removefromfavorites", "", "", "", "", "");
    }

    funSessionExpiryNav(strResult);
}
//This Function is used to Delete and Insert Title into Cart using Jquery
function funInsTitleintoCart(strTitleId, obj) {
    var vardate = new Date();
    var strResult;
    var lblTitleInCart = window.document.getElementById("ctl00_ctl00_MainMenu1_lblTitleInCart");

    if (obj.className == "cartoff") {
        obj.className = "carton";
        obj.title = "remove from cart"
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TitleId=" + strTitleId + "~" + vardate + "&Type=Cart");
    }
    else {
        obj.title = "add to cart"
        obj.className = "cartoff";
        strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TitleId=" + strTitleId + "~" + vardate + "&Type=DeleteCart");
    }

    if (lblTitleInCart != null && strResult != null) {
        var strTitCartCount = Trim(strResult);
        lblTitleInCart.innerHTML = (strTitCartCount == "1") ? strTitCartCount + " title" : strTitCartCount + " titles";
    }

    funSessionExpiryNav(strResult);
}

function funNavPage(strPageName, strMode) {
    strMode = funReplaceWithActualChar(strMode);
    if (strPageName.toLowerCase() != "titlecart.aspx") {
        if (strMode == "Licensed Titles") {
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = strMode;
        }
        else if (strMode == "Favorites") {
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = strMode;
        }
        else if (strMode == "New") {
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = strMode;
        }
        else if (strMode == "Recently Viewed") {
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = strMode;
        }
        else if (strMode == "Saved Search") {
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = strMode;
        }
        else {
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "All";
        }
        /*Conditions added for clearing Parent-Child flags on 02-02-2009 by Manihari*/
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild") != null) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild").value = "";
        }
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleDetailsForCast") != null) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleDetailsForCast").value = "";
        }
        if (strPageName.toLowerCase() == "NewScreeningRoom.aspx") {
            if (window.document.getElementById("hdnScreenNavMode")) {
                window.document.getElementById("hdnScreenNavMode").value = "menu";
            }
        }
        window.document.forms[0].action = strPageName;
        window.document.forms[0].submit();
    }
    else {
        funNavToTitleAssetCartScreen('TitleCart');
    }
}
function funNavPage1(id) {
    if (FlagCheckForVideoPlay) {
        FlagCheckForVideoPlay = "Y";
    }
    window.document.location.href = "TitleDetailsHome.aspx?TitleId=" + id + "&Type=ScrR";
    return false;
}

// Doing Asyncronous PostBack for the TitleList Page.
function funTitleListAsyncronouPostBack(strClearHiddenVar) {
    // Clearing the ParentChild Flag Hiddev Varaible when not required.
    if (strClearHiddenVar != "N") {
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild") != null) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild").value = "";
        }
    }

    window.document.forms[0].__VIEWSTATE.name = "";
    window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain", "");
}

//CheckAll functionality which uses ID of the div in which the Checkboxes reside and the ID of the CheckAll checkbox
function funCheckAllJQuery(parentId, childId) {
    $("#" + childId + " :checkbox").attr('checked', $("#" + parentId).is(':checked'));
}

function funBuildSaveSearchMsg(Heading, txtSave, txtCancel, ScriptFunNameForSave) {
    window.document.getElementById("saveSearchDialog").innerHTML = "<div class='top'></div>" +
        "<div class='body'>" +
            "<div class='modalClose'><a href='javascript:void(0);' onclick='toggleVis(\"saveSearchDialog\");'><img src='../images/close.gif' border='0' /></a></div>" +
            "<div class='modalContent'>" +
    //<!-- put prompt text within p tags -->
                "<p>" +
                Heading + //"Save new title search as:"+
                "<input type='text' class='smallModalInput' id='titleSearchTitle' name='titleSearchTitle'  />" +
                "</p>" +
    //<!-- use 'affirmative' and 'negative' link classes for responses (funAdvSrchEvents)-->
                "<a href='#' onclick='javascript:return " + ScriptFunNameForSave + ";' class='affirmative'>" + txtSave + "</a>" +
    //<!-- using close link here again to cancel out of the dialog -->
                "<a href='javascript:void(0);' onclick='toggleVis(\"saveSearchDialog\");' class='negative'>" + txtCancel + "</a>" +
            "</div>" +
        "</div>" +
      "<div class='bot'></div>";
}

function funBuildAlterMsg(Msg, txtOk) {
    window.document.getElementById("saveSearchDialog").innerHTML = "<div class='top'></div>" +
        "<div class='body'>" +
            "<div class='modalClose'><a href='javascript:void(0);' onclick='toggleVis(\"saveSearchDialog\");'><img src='../images/close.gif' border='0' /></a></div>" +
            "<div class='modalContent'>" +
    //<!-- put prompt text within p tags -->
                "<p>" +
                Msg + //"Save new title search as:"+
                "</p>" +
    //<!-- using close link here again to cancel out of the dialog -->
                "<a href='javascript:void(0);' onclick='javascript:funExtendedPopUpFunction();' class='affirmative'>" + txtOk + "</a>" +
            "</div>" +
        "</div>" +
      "<div class='bot'></div>";
}
function funExtendedPopUpFunction() {
    toggleVis('saveSearchDialog');
    if (window.document.getElementById("ctl00_ctl00_Login1_txtUserName") && $("#loginContainer").is(':visible')) {
        window.document.getElementById("ctl00_ctl00_Login1_txtUserName").value = "";
        window.document.getElementById("ctl00_ctl00_Login1_txtUserName").focus();
    }
    //<!--  Added on 6th April for the ITS ISSUE# 1462 -->
    else if (window.document.getElementById("ctl00_ctl00_Login22_txtUserName")) {
        if (window.document.getElementById("ctl00_ctl00_Login22_txtUserName").value == "") {
            window.document.getElementById("ctl00_ctl00_Login22_txtUserName").value = "";
            window.document.getElementById("ctl00_ctl00_Login22_txtUserName").focus();
        }
        else {
            window.document.getElementById("ctl00_ctl00_Login22_txtPassword").value = "";
            window.document.getElementById("ctl00_ctl00_Login22_txtPassword").focus();
        }
    }
    $("form.error:first").focus();
}

function funBuildAlterMsgWithAction(Msg, txtOk, ScriptFunNameForOk) {
    window.document.getElementById("saveSearchDialog").innerHTML = "<div class='top'></div>" +
        "<div class='body'>" +
            "<div class='modalClose'><a href='javascript:void(0);' onclick='toggleVis(\"saveSearchDialog\");'><img src='../images/close.gif' border='0' /></a></div>" +
            "<div class='modalContent'>" +
    //<!-- put prompt text within p tags -->
                "<p>" +
                Msg + //"Save new title search as:"+
                "</p>" +
    //<!-- using close link here again to cancel out of the dialog -->
                "<a href='javascript:void(0);' onclick='javascript:return " + ScriptFunNameForOk + ";' class='affirmative'>" + txtOk + "</a>" +
            "</div>" +
        "</div>" +
      "<div class='bot'></div>";
}

function funBuildConfirmationMsg(Msg, txtOk, txtCancel, ScriptFunNameForOk) {
    window.document.getElementById("saveSearchDialog").innerHTML = "<div class='top'></div>" +
        "<div class='body'>" +
            "<div class='modalClose'><a href='javascript:void(0);' onclick='toggleVis(\"saveSearchDialog\");'><img src='../images/close.gif' border='0' /></a></div>" +
            "<div class='modalContent'>" +
    //<!-- put prompt text within p tags -->
                "<p>" +
                Msg + //"Save new title search as:"+
                "</p>" +
    //<!-- using close link here again to cancel out of the dialog -->
                "<a href='javascript:void(0);' onclick='javascript:return " + ScriptFunNameForOk + ";' class='affirmative'>" + txtOk + "</a>&nbsp;" +
                "<a href='javascript:void(0);' onclick='toggleVis(\"saveSearchDialog\");' class='negative'>" + txtCancel + "</a>" +
            "</div>" +
        "</div>" +
      "<div class='bot'></div>";
}
function funBuildMultipleUsersConfirmationMsg(Msg, txtOk, txtCancel, ScriptFunNameForOk, ScriptFunNameForCancel) {
    window.document.getElementById("saveSearchDialog").innerHTML = "<div class='top'></div>" +
        "<div class='body'>" +
            "<div class='modalClose'><a href='javascript:void(0);' onclick='toggleVis(\"saveSearchDialog\");'><img src='../images/close.gif' border='0' /></a></div>" +
            "<div class='modalContent'>" +
    //<!-- put prompt text within p tags -->
                "<p>" +
                Msg + //"Save new title search as:"+
                "</p>" +
    //<!-- using close link here again to cancel out of the dialog -->
                "<a href='javascript:void(0);' onclick='javascript:return " + ScriptFunNameForOk + ";' class='affirmative'>" + txtOk + "</a>&nbsp;" +
                "<a href='javascript:void(0);' onclick='javascript:return " + ScriptFunNameForCancel + ";' class='negative'>" + txtCancel + "</a>" +
            "</div>" +
        "</div>" +
      "<div class='bot'></div>";
}
function funBuildConfirmationMsgWithAction(Msg, txtOk, txtCancel, ScriptFunNameForOk, ScriptFunNameForCancel) {
    window.document.getElementById("divSoftwareUpdateAlterMsg").innerHTML = "<div class='topwider'></div>" +
        "<div class='bodywider'>" +
            "<div class='modalClose'><a href='javascript:void(0);' onclick='toggleVis(\"divSoftwareUpdateAlterMsg\");'><img src='../images/close.gif' border='0' /></a></div>" +
            "<div class='modalContent1'>" +
    //<!-- put prompt text within p tags -->
                "<p>" +
                Msg + //"Save new title search as:"+
                "</p>" +
    //<!-- using close link here again to cancel out of the dialog -->
                "<div style='text-align: center;'><a href='javascript:void(0);' onclick='javascript:return " + ScriptFunNameForOk + ";' class='affirmative'>" + txtOk + "</a>&nbsp;" +
                "<a href='javascript:void(0);' onclick='javascript:return " + ScriptFunNameForCancel + ";' class='negative'>" + txtCancel + "</a></div>" +
            "</div>" +
        "</div>" +
      "<div class='botwider'></div>";
}

function funBuildTermsConditionButton(ScriptFunName) {
    window.document.getElementById("divBtnTermsConditions").innerHTML = "<div class='button'>" +
            "<a href='javascript:" + ScriptFunName + ";'>" +
                "<img src='../images/btnAgree.gif' border='0' /></a></div>" +
        "<div class='button'>" +
            "<a href='javascript:funDisAgreeTermsConditions();'>" +
                "<img src='../images/btnDisagree.gif' border='0' /></a></div>";
}

function funGetAdvnSrchforCast(talentId, titobjobjId, talentName, TitleName, WprTitleId, TvdProductType, Level3callYN) {
    //For web trends tracking
    funPBTrends(TitleName, WprTitleId, TvdProductType, "BiosDescription", talentName, "", "", "", "", "");
    if (titobjobjId && titobjobjId != "") {
        window.document.getElementById("hdnCastTitleObjectObjectId").value = titobjobjId;
        if (Level3callYN == "Y") {
            var vardate = new Date();
            funGetHtmlFromJQuery("Xmlhttp.aspx", "TitObjObjId=" + titobjobjId + "~" + vardate + "&Type=otherassetrightslevel3");
        }
    }
    window.document.getElementById("hdnCastTalentObjectObjectId").value = talentId;

    window.document.forms[0].action = "TitleBios.aspx";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
    return false;
}
function funGetCastTitles(talentId, talentName, TitleName, WprTitleId, TvdProductType) {
    // Function call to update the All Filter Option in Session_member_preference_type table when request for titles in this mode.
    funLeftFilter_SessionMemberPreference_Update('All');
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategoryLinkId") != null) {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategoryLinkId").value = "";
    }
    if (window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu")) {
        window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "";
        window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "All";
    }
    //For web trends tracking
    funPBTrends(TitleName, WprTitleId, TvdProductType, "OtherFoxTitles", talentName, "", "", "", "", "");
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleDetailsForCast").value = talentId; //+"~"+firstName+"~"+middleName+"~"+lastName;
    window.document.forms[0].action = "TitlesList.aspx";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
    return false;
}

function funLeftFilter_SessionMemberPreference_Update(type) {
    var vardate = new Date();
    var strResult;
    strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "Option=" + type + "~@$~" + vardate + "&Type=updateleftfilsesmempref");
    return strResult;
}

function funFoxFastLogoClick() {

    // Added for showing Loading wait.. Message.
    if (window.document.getElementById('divProgressDialog')) {
        toggleVis('divProgressDialog');
    }
    funLeftFilter_SessionMemberPreference_Update('ESE');
    window.location.href = "TitlesList.aspx";
}
function funFoxFastcancelClick() {

    var QS = window.location.search.substring(1);
    if (QS == "TitleList") {
        window.document.forms[0].action = "TitleList.aspx";
    }
    else if (QS == "Login") {
        window.document.forms[0].action = "Login.aspx";
    }
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();

}
function funFoxFastHomeClick() {
    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
    var strResult = funLeftFilter_SessionMemberPreference_Update('MP');
    strResult = strResult.substring(0, strResult.length - 2);
    NavAsPerUserPreferences(strResult);

}
function NavAsPerUserPreferences(strResult) {
    //    if (window.document.aspnetForm.ctl00_LogBodyContent_hdnMode.value == 'Screening_Room') {
    //        toggleVis('divProgressDialog');
    //        funNavScreeningRoom("All");
    //        return;
    //    }   

    var strValues = strResult.split('~');
    if (strValues[1].indexOf('$') != -1) {
        funLeftFilter_SessionMemberPreference_Update('ESE');
        strValues[1] = strValues[1].substring(0, strValues[1].length - 1);
    }
    if (strValues[1] == "ChangePwd") {
        window.document.forms[0].action = "ChangePwd.aspx";
        window.document.forms[0].method = "post";
        window.document.forms[0].__VIEWSTATE.name = "";
        window.document.forms[0].submit();
    }
    else if (strValues[1] == "savedsearches") {
        toggleVis('divProgressDialog');
        funGetAdvSrchTitleDetails(strValues[2] + "~" + strValues[3])
    }
    else if (strValues[1] == "screeningroom") {
        toggleVis('divProgressDialog');
        funNavScreeningRoom("All");
    }
    else if (strValues[1] == "livestream") {
        // funViewLiveStream();
        window.document.forms[0].action = "TitlesList.aspx";
        window.document.forms[0].method = "post";
        window.document.forms[0].__VIEWSTATE.name = "";
        window.document.forms[0].submit();
    }
    else {
        if (strValues[1] == "mytitles") {
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "All";
        }
        else if (strValues[1] == "new") {
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "New";
        }
        else if (strValues[1] == "favorites") {
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "Favorites";
        }
        else if (strValues[1] == "licensedtitles") {
            funLeftFilter_SessionMemberPreference_Update('EE');
            window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "Licensed Titles";
        }

        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild") != null) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild").value = "";
        }
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleDetailsForCast") != null) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleDetailsForCast").value = "";
        }
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategoryLinkId") != null) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategoryLinkId").value = "";
        }
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo") != null) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = "1";
        }
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnShowHierarchy")) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnShowHierarchy").value = "Y";
        }
        window.document.forms[0].action = "TitlesList.aspx";
        window.document.forms[0].method = "post";
        window.document.forms[0].__VIEWSTATE.name = "";
        window.document.forms[0].submit();
    }
}

//Function to persist the spotlight expand/collapse mode.
function funSpotLight(condition) {
    var vardate = new Date();
    var strResult;
    var Flag = "Y";
    if (condition == "hide") {
        Flag = "N";
    }
    strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "FlagYN=" + Flag + "~@$~" + vardate + "&Type=setSpotLight");
    if (window.document.getElementById("QTBody")) {
        if (condition == "hide") {
            $("#QTBody").slideDown("fast");
            $("#screeningHead").removeClass('screeningHeadClosed');
            $("#screeningHead").addClass('screeningHeadOpen');
            if (navigator.appName.toLowerCase() == "netscape" && window.document.getElementById("QTPlayer") && window.document.getElementById("QTPlayer").style.display == 'block') {
                funQuickTimeoverShowHide('hide');
            }
            funSetPlayeronSpotlight('show');
        }
        else {
            $("#QTBody").slideUp("fast");
            $("#screeningHead").removeClass('screeningHeadOpen');
            $("#screeningHead").addClass('screeningHeadClosed');
            funQuickTimeoverShowHide('show');
            funSetPlayeronSpotlight('hide');
        }
    }
    return false;
}
function funPlayVideoForFoxRetail(strIPAssetname, strTitleId, strTitleName, strRuntime, source, sourceurl2, strFileName, sourceurl1, strTitleObjObjId, strVideoType, strVideoAspectRatio, strFullScreen, strFileObjObjId, strWatchYN, strTitleType, strAssetName, strAssetType, strAssetFormatType, strFileSize, strshortlenghtPreview) {
    toggleVideoLoadingMsg('');
    window.setTimeout("funPlayVideoForFoxRetail1('" + strIPAssetname + "','" + strTitleId + "','" + strTitleName + "','" + strRuntime + "','" + source + "','" + sourceurl2 + "','" + strFileName + "','" + sourceurl1 + "','" + strTitleObjObjId + "','" + strVideoType + "','" + strVideoAspectRatio + "','" + strFullScreen + "','" + strFileObjObjId + "','" + strWatchYN + "','" + strTitleType + "','" + strAssetName + "','" + strAssetType + "','" + strAssetFormatType + "','" + strFileSize + "','" + strshortlenghtPreview + "')", 1000);
    return false;
}
function funPlayVideoForFoxRetail1(strIPAssetname, strTitleId, strTitleName, strRuntime, source, sourceurl2, strFileName, sourceurl1, strTitleObjObjId, strVideoType, strVideoAspectRatio, strFullScreen, strFileObjObjId, strWatchYN, strTitleType, strAssetName, strAssetType, strAssetFormatType, strFileSize, strshortlenghtPreview) {
    var FoxFastVideoPlayerType = "WMP";
    var GuidForPalyClick = "";
    var Browser = funGetBrowserType();
    try {
        GuidForPalyClick = guid();
    }
    catch (e) {
        GuidForPalyClick = guid();
    }
//    if (Browser.toLowerCase() != "microsoft internet explorer" && strVideoType.toLowerCase() == "long form watermarked") {
//        funBuildAlterMesg("Sorry, the security on this protected video requires you to use the Internet Explorer browser on a PC for viewing in FoxFast.  Beginning July 2011, you may use other browsers and platforms to play our highly-secured video.", "OK");
//        toggleVis('saveSearchDialog');
//    }
//    else {
        var vardate = new Date();
        var PBTitleName = strTitleName;
        if (strTitleName && strTitleName != "") {
            strTitleName = strTitleName.replace(/~@@~/g, "'");
       // }
        funPlayFoxRetailVideo(sourceurl1);
    }
    
    funCloseVideoDialog();
    strAssetFormatType = strAssetFormatType + "~@$" + GuidForPalyClick;
    window.setTimeout("funPlayerPbTrends('" + PBTitleName + "','" + strTitleId + "','" + strTitleType + "','" + strVideoType + "','" + strAssetType + "','" + strAssetFormatType + "','" + strAssetName + "','" + strFileName + "','" + strFileSize + "','" + FoxFastVideoPlayerType + "')", 7000);
    toggleVideoLoadingMsg('none');
    return false;
}

function funDownloadVideoForEsprit(strTitleName, sourceurl1) {
    if (strTitleName && strTitleName != "") {
        strTitleName = strTitleName.replace("~@@~", "'");
    }

    var vardate = new Date();
    var varTime = vardate.getTime();
    url = "../aspxfiles/DownloadEspritValidatePopup.aspx?assetIDs=" + sourceurl1 + "&getToken=Y";

    Openpopup(url, 450, 500, varTime, 'N');

    return false;
}

function funDownloadVideoForOrigin(fileObjObjId) {
    funStoreLicenseforDownload(fileObjObjId);


    var vardate = new Date();
    var varTime = vardate.getTime();
    url = "../aspxfiles/Download.aspx?fileObjObjId=" + fileObjObjId + "&orginDwnld=Y";
    Openpopup(url, 300, 150, varTime, 'N');


}

function funCreateDRMLicense(sourceurl1) {
    var vardate = new Date();
    var OSType = funGetOperatingSystem();
    var SilLightInstalFlag = isSilverlightInstalled();
    var Browser = funGetBrowserType();
    var strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "&Mode=" + vardate + "&Type=drmlicense&sourceurl1=" + sourceurl1 + "&OSType=" + OSType + "&SilLightInstalFlag=" + SilLightInstalFlag);
    if (strResult && Trim(strResult) == "session expired") {
        funSessionExpiryNav(strResult);
    }
    else if (strResult.toLowerCase() == "failed createsession call") {
        funBuildPswdPolicyAlterMsg("Sorry, we are having trouble playing video on your PC. It is likely that you need to update your computer’s software.  Please click <a href='../aspxfiles/Help.aspx' target='_blank' style='color:White'>here</a> to visit our Help page where quick installation links will be listed for your use.", "OK")
        toggleVis('saveSearchDialog');
    }
    else if (strResult.toLowerCase() == "failed registeruser call") {
        funBuildPswdPolicyAlterMsg("Sorry, we are having trouble playing video on your PC. It is likely that you need to update your computer’s software.  Please click <a href='../aspxfiles/Help.aspx' target='_blank' style='color:White'>here</a> to visit our Help page where quick installation links will be listed for your use.", "OK")
        toggleVis('saveSearchDialog');
    }
    else {
        if (window.document.getElementById('netobj') && strResult != "") {
            //Condition to check storelicense should be called only when os is windows and silverlight is not installed inthe client system.
            if (OSType.toLowerCase() == "windows" && SilLightInstalFlag.toLowerCase() == "n" && Browser.toLowerCase() != "netscape") {
                try {
                    window.document.getElementById('netobj').StoreLicense(strResult);
                }
                catch (e) {
                    if ($("#QTPlayer>#QTBody")) {
                        $("#QTPlayer>#QTBody").html("");
                        funBuildPswdPolicyAlterMsg("Sorry, we are having trouble playing video on your PC. It is likely that you need to update your computer’s software.  Please click <a href='../aspxfiles/Help.aspx' target='_blank' style='color:White'>here</a> to visit our Help page where quick installation links will be listed for your use.", "OK")
                        toggleVis('saveSearchDialog');

                    }
                    //                    funBuildPswdPolicyAlterMsg("Sorry, we are having trouble playing video on your PC. It is likely that you need to update your computer’s software.  Please click <a href='../aspxfiles/Help.aspx' target='_blank' style='color:White'>here</a> to visit our Help page where quick installation links will be listed for your use.", "OK")
                    //                    toggleVis('saveSearchDialog');
                }
            }
        }
    }
}
function funGetSystemInfo() {
    if (window.ActiveXObject) {
        // IE
        try {
            var DRM = document.getElementById('netobj');
            var ClientInfo = DRM.GetSystemInfo();
            document.getElementById("hdnClientInfo").value = escape(ClientInfo);
            if (document.getElementById("hdnSCRclientInfo")) {
                document.getElementById("hdnSCRclientInfo").value = escape(ClientInfo);
            }
        }
        catch (e) {
        }
    }
    else if (window.GeckoActiveXObject) {
        // Firefox, Netscape 7>
        try {
            var DRM = new GeckoActiveXObject('DRM.GetLicense.1');
            document.getElementById("hdnClientInfo").value = escape(DRM.GetSystemInfo());
            if (document.getElementById("hdnSCRclientInfo")) {
                document.getElementById("hdnSCRclientInfo").value = escape(DRM.GetSystemInfo());
            }
        }
        catch (e) {
        }
    }
    else {
    }
}

function GetClientCurrentDate() {
    if (window.document.getElementById("ctl00_ctl00_Login1_titleSearch")) {
        window.document.getElementById("ctl00_ctl00_Login1_titleSearch").disabled = false;
    }
    var d = new Date();
    var curr_date = d.getDate();
    var curr_month = d.getMonth() + 1;
    var curr_year = d.getFullYear();
    if (document.getElementById("ctl00_ctl00_Login1_lblCurDate")) {
        document.getElementById("ctl00_ctl00_Login1_lblCurDate").innerHTML = (GetMonthName(curr_month) + " " + curr_date + ", " + curr_year);
    }
    else if (document.getElementById("lblCurDate")) {
        document.getElementById("lblCurDate").innerHTML = (GetMonthName(curr_month) + " " + curr_date + ", " + curr_year);
    }
}
function GetMonthName(month) {
    var MonthName = '';
    switch (month) {
        case 1:
            MonthName = 'January';
            break;
        case 2:
            MonthName = 'February';
            break;
        case 3:
            MonthName = 'March';
            break;
        case 4:
            MonthName = 'April';
            break;
        case 5:
            MonthName = 'May';
            break;
        case 6:
            MonthName = 'June';
            break;
        case 7:
            MonthName = 'July';
            break;
        case 8:
            MonthName = 'August';
            break;
        case 9:
            MonthName = 'September';
            break;
        case 10:
            MonthName = 'October';
            break;
        case 11:
            MonthName = 'November';
            break;
        default:
            MonthName = 'December';
    }

    return MonthName;
}

function funOpenPopupforFooter(screenName) {
    if (screenName.toLowerCase() == "takeatour") {
        window.open('http://www.20thcenturyfox-tvd.com/sites/FoxFastGuides/Fox---Tours.html', screenName, 'width=880,height=600,status=no,location=no,scrollbars=yes,resizable=yes,top=100,left=100,dependent=yes,alwaysRaised=yes');
    }
    else if (screenName.toLowerCase() == "contact") {
        window.open('../aspxfiles/' + screenName + '.aspx', screenName, 'width=880,height=600,status=no,location=no,scrollbars=yes,resizable=yes,top=100,left=70,dependent=yes,alwaysRaised=yes');
    }
    else {
        window.open('../aspxfiles/' + screenName + '.aspx', screenName, 'width=800,height=600,status=no,location=no,scrollbars=yes,resizable=yes,top=100,left=100,dependent=yes,alwaysRaised=yes');
    }
}

function funGetOperatingSystem() {
    var OSType = "";
    var agt = navigator.userAgent.toLowerCase();
    if ((agt.indexOf("mac") != -1)) {
        OSType = "macintosh";
    }
    else {
        OSType = "windows";
    }
    return OSType;
}
function isSilverlightInstalled() {
    var isSilverlightInstalled = "N";
    try {
        if (Silverlight.isInstalled("4.0.50401.0")) {
            isSilverlightInstalled = "Y";
        }
    }
    catch (e) {
        //we don't want to leak exceptions. However, you may want
        //to add exception tracking code here.
    }
    return isSilverlightInstalled;
}

function funSetSpotlightObject() {
    var hdnspotlightXMLPath = "";
    var divSpotLight = window.document.getElementById("ctl00_ctl00_SpotLight1_divSpotLight");

    //    else
    //    {
    if (window.document.getElementById("ctl00_ctl00_SpotLight1_hdnspotlightXMLPath")) {
        hdnspotlightXMLPath = window.document.getElementById("ctl00_ctl00_SpotLight1_hdnspotlightXMLPath").value;
    }
    var hdnspotlightTemplate = "";
    if (window.document.getElementById("ctl00_ctl00_SpotLight1_hdnspotlightTemplate")) {
        hdnspotlightTemplate = document.getElementById("ctl00_ctl00_SpotLight1_hdnspotlightTemplate").value;
    }
    swfobject.embedSWF(
	        hdnspotlightTemplate, //"../spotlight/Spotlight_LimitOf7.swf", // path to swf
	        "spotlightGoesHere", // id of element to replace with swf
	        "990", // width
	        "307", // height
	        "9.0.0", // minimum flash version required
	        false,
	        { xmlFile: hdnspotlightXMLPath + "?nocache=" + getCurrentDateTime() }, // flashvars
	        {quality: "best", scale: "noscale", wmode: "transparent", bgcolor: "000000", allowfullscreen: "false" }, // params
	        {align: "middle", style: "margin-top: 10px;"} // attributes
        );
    if ($.browser.msie) {

        if (divSpotLight && divSpotLight.className == "toggler-promo closed") {
            if (window.document.getElementById("ctl00_ctl00_SpotLight1_spotlightPromo")) {
                window.document.getElementById("ctl00_ctl00_SpotLight1_spotlightPromo").innerHTML = '<a id="spotlightGoesHere" href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a>';
            }
        }
    }
}
function funLivestreamSpotlightObject() {
    var strFlashFileName = "";
    var strStreamCategory = document.getElementById("ctl00_ctl00_MainMenu1_hdnStreamCategory");
    var strStreamMessage = document.getElementById("ctl00_ctl00_MainMenu1_hdnStreamMessage");
    var strFailureFlag = document.getElementById("ctl00_ctl00_MainMenu1_hdnFailureFlag");
    if (strStreamCategory && strStreamCategory.value.toLowerCase() == "live") {
        strFlashFileName = "AkamaiFlashPlayer_Live.swf";
    }
    else if (strStreamCategory && strStreamCategory.value.toLowerCase() == "test") {
        strFlashFileName = "AkamaiFlashPlayer_Test.swf";
    }
    var hasReqestedVersion = DetectFlashVer(10, 0, 0); //DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
    if (hasReqestedVersion) {
        if (strFailureFlag && strFailureFlag.value.toLowerCase() == "n") {
            var flashvars = {
                src: "http://mediapm.edgesuite.net/ovp/content/demo/smil/elephants_dream.smil",
                autostart: "true",
                themeColor: "0395d3",
                mode: "sidebyside",
                scaleMode: "fit"
            };
            var params = { wmode: "transparent" };
            var attributes = {
                id: "myPlayer",
                name: "myPlayer",
                allowFullScreen: "true",
                align: "middle",
                style: "margin-top: 10px;"
            };
            swfobject.embedSWF("../spotlight/" + strFlashFileName, "spotlightGoesHere", "990", "307", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
            funBuildSoftwareUpdateAlterMsg(strStreamMessage.value, "OK")
            toggleVis('divSoftwareUpdateAlterMsg');
        }
        else {
            window.document.getElementById("imgSpotlightImage").src = "../images/LiveVideoFeed_Trouble.jpg";
        }
    }
}

function onSilverlightError(sender, args) {
    //    var appSource = "";
    //    if (sender != null && sender != 0) {
    //        appSource = sender.getHost().Source;
    //    }
    //    var errorType = args.ErrorType;
    //    var iErrorCode = args.ErrorCode;
    //    var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n";
    //    errMsg += "Code: " + iErrorCode + "    \n";
    //    errMsg += "Category: " + errorType + "       \n";
    //    errMsg += "Message: " + args.ErrorMessage + "     \n";
    //    if (errorType == "ParserError") {
    //        errMsg += "File: " + args.xamlFile + "     \n";
    //        errMsg += "Line: " + args.lineNumber + "     \n";
    //        errMsg += "Position: " + args.charPosition + "     \n";
    //    }
    //    else if (errorType == "RuntimeError") {
    //        if (args.lineNumber != 0) {
    //            errMsg += "Line: " + args.lineNumber + "     \n";
    //            errMsg += "Position: " + args.charPosition + "     \n";
    //        }
    //        errMsg += "MethodName: " + args.methodName + "     \n";
    //    }
    //    throw new Error(errMsg);
}
function funGetBrowserType() {
    var browser = navigator.appName;
    var b_version = navigator.appVersion;
    var version = parseFloat(b_version);
    return browser;
}

function funWaterMarkAlertMsg() {
    funBuildPswdPolicyAlterMsg("Sorry, the security on this protected video requires you to use the Internet Explorer browser on a PC for viewing in FoxFast.  Beginning July 2011, you may use other browsers and platforms to play our highly-secured video.", "OK")
    toggleVis('saveSearchDialog');
    //funBuildAlterMesg("This video is not designed to play in FireFox browser, please Login to FoxFast in Internet Explorer and try again.", "OK");
}

function funFoxRetailAlertMsg() {
    //funBuildPswdPolicyAlterMsg(strRetailMsg, "OK")
    funBuildPswdPolicyAlterMsg("We're sorry, secured copies of this video are not currently available.  Please try again in a few hours.  For additional assistance please contact <a href='mailto:FoxTVdigital@fox.com' target='_blank' style='color:white'>FoxTVdigital@fox.com</a>.", "OK");
    toggleVis('saveSearchDialog');  
}

function funPBTrends(TitleName, WprTitleId, TitleCat, Category, ViewType, AssetType, AssetFormatType, AssetName, FileName, FileSize) {
    if (AssetType != "") {
        AssetType = AssetType.replace(/&/g, "$@$");
    }
    TitleName = encodeURI(TitleName);
    ViewType = encodeURI(ViewType);
    AssetFormatType = encodeURI(AssetFormatType);

    var vardate = new Date();
    funGetHtmlFromJQuery("WebTrends.aspx", "TitleName=" + TitleName + "~" + vardate + "&WprTitleId=" + WprTitleId + "&TitleCat=" + TitleCat + "&Category=" + Category + "&ViewType=" + ViewType + "&AssetType=" + AssetType + "&AssetFormatType=" + AssetFormatType + "&AssetName=" + AssetName + "&FileName=" + FileName + "&FileSize=" + FileSize);
}
function funOpenLAScreenings(strEmail, strFirstName, strLastName) {
    window.open("http://www.20thcenturyfox-tvd.com/sites/lascreeningsInfo/index.asp?hdnemail=" + strEmail + "&hdnfname=" + strFirstName + "&hdnlname=" + strLastName, "LAScreenings", "menubar=1,width=800,height=600,status=yes,location=yes,scrollbars=yes,resizable=yes,top=100,left=100,toolbar=yes");
}
function funUnderConstruction() {
    window.alert("Under Construction");
}

function funSessionExpiryNav(strResult) {
    if (strResult && Trim(strResult) == "session expired") {
        window.location.href = "Login.aspx?sessionexpired=Y";
    }
}

function funSessionExpiryNavMSG() {
    funBuildAlterMsg("Your previous session has expired.  Please login to FoxFast again to continue using the site.", "OK");
    toggleVis('saveSearchDialog');
}

function funPrint() {
    var adRestrictDetailsWrapper = window.document.getElementById("adRestrictDetailsWrapper");
    var tblBtns = window.document.getElementById("tblBtns");
    var divclosebtn = window.document.getElementById("divclosebtn");
    if (window.print && adRestrictDetailsWrapper) {
        if (tblBtns && divclosebtn) {
            tblBtns.style.display = 'none';
            divclosebtn.style.display = 'none';
        }
        var WinPrint = window.open('', '', 'left=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');
        WinPrint.document.write(adRestrictDetailsWrapper.innerHTML);
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        WinPrint.close();

        if (tblBtns && divclosebtn) {
            tblBtns.style.display = '';
            divclosebtn.style.display = '';
        }
    }
    else {
        var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        WebBrowser1.ExecWB(6, 2); //Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
    }

    return false;
}

function funNavHomPageOnLogin(strInfo) {
    //Added by Anil on 03.03.2009 for getting system info for entrique functionality.                
    funGetSystemInfo();

    var strValues = strInfo.split('~');
    if (strValues[1] == "livestream") {
        // funViewLiveStream();
        NavAsPerUserPreferences(strInfo);
    }
    else if (strValues[1] == "BQAssetsY") {

        // Resetting the default page values.
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId")) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId").value = "sortID1";
        }
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo")) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = "1";
        }
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnNoofTitlesPerPage")) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnNoofTitlesPerPage").value = "25";

        }
        window.document.getElementById("hdnNavigationMode").value = "cart";
        window.document.forms[0].action = "BQAssetCart.aspx";
        window.document.forms[0].method = "post";
        window.document.forms[0].__VIEWSTATE.name = "";
        window.document.forms[0].submit();
        //        
        //        if (window.document.aspnetForm.ctl00_LogBodyContent_hdnMode.value == 'Screening_Room') {
        //            toggleVis('divProgressDialog');
        //            funNavScreeningRoom("All");
        //            //return;
        //        }
    }
    else {
        NavAsPerUserPreferences(strInfo);
    }
}

function Openpopup(url, width, height, name, ModalYN) {
    if (ModalYN == 'Y') {
        window.showModalDialog(url, "", "dialogWidth:500px;dialogHeight:500px;dialogLeft:220px;dialogTop:120;center:yes;status:no");
    }
    else {
        var left = (screen.width - width) / 2;
        var top = (screen.height - height) / 2;
        var params = 'width=' + width;
        params += ', height=' + height;
        params += ', directories=no';
        params += ', location=no';
        params += ', menubar=no';
        params += ', resizable=no';
        params += ', scrollbars=no';
        params += ', status=no';
        params += ', toolbar=no';
        params += ', top=' + top;
        params += ', left=' + left;

        newwin = window.open(url, name, params);
        if (window.focus) {
            newwin.focus();
        }
    }
    return false;
}

function toggleVideoLoadingMsg(displayType) {
    var el = document.getElementById('divVideoProgressDialog');
    if (displayType == 'none') {
        el.style.display = 'none';
    }
    else {
        el.style.display = '';
    }
}
function funKnowPlayerVersions() {
    var strMediaPlayerVersion = "";
    var OSType = funGetOperatingSystem();
    try {
        if (OSType.toLocaleLowerCase() == "macintosh" && !$.browser.mozilla) {
            if ($("#QTPlayer>#QTBody")) {
                $("#QTPlayer>#QTBody").html("");
            }
            funBuildSoftwareUpdateAlterMsg("<br /><label style='font-weight:bold;color:#F89602;width:600px;padding-left:190px;'>Software&nbsp;Upgrade&nbsp;Required</label><br /><br />We're sorry, to play FoxFast's secure video on a MAC computer you must be using Firefox browser software.  Please download and install Firefox by clicking <a href='http://www.firefox.com' target='_blank' style='color:White'>here</a>.<br /><br />Please contact your company's IT Administration if you have any difficulty with the Firefox browser software installation.", "OK")
            toggleVis('divSoftwareUpdateAlterMsg');
            return false;
        }
        else if ($.browser.msie) {
            strMediaPlayerVersion = printResults();
            if (strMediaPlayerVersion != "" && parseInt(strMediaPlayerVersion) < 11) {
                if ($("#QTPlayer>#QTBody")) {
                    $("#QTPlayer>#QTBody").html("");
                }
                funBuildSoftwareUpdateAlterMsg("<br /><label style='font-weight:bold;color:#F89602;width:600px;padding-left:190px;'>Software&nbsp;Upgrade&nbsp;Required</label><br /><br />We're sorry, to play FoxFast's secure video you must upgrade your Windows Media Player software to version 11 or above.  Please download and install Windows Media Player version 11 by clicking <a href='http://www.microsoft.com/windows/windowsmedia/player/11/default.aspx' target='_blank' style='color:White'>here</a>.<br /><br />Please contact your company's IT Administration if you have any difficulty with the Windows Media Player software installation.", "OK")
                toggleVis('divSoftwareUpdateAlterMsg');
                return false;
            }
            else {
                return true;
            }
        }
        else {
            return true;
        }
    }
    catch (e) {
        return true;
    }
}
function funBuildPswdPolicyAlterMsg(Msg, txtOk) {
    window.document.getElementById("saveSearchDialog").innerHTML = "<div class='top'></div>" +
        "<div class='body'>" +
            "<div class='modalClose'><a href='javascript:void(0);' onclick='toggleVis(\"saveSearchDialog\");'><img src='../images/close.gif' border='0' /></a></div>" +
            "<div class='modalContent'>" +
    //<!-- put prompt text within p tags -->
                "<table><tr><td><p>" +
                Msg + //"Save new title search as:"+
                "</p></td></tr></table>" +
    //<!-- using close link here again to cancel out of the dialog -->
                "<a href='javascript:void(0);' onclick='toggleVis(\"saveSearchDialog\");' class='affirmative'>" + txtOk + "</a>" +
            "</div>" +
        "</div>" +
      "<div class='bot'></div>";
}

function funBuildSoftwareUpdateAlterMsg(Msg, txtOk) {
    window.document.getElementById("divSoftwareUpdateAlterMsg").innerHTML = "<div class='topwider' ></div>" +
        "<div class='bodywider'>" +
            "<div class='modalClose'><a href='javascript:void(0);' onclick='toggleVis(\"divSoftwareUpdateAlterMsg\");'><img src='../images/close.gif' border='0' /></a></div>" +
            "<div class='modalContent' >" +
    //<!-- put prompt text within p tags -->
                "<table><tr><td><p>" +
                Msg + //"Save new title search as:"+
                "</p></td></tr></table>" +
    //<!-- using close link here again to cancel out of the dialog -->
                "<a href='javascript:void(0);' onclick='toggleVis(\"divSoftwareUpdateAlterMsg\");' class='affirmative'>" + txtOk + "</a>" +
            "</div>" +
        "</div>" +
      "<div class='botwider'></div>";

}
function funEditBaySeasonPass(strTitObjObjId, strSeasonName) {
    if ($("#divEditBaySeasonPass")[0].className == "editBaySeasonPass_on") {
        funBuildConfirmationMsg("Click OK to remove a Edit Bay Season Subscription for '" + funReplaceWithActualChar(strSeasonName) + "'.", "OK", "Cancel", "funEditBaySeasonPass2(\"" + strTitObjObjId + "\",\"" + strSeasonName + "\")");
        toggleVis('saveSearchDialog');
    }
    else {
        funBuildConfirmationMsg("Click OK to add a Edit Bay Season Subscription for '" + funReplaceWithActualChar(strSeasonName) + "'.", "OK", "Cancel", "funEditBaySeasonPass1(\"" + strTitObjObjId + "\",\"" + strSeasonName + "\")");
        toggleVis('saveSearchDialog');
    }
}
function funEditBaySeasonPass1(strTitObjObjId, strSeasonName) {
    toggleVis('saveSearchDialog');
    var vardate = new Date();
    var strResult;
    var lblAssetsinEditBay = window.document.getElementById("ctl00_ctl00_MainMenu1_lblAssetsinEditBay");
    strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TitleId=" + strTitObjObjId + "~@$~" + vardate + "&Mode=ineditbay&Type=inserteditbayseasonpass");
    if (lblAssetsinEditBay != null && strResult != null && strResult.toLowerCase() != "session expired") {
        var strEditBayCount = Trim(strResult);
        lblAssetsinEditBay.innerHTML = strEditBayCount + " Edit Bay";
        $("#divEditBaySeasonPass").removeClass('editBaySeasonPass_on');
        $("#divEditBaySeasonPass").removeClass('editBaySeasonPass_off');
        $("#divEditBaySeasonPass").addClass('editBaySeasonPass_on');
        funSessionExpiryNav(strResult);
    }
}
function funEditBaySeasonPass2(strTitObjObjId, strSeasonName) {
    toggleVis('saveSearchDialog');
    var vardate = new Date();
    var strResult;
    var lblAssetsinEditBay = window.document.getElementById("ctl00_ctl00_MainMenu1_lblAssetsinEditBay");
    strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TitleId=" + strTitObjObjId + "~@$~" + vardate + "&Mode=deleditbay&Type=deleteeditbayseasonpass");
    if (lblAssetsinEditBay != null && strResult != null && strResult.toLowerCase() != "session expired") {
        var strEditBayCount = Trim(strResult);
        lblAssetsinEditBay.innerHTML = strEditBayCount + " Edit Bay";
        $("#divEditBaySeasonPass").removeClass('editBaySeasonPass_off');
        $("#divEditBaySeasonPass").removeClass('editBaySeasonPass_on');
        $("#divEditBaySeasonPass").addClass('editBaySeasonPass_off');
        funSessionExpiryNav(strResult);
    }
}
function funSetSeasonPass(strTitObjObjId, strSeasonName, hasSeasonPassYN) {
    if (hasSeasonPassYN == "Y") {
        funBuildAlterMsg("You already have a Season Pass for '" + funReplaceWithActualChar(strSeasonName) + "'.  Please visit the User Preferences page if you would like to cancel this Season Pass", "OK");
        toggleVis('saveSearchDialog');
    }
    else {
        funBuildConfirmationMsg("Click OK to add a Season Pass for '" + funReplaceWithActualChar(strSeasonName) + "'.", "OK", "Cancel", "funSetSeasonPass1(\"" + strTitObjObjId + "\",\"" + strSeasonName + "\")");
        toggleVis('saveSearchDialog');
    }
}
function funSetSeasonPass1(strTitObjObjId, strSeasonName) {
    toggleVis('saveSearchDialog');
    //    $("#divEditBaySeasonPass").removeClass('editBaySeasonPass_on');
    //    $("#divEditBaySeasonPass").removeClass('editBaySeasonPass_off');
    //    $("#divEditBaySeasonPass").addClass('editBaySeasonPass_on');
    var vardate = new Date();
    var strResult;
    strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "TitleId=" + strTitObjObjId + "~@$~" + vardate + "&Mode=foxfast&Type=insertseasonpass");
    if (Trim(strResult) == "Record Already Exists") {
        toggleVis('saveSearchDialog');
        funBuildAlterMsg("You already have a Season Pass for '" + funReplaceWithActualChar(strSeasonName) + "'.  Please visit the User Preferences page if you would like to cancel this Season Pass", "OK");
    }
    else {
        funSessionExpiryNav(strResult);
    }
}
function S4() {
    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}
function guid() {
    return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}
function funDirectVideoPlayLogin() {
    funBuildAlterMsg("Please login to FoxFast.  Your video will begin playing after your successful login.", "OK")
    toggleVis('saveSearchDialog');
}
function funDirectVideoLivestreamLogin() {
    funBuildAlterMsg("Please login to FoxFast.  Your live stream will begin playing after your successful login.", "OK")
    toggleVis('saveSearchDialog');
}
function funDirectEditbayLogin() {
    funBuildAlterMsg("Please login to FoxFast.  Your Edit Bay session will begin following your successful login.", "OK")
    toggleVis('saveSearchDialog');
}

function funChangePwdRedirect(Msg, NavPage) {
    if (NavPage == "home") {
        funBuildAlterMsgWithAction(Msg, "OK", "funNavToHome()");
    }
    else if (NavPage == "bqhome") {
        funBuildAlterMsgWithAction(Msg, "OK", "funNavToBQHome()");
    }
    else {
        funBuildAlterMsgWithAction(Msg, "OK", "funNavToScreeningRoomVideoPlay()");
    }
    toggleVis('saveSearchDialog');
}
function funNavToScreeningRoomVideoPlay() {
    window.document.forms[0].action = "NewScreeningRoom.aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
    return false;
}
function funNavToBQHome() {
    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
    var strResult = funLeftFilter_SessionMemberPreference_Update('MP~Y');
    funNavHomPageOnLogin(strResult);

    return false;
}
function funNavToHome() {
    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
    var strResult = funLeftFilter_SessionMemberPreference_Update('MP~N');
    funNavHomPageOnLogin(strResult);
    return false;
}

function getCurrentDateTime() {
    var d = new Date();
    return d.getMonth() + "_" + d.getDate() + "_" + d.getFullYear() + "_" + d.getHours() + "_" + d.getMinutes() + "_" + d.getSeconds();
}
function funReplaceWithActualChar(strText) {
    return strText.replace(/~@@~/g, "'").replace(/@@@/g, "\"").replace(/\$@\$/g, "&");
}
function funReplaceRequestFormsWithActualChar(strText) {
    return strText.replace(/\$@/g, "'").replace(/@@@/g, "\"").replace(/\$\*\$/g, "&");
}

function funViewLiveStream() {
    var strEmailVideoLink = "N";
    if (window.document.getElementById("ctl00_ctl00_hdnLiveStreamMode")) {
        window.document.getElementById("ctl00_ctl00_hdnLiveStreamMode").value = "Y";
        var strEmailVideoLink = "Y";
    }
    funPBTrendsForLiveVideo(strEmailVideoLink);
    strleft = (screen.width - 696) / 2;
    strtop = (screen.height - 400) / 2;

    window.open('../aspxfiles/Livestream.aspx', 'PlayLiveStream', 'toolbar=no,scrollbars=no,location=no,resizable=no,menubar=no,height=532,top=' + strtop + ',left=' + strleft + ',dependent=yes,alwaysRaised=yes,width=882');

    // funNavScreeningRoom('All');
}
function funViewLiveStream1() {
    var strEmailVideoLink = "N";
    if (window.document.getElementById("ctl00_ctl00_hdnLiveStreamMode")) {
        window.document.getElementById("ctl00_ctl00_hdnLiveStreamMode").value = "Y";
        strEmailVideoLink = "Y";
    }
    funPBTrendsForLiveVideo(strEmailVideoLink);
    strleft = (screen.width - 696) / 2;
    strtop = (screen.height - 400) / 2;

    window.open('../aspxfiles/Livestream.aspx', 'PlayLiveStream', 'toolbar=no,scrollbars=no,location=no,resizable=no,menubar=no,height=532,top=' + strtop + ',left=' + strleft + ',dependent=yes,alwaysRaised=yes,width=882');

    // funNavScreeningRoom('All');
}

function funShowLiveBroadCastMessage() {
    funBuildAlterMsg("Thank you for your interest in watching the FBC Upfront Presentation.  Unfortunately, we are no longer streaming this video.", "OK");
    toggleVis('saveSearchDialog');
}





// Flash Player Version Detection - Starts Here.  
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion() {
    var version;
    var axo;
    var e;

    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

    try {
        // version will be set for 7.X or greater players
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    } catch (e) {
    }

    if (!version) {
        try {
            // version will be set for 6.X players only
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

            // installed player is some revision of 6.0
            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so we have to be careful. 

            // default to the first public version
            version = "WIN 6,0,21,0";

            // throws if AllowScripAccess does not exist (introduced in 6.0r47)		
            axo.AllowScriptAccess = "always";

            // safe to call for 6.0r47 or greater
            version = axo.GetVariable("$version");

        } catch (e) {
        }
    }

    if (!version) {
        try {
            // version will be set for 4.X or 5.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }

    if (!version) {
        try {
            // version will be set for 3.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }

    if (!version) {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }

    return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer() {
    // NS/Opera version >= 3 check for Flash plugin in plugin array
    var flashVer = -1;

    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                versionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    }
    // MSN/WebTV 2.6 supports Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 supports Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    // older WebTV supports Flash 2
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    else if (isIE && isWin && !isOpera) {
        flashVer = ControlVersion();
    }
    return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
    versionStr = GetSwfVer();
    if (versionStr == -1) {
        return false;
    } else if (versionStr != 0) {
        if (isIE && isWin && !isOpera) {
            // Given "WIN 2,0,0,11"
            tempArray = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
            tempString = tempArray[1]; 		// "2,0,0,11"
            versionArray = tempString.split(","); // ['2', '0', '0', '11']
        } else {
            versionArray = versionStr.split(".");
        }
        var versionMajor = versionArray[0];
        var versionMinor = versionArray[1];
        var versionRevision = versionArray[2];

        // is the major.revision >= requested major.revision AND the minor version >= requested minor
        if (versionMajor > parseFloat(reqMajorVer)) {
            return true;
        } else if (versionMajor == parseFloat(reqMajorVer)) {
            if (versionMinor > parseFloat(reqMinorVer))
                return true;
            else if (versionMinor == parseFloat(reqMinorVer)) {
                if (versionRevision >= parseFloat(reqRevision))
                    return true;
            }
        }
        return false;
    }
}
// Flash Player Version Detection - Ends Here.
function funPBTrendsForLiveVideo(strLiveVideoEmailLinkClickYN) {
    var Category = window.document.getElementById("ctl00_ctl00_MainMenu1_hdnStreamCategory").value; ;
    /*if (strLiveVideoEmailLinkClickYN.toLowerCase() == "y") {
    Category = "Access From Email Link";
    }*/
    var version = GetSwfVer();
    var ViewType = "Play - Live Stream - (Flash Player" + ((version != "") ? " : " + version : "") + ")";
    funPBTrends("", "", "", Category, ViewType, "", "", "", "", "");
}
function funShowEditBay(srMemberId, strQueueItemId) {
    try {
        funPBTrends("", "", "", "", "open - editbay", "", "", "", "", "");
    }
    catch (e) {
    }
    if (window.document.getElementById("objSildiv")) {
        var screenwidth = screen.width - 40 + "px";
        var screenheight = screen.height - 210 + "px";
        var agt = navigator.userAgent.toLowerCase();
        if ((agt.indexOf("mac") != -1)) {
            screenwidth = screen.width - 40 + "px";
            screenheight = screen.height - 270 + "px";
            $("#divEditBay").css({ 'width': (screen.width - 30) + 'px' });
            $("#divEditBay").css({ 'height': (screen.height - 260) + 'px' });
        }
        else {
            $("#divEditBay").css({ 'width': (screen.width - 30) + 'px' });
            $("#divEditBay").css({ 'height': (screen.height - 200) + 'px' });
        }

        window.document.getElementById("objSildiv").innerHTML = "";
        window.document.getElementById("ctl00_ctl00_MainMenu1_hdnEditBayMode").value = "editbay";
        window.document.getElementById("objSildiv").innerHTML = "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='" + screenwidth + "' height='" + screenheight + "'>" +
            "<param name='source' value='../ClientBin/EditBayTool.xap' />" +
            "<param name='initparams' value='MemberId=" + srMemberId + ",sUserName=lGzn/j+ujpCghzRypHvW2w==,sPassword=V0d+g0WQ/M35W6wtD7lIUA==,QueueItemId=" + strQueueItemId + "' />" +
            "<param name='onError' value='onSilverlightError' />" +
            "<param name='background' value='white' />" +
            "<param name='minRuntimeVersion' value='4.0.50401.0' />" +
            "<param name='autoUpgrade' value='true' />" +
            "<param name='windowless' value='true' />" +    
            "<a href='http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0' style='text-decoration: none'>" +
                "<img src='http://go.microsoft.com/fwlink/?LinkId=161376' alt='Get Microsoft Silverlight' style='border-style: none' />" +
            "</a>"
        "</object>";
    }
    var bhvPopupCntrExt = $find("bhvEditBayExtender");
    if (bhvPopupCntrExt != null) {
        bhvPopupCntrExt.show();
    }
    else {
        var EditBaytimer = "";
        clearTimeout(EditBaytimer);
        EditBaytimer = window.setTimeout("openShareEditBay()", 3000);
    }
}
function openShareEditBay() {
    var bhvPopupCntrExt = $find("bhvEditBayExtender");
    if (bhvPopupCntrExt != null) {
        bhvPopupCntrExt.show();
    }
}
function funShowEditbayMessage() {
    funBuildAlterMsg("Thank you for your interest in Edit Bay, Please contact the FoxFast.com administrator.", "OK");
    toggleVis('saveSearchDialog');
}
function funEditBayClose() {
    var bhvPopupCntrExt = $find("bhvEditBayExtender");
    bhvPopupCntrExt.hide();
}
function funAddCustomers() {
    window.open("../aspxfiles/TVDLicenseCustomers.aspx", "Customers", "width=820,height=600,status=no,location=no,scrollbars=no,resizable=no,top=100,left=100,dependent=yes,alwaysRaised=yes", "");
}
function funCheckDate(obj) {
    var strDate = obj.value;
    var DateFormat = "DD-MMM-YYYY";
    var blnValidDate = true;
    if (strDate.length > 0) {
        blnValidDate = CheckValid(strDate, DateFormat)
        if (blnValidDate == false) {
            if (isLetter(strDate.charAt(0)) || isLetter(strDate.charAt(3))) {
                blnValidDate = CheckValid(strDate, DateFormat)
            }
            if (blnValidDate == false) {
                window.alert("Enter Date in Valid Format : " + DateFormat);
                obj.value = '';
                obj.focus();
                return false;
            }
        }
    }
}
function funDatePopUp(objId) {
    var obj = window.document.getElementById(objId);
    DatePopup(obj, 'dd-MMM-yyyy');
}

function funCheckUnCheckTVDLicTitles(obj, TitleId) {
    if (obj.checked == true) {
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value.indexOf(TitleId) < 0) {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value += TitleId + ",";
        }
    }
    else {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value.replace(TitleId + ",", "");
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value.replace(TitleId, "");
    }
}
function funRemoveSelectedAllLicTitles(obj) {
    var hdnDelLicTitleIds = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds");
    if (obj.checked == true) {
        var obj1 = new Array();
        var intCount;
        obj1 = window.document.getElementsByName("chkSelectLicTitles");
        hdnDelLicTitleIds.value = "";
        for (intCount = 0; intCount < obj1.length; intCount++) {
            hdnDelLicTitleIds.value = hdnDelLicTitleIds.value + obj1[intCount].value + ",";
            obj1[intCount].checked = true;
        }
    }
    else {
        hdnDelLicTitleIds.value = "";
        var obj1 = new Array();
        var intCount;
        obj1 = window.document.getElementsByName("chkSelectLicTitles");
        for (intCount = 0; intCount < obj1.length; intCount++) {
            obj1[intCount].checked = false;
        }
    }
}
function funDeleteLicTitles() {
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value != "") {
        window.document.getElementById("hdnLicTitlesMode").value = "delete";
        window.document.forms[0].action = "#";
        window.document.forms[0].__VIEWSTATE.name = "";
        window.document.forms[0].submit();
    }
    else {
        funBuildAlterMsg("Please select at least one title to delete.", "OK");
        toggleVis('saveSearchDialog');
    }
}

function funApplyEffective() {
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value == "") {
        funBuildAlterMsg("Please use checkboxes to select title(s) that batch population will be applied to.", "OK");
        toggleVis('saveSearchDialog');
    }
    else if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtEffectiveDate").value == "" && window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtExpiryDate").value == "") {
        funBuildAlterMsg("Please enter Effective and Expiration dates", "OK");
        toggleVis('saveSearchDialog');
    }
    else {
        var obj1 = new Array();
        var intCount;
        obj1 = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value.split(',');
        for (intCount = 0; intCount < obj1.length; intCount++) {
            if (window.document.getElementById("txtLicEffectiveDate_" + obj1[intCount].toLowerCase())) {
                window.document.getElementById("txtLicEffectiveDate_" + obj1[intCount].toLowerCase()).value = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtEffectiveDate").value;
            }
        }
        for (intCount = 0; intCount < obj1.length; intCount++) {
            if (window.document.getElementById("txtLicExpiryDate_" + obj1[intCount].toLowerCase())) {
                window.document.getElementById("txtLicExpiryDate_" + obj1[intCount].toLowerCase()).value = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtExpiryDate").value;
            }
        }
    }
}
function funAddNewLicCustomer(obj) {
    var hdnTVDLicCustomerId = window.document.getElementById("hdnTVDLicCustomerId");
    if (hdnTVDLicCustomerId.value == "") {
        funBuildAlterMsg("Please select at least one customer.", "OK");
        toggleVis('saveSearchDialog');
    }
    else {
        var vardate = new Date();
        var strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "date=" + vardate + "&CusDetails=" + escape(Trim(hdnTVDLicCustomerId.value)) + "&Type=tvdnewcustomerreq");
        window.opener.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCustomerDetails").value = funReplaceRequestFormsWithActualChar(hdnTVDLicCustomerId.value);
        window.opener.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_divLicCustomer").innerHTML = funReplaceRequestFormsWithActualChar(strResult);
        obj.close();
    }
}
function funSubmitLicCustomerTitles() {
    var obj1 = new Array();
    var intCount;
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnLicTitleIds").value == "") {
        funBuildAlterMsg("License Request can not be submitted with out a title. Please start the new request by selecting title(s) from the Title Cart.", "OK");
        toggleVis('saveSearchDialog');
        return false;
    }
    obj1 = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnLicTitleIds").value.split(',');
    for (intCount = 0; intCount < obj1.length; intCount++) {
        if (window.document.getElementById("txtLicEffectiveDate_" + obj1[intCount].toLowerCase()) && window.document.getElementById("txtLicEffectiveDate_" + obj1[intCount].toLowerCase()).value == "") {
            funBuildAlterMsg("Please fill Effective and Expiration dates for each of the titles above.", "OK");
            toggleVis('saveSearchDialog');
            return false;
        }
    }
    for (intCount = 0; intCount < obj1.length; intCount++) {
        if (window.document.getElementById("txtLicExpiryDate_" + obj1[intCount].toLowerCase()) && window.document.getElementById("txtLicExpiryDate_" + obj1[intCount].toLowerCase()).value == "") {
            funBuildAlterMsg("Please fill Effective and Expiration dates for each of the titles above.", "OK");
            toggleVis('saveSearchDialog');
            return false;
        }
    }
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCustomerDetails").value == "") {
        funBuildAlterMsg("Please select the Customer", "OK");
        toggleVis('saveSearchDialog');
        return false;
    }
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDelLicTitleIds").value = "";
    window.document.getElementById("hdnLicTitlesMode").value = "submit";
    window.document.forms[0].action = "#";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
    return true;
}
function funTVDLicenseCustomerSearch() {
    if (window.document.getElementById("hdnTVDLicCustomersMode") != null) {
        window.document.getElementById("hdnTVDLicCustomersMode").value = "search";
    }
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}
function funTVDLicenseCustomerReset() {
    if (window.document.getElementById("hdnTVDLicCustomersMode")) {
        window.document.getElementById("hdnTVDLicCustomersMode").value = "reset";
    }
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}
function funTVDLicenseCustomerCancel() {
    window.document.close();
}
function funCheckDate(obj, mode) {
    var strDate = obj.value;
    var DateFormat = "DD-MMM-YYYY";
    var blnValidDate = true;
    if (strDate.length > 0) {
        blnValidDate = CheckValid(strDate, DateFormat)
        if (blnValidDate == false) {
            if (isLetter(strDate.charAt(0)) || isLetter(strDate.charAt(3))) {
                blnValidDate = CheckValid(strDate, DateFormat)
            }
            if (blnValidDate == false) {
                //                    window.alert("Enter Date in Valid Format : " + DateFormat);
                //                    obj.value = '';
                //                    obj.focus();
                //                    return false;
                funBuildAlterMsg("Enter Date in Valid Format : " + DateFormat, "OK");
                toggleVis('saveSearchDialog');
                obj.value = "";
                obj.focus();
                return false;
            }
        }
    }
    if (mode == "start") {
        var enddateid = obj.id;
        enddateid = enddateid.replace("EffectiveDate", "ExpiryDate");
        if (window.document.getElementById(enddateid) && window.document.getElementById(enddateid).value != "") {
            var startdate = obj.value;
            var enddate = window.document.getElementById(enddateid).value;
            var IntDateDifference = CompareDatesDiff(startdate, enddate, DateFormat);
            if (IntDateDifference == 3) {
                funBuildAlterMsg("Effective date should be Less than or Equal to the given Expiration date", "OK");
                toggleVis('saveSearchDialog');
                obj.value = '';
                obj.focus();
                return false;
            }
        }
    }
    if (mode == "end") {
        var startdateid = obj.id;
        startdateid = startdateid.replace("ExpiryDate", "EffectiveDate");
        if (window.document.getElementById(startdateid) && window.document.getElementById(startdateid).value != "") {
            var startdate = window.document.getElementById(startdateid).value;
            var enddate = obj.value;

            var IntDateDifference = CompareDatesDiff(startdate, enddate, DateFormat);
            if (IntDateDifference == 3) {
                funBuildAlterMsg("Expiration date should be Greater than or Equal to the given Effective date", "OK");
                toggleVis('saveSearchDialog');
                obj.value = "";
                obj.focus();
                //return false;
            }
        }
    }
}

function funtextLimit(maxlen) {
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtComments")) {
        var field = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtComments");
        if (field.value.length > maxlen + 1) {
            funBuildAlterMsg("your input exceeds  " + maxlen + " characters", "OK");
            toggleVis('saveSearchDialog');
            if (field.value.length > maxlen)
                field.value = field.value.substring(0, maxlen);
        }
    }
}
function funNewUsertextLimit(maxlen) {
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtNewUserComments")) {
        var field = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtNewUserComments");
        if (field.value.length > maxlen + 1) {
            funBuildAlterMsg("your input exceeds  " + maxlen + " characters", "OK");
            toggleVis('saveSearchDialog');
            if (field.value.length > maxlen)
                field.value = field.value.substring(0, maxlen);
        }
    }
}
function funEnterKeyPressTVDSearch(e) {
    if (navigator.appName.indexOf("Netscape") > (-1)) {
        if (e.keyCode == 13) {
            funTVDLicenseCustomerSearch();
        }
    }
    if (navigator.appName.indexOf("Microsoft Internet Explorer") > (-1)) {
        if (event.keyCode == 13) {
            funTVDLicenseCustomerSearch();
        }
    }
}

function funEnterKeyPressUserSearch(e) {
    if (navigator.appName.indexOf("Netscape") > (-1)) {
        if (e.keyCode == 13) {
            funLicenseUserSearch();
        }
    }
    if (navigator.appName.indexOf("Microsoft Internet Explorer") > (-1)) {
        if (event.keyCode == 13) {
            funLicenseUserSearch();
        }
    }
}
function funRequestFormsRedirect(Msg, NavPage) {
    if (NavPage == "titlecart") {
        funBuildAlterMsgWithAction(Msg, "OK", "funRequestFormsSubmitNav(\"TitleCart\")");
    }
    else if (NavPage == "assetcart") {
        funBuildAlterMsgWithAction(Msg, "OK", "funRequestFormsSubmitNav(\"AssetCart\")");
    }
    else {
        funBuildAlterMsgWithAction(Msg, "OK", "funRequestFormsSubmitNav(\"\")");
    }
    toggleVis('saveSearchDialog');
}
function funRequestFormsSubmitNav(NavPage) {
    toggleVis('saveSearchDialog');
    if (NavPage == "TitleCart") {
        funNavToTitleAssetCartScreen("TitleCart");
    }
    else if (NavPage == "AssetCart") {
        funNavToTitleAssetCartScreen("AssetCart");
    }
    else {
        funFoxFastHomeClick();
    }
}


/******************************************************************************
DESCRIPTION: To Show Model Popup Extenders.
******************************************************************************/
function funPopupShow(src) {
    var frm = document.getElementById('ctl00_ctl00_ifrmPopup')
    frm.src = src;
    var obj = $find('ctl00_ctl00_mpePopup');
    if (obj) {      
        obj.show();
    }
    // return false;
}

/******************************************************************************
DESCRIPTION: To Close Model Popup Extenders.
******************************************************************************/
function funPopupClose() {
    window.parent.document.getElementById('ctl00_ctl00_ifrmPopup').src = "";
    var objF = window.parent.$find('ctl00_ctl00_mpePopup');
    objF.hide();
    return false;
}
