﻿/*On Click of SmalThumbNal Navigating to the TitleDetilsHome page.*/
function funNavToListDetaisHome(strTitleId)
{
     // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
    var TitleSearchMode = "";
    var TitleSearchText = "";
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchMode")) 
    {
        TitleSearchMode = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchMode").value;
    }
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchText")) 
    {
        TitleSearchText = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchText").value;
    }
    var hdnCategoryLinkId = window.document.getElementById('ctl00_ctl00_BodyContent_SubBodyContent_hdnCategoryLinkId');
    if(hdnCategoryLinkId && hdnCategoryLinkId.value != "")
    {
        window.location.href = "TitleDetailsHome.aspx?TitleId=" + strTitleId+ "&Type=CL~"+hdnCategoryLinkId.value;
    }
    else if (TitleSearchMode != "")
    {
        window.location.href ="TitleDetailsHome.aspx?TitleId=" + strTitleId + "&Type=SR&TtlSrchMode="+TitleSearchMode+"&TtlSrchTxt="+TitleSearchText;           
    }
    else
    {
        window.location.href = "TitleDetailsHome.aspx?TitleId=" + strTitleId;
    }    
    return false;
}
//Used in the Implementation of BreadCrumb (Type = ListSR) and (Type = SR)
function funNavToTtlDetailsHome(strTitleId)
{
    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
    var hdnPageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
    var TitleSearchMode = "";
    var TitleSearchText = "";
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchMode"))
    {
        TitleSearchMode = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchMode").value;
    }
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchText"))
    {
        TitleSearchText = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchText").value;
    }
    var hdnCategoryLinkId = window.document.getElementById('ctl00_ctl00_BodyContent_SubBodyContent_hdnCategoryLinkId');
    if ((hdnPageName && (hdnPageName.value == "SearchResults" || hdnPageName.value == "titledetailshome")) || TitleSearchMode != "")
    {
        window.location.href ="TitleDetailsHome.aspx?TitleId=" + strTitleId + "&Type=SR&TtlSrchMode="+TitleSearchMode+"&TtlSrchTxt="+TitleSearchText;
    }
    else if (hdnCategoryLinkId && hdnCategoryLinkId.value != "") 
    {
        window.location.href = "TitleDetailsHome.aspx?TitleId=" + strTitleId + "&Type=CL~" + hdnCategoryLinkId.value;
    }
    else
    {
        window.location.href = "TitleDetailsHome.aspx?TitleId=" + strTitleId + "&Type=ListSR";
    }   
    return false;
}
function funNavToTtlDetailsHomeForTitlelink(strTitleId, querystring)
{
    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
    var hdnPageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
   
    window.location.href = "TitleDetailsHome.aspx?TitleId=" + strTitleId + querystring;
}
/*On Click of AddAllTitleToCart Hyperlink doing asyncronous postback to the TitleDetils page.*/
function funAddAllTittoCart()
{
    var hdnPageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
    if(hdnPageName && hdnPageName.value == "SearchResults")
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAddAllTittoCart").value = "addall";
    }
    else
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAddAllTittoCart").value = "Add";
    }
    
    // Doing Asyncronous PostBack for the TitleList Page.
    
    window.document.forms[0].__VIEWSTATE.name= "";
    window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain","");
} 

function funGetTitleChilds(strTitleId)
{
    var pageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleDetailsForCast") != null)
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleDetailsForCast").value = "";
    }
   
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild").value = "C~" + strTitleId;
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = "1"; 
    if(window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu"))
    {
        window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "All";
    }
    if(pageName.value == "SearchResults")
    {
        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
    {
        window.scrollTo(0,0);  
        funTitleListAsyncronouPostBack('N');
    }
}

function funGetTitleParents(strTitleId)
{
    
    var pageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
    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_MainMenu1_hdnTitleMenu"))
    {
        window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "All";
    }
    
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild").value = "P~" + strTitleId;
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = "1";   
    if(pageName.value == "SearchResults")
    {
        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
    {
        window.scrollTo(0,0);  
        funTitleListAsyncronouPostBack('N');
    }   
}


function funSetChildHtml(obj)
{
    var sortBy = "A-Z";
    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId").value == "sortID2")
    {
        sortBy = "Release Date";
    }
    else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId").value == "sortID3")
    {
        sortBy = "DateAddedUpdated";
    }
    
    var ulelement = document.getElementById('ul_'+obj.id);
    if(obj.className.indexOf("parent collapsable") > -1)
    {
        if(Trim(ulelement.innerHTML) == "")
        {
            var vardate = new Date();
            var strResult =  funGetHtmlFromJQuery("Xmlhttp.aspx","TitleObjOjbId="+ obj.id + "~@$~"+ vardate + "&sortBy="+sortBy+"&Type=buildtextviewchilddetails");
            
            ulelement.innerHTML = Trim(strResult);
            funSetHoverforTitles1();
           
            //Added by Anil on 06.Jann For Video Box dialog.
            funSetVideoBoxDialog();
        }
    }
    else
    {
        ulelement.innerHTML = "";
    }
    
}

function funNavToTitleAssetCartScreen(pageName)
{
    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
    
    // Added by Sami: For Default TextView Option for Title/Asset Cart. -- by kalyan on 14-APR-2009.
    // Commented by Sami : the above functionality is now handled by using hidden variable.
    var vardate = new Date();
    var strResult = '';
    if(pageName == "TitleCart") {
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName") && window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName").value == "TitleDetailsList") {
            funGetHtmlFromJQuery("Xmlhttp.aspx", "Date=" + vardate + "&Type=updatebreadcrumbinfointitlecartmode");
        }
        else {
            funGetHtmlFromJQuery("Xmlhttp.aspx", "Date=" + vardate + "&Type=updatebreadcrumbinfointitlecart");
        }
        //strResult =  funGetHtmlFromJQuery("Xmlhttp.aspx","Option=viewID3~"+ vardate + "&Type=userprefupdate"); 
        funLeftFilter_SessionMemberPreference_Update('All');
    }
    if (pageName == "AssetCart") {
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName") && window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName").value == "TitleDetailsList") {
            funGetHtmlFromJQuery("Xmlhttp.aspx", "Date=" + vardate + "&Type=updatebreadcrumbinfoinassetcartmode");
        }
        else {
            funGetHtmlFromJQuery("Xmlhttp.aspx", "Date=" + vardate + "&Type=updatebreadcrumbinfoinassetcart");
        }
    }
    if (pageName == "BQAssetCart") {
        if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName") && window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName").value == "TitleDetailsList") {
            funGetHtmlFromJQuery("Xmlhttp.aspx", "Date=" + vardate + "&Type=updatebreadcrumbinfoinbqassetcartmode");
        }
        else {
            funGetHtmlFromJQuery("Xmlhttp.aspx", "Date=" + vardate + "&Type=updatebreadcrumbinfoinbqassetcart");
        }

        // Added by Sami: For Default A-Z Sort Option for BQAsset Cart.
        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_CartControls1_hdnCartCheckAll"))
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_CartControls1_hdnCartCheckAll").value = "Y"
    }
    // Added on 27-July-2009: By Sami: For Isue: When navigating to ‘Title Cart’ from any title list page other than the first page, titles already in cart are not displayed.
    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo"))
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = "1";
    }
    //Ends.
    //Conditions to maintain default check all condition when navigated to asset cart or bq asset cart from the top cart links
    //***************************************************************************************************//
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAssetCartCatIds")) {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAssetCartCatIds").value = "cartcat";
    }
    if (window.document.getElementById("ctl00_ctl00_BodyContent_CartControls1_hdnAssetCartCheckAll")) {
        window.document.getElementById("ctl00_ctl00_BodyContent_CartControls1_hdnAssetCartCheckAll").value = "Y";
    }
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTotAssetObjObjIds")) {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTotAssetObjObjIds").value = "";
    }
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAssetIds")) {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAssetIds").value = "";
    }
    // Added by Sami: For Default TextView Option for Title/Asset/BQAsset Cart.
    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleViewId")) {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleViewId").value = "viewID3";
    }
    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAssetCartMode"))
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAssetCartMode").value = "";
    }
    //***************************************************************************************************//
    window.document.getElementById("hdnNavigationMode").value = "cart";
    window.document.forms[0].action = pageName+".aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();    
}




