﻿
var timer="";

function funTitlesMenuBackgroundChange()
{
    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem"))
    {
        if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem").value == "Recently Viewed")
        {
            if (window.document.getElementById("liRecentlyViewedTM")) {
                window.document.getElementById("liRecentlyViewedTM").style.backgroundColor = "#ffac13";
                if (window.document.getElementById("lblPageName")) {
                    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnLoginUserName") && window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnLoginUserName").value != "") {
                        window.document.getElementById("lblPageName").innerHTML = "Titles&nbsp;Viewed&nbsp;in&nbsp;the&nbsp;past&nbsp;7&nbsp;days";
                    }
                    else {
                        window.document.getElementById("lblPageName").innerHTML = "Titles";
                   }
                }
            }
        }
        else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem").value == "New")
        { 
            if(window.document.getElementById("liNewTM"))
            { 
                window.document.getElementById("liNewTM").style.backgroundColor = "#ffac13"; 
            }
        }
       else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem").value == "Favorites")
        {
            if(window.document.getElementById("liFavoritesTM"))
            { 
                window.document.getElementById("liFavoritesTM").style.backgroundColor = "#ffac13"; 
            }
        }
        else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem").value == "Licensed Titles")
        { 
            if(window.document.getElementById("liLicensedTitlesTM"))
            { 
                window.document.getElementById("liLicensedTitlesTM").style.backgroundColor = "#ffac13";
            }
        }
        else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem").value == "All")
        { 
            if(window.document.getElementById("liAllTitlesTM"))
            { 
                window.document.getElementById("liAllTitlesTM").style.backgroundColor = "#ffac13";
            }
        }
        else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem").value == "Search Results")
        {
            if(window.document.getElementById("liSearchResult"))
            {
               window.document.getElementById("liSearchResult").style.backgroundColor = "#ffac13";
            }
        }
        else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem").value == "Saved Searches")
        {
            if(window.document.getElementById("liSavedSearch"))
            {
               window.document.getElementById("liSavedSearch").style.backgroundColor = "#ffac13";
            }
        }
    }
}

function funTitleMenuNav(strTitleMenuItem,id)
{
   window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "";
   window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = strTitleMenuItem;
   var pageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
   
    if(window.document.getElementById("liRecentlyViewedTM"))
    {
        window.document.getElementById("liRecentlyViewedTM").style.backgroundColor = "";
    }
    if(window.document.getElementById("liNewTM"))
    {
       window.document.getElementById("liNewTM").style.backgroundColor = "";
    }
    if(window.document.getElementById("liFavoritesTM"))
    {
       window.document.getElementById("liFavoritesTM").style.backgroundColor = "";
    }
    if(window.document.getElementById("liLicensedTitlesTM"))
    {
       window.document.getElementById("liLicensedTitlesTM").style.backgroundColor = "";
    }
    if(window.document.getElementById("liAllTitlesTM"))
    {
       window.document.getElementById("liAllTitlesTM").style.backgroundColor = "";
    }
    
    if(window.document.getElementById("liSearchResult"))
    {
       window.document.getElementById("liSearchResult").style.backgroundColor = "";
    }
    
    if(window.document.getElementById("liSavedSearch"))
    {
       window.document.getElementById("liSavedSearch").style.backgroundColor = "";
    }
    
    if(window.document.getElementById(id))
    {
        window.document.getElementById(id).style.backgroundColor = "#ffac13";
    }
    if(pageName && pageName.value  == "ScreeningRoom")
    {
        if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo") != null)
        {
           window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = "1";
        }
        window.document.getElementById("hdnScreenNavMode").value = "menu";
        // Function call to update the All Filter Option in Session_member_preference_type table when request for titles in this mode.
        if(strTitleMenuItem == "All")
        {
            funLeftFilter_SessionMemberPreference_Update('ESE');
        }
        else if(strTitleMenuItem == "Licensed Titles")
        {
            funLeftFilter_SessionMemberPreference_Update('EE');
        }
        else
        {
            funLeftFilter_SessionMemberPreference_Update('All');
        }
        window.document.forms[0].__VIEWSTATE.name= "";
        window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain","");
    }
    else
    {
        // Added for showing Loading wait.. Message.
        toggleVis('divProgressDialog');
    
        // Function call to update the All Filter Option in Session_member_preference_type table when request for titles in this mode.
        if(strTitleMenuItem == "All")
        {
            funLeftFilter_SessionMemberPreference_Update('ESE');
        }
        else if(strTitleMenuItem == "Licensed Titles")
        {
            funLeftFilter_SessionMemberPreference_Update('EE');
        }
        else
        {
            funLeftFilter_SessionMemberPreference_Update('All');
        }
        
        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";
        }
        pageName.value = "";
        window.document.forms[0].action = "TitlesList.aspx";
        window.document.forms[0].method = "post";
        window.document.forms[0].__VIEWSTATE.name = "";
        window.document.forms[0].submit();
    
     }
   return false;
}

function funEndEmulationClick() {

    var vardate = new Date();
    var strInfo = funGetHtmlFromJQuery("Xmlhttp.aspx", "Type=endemulation&Id=" + vardate); 
    strInfo = strInfo.substring(0,strInfo.length-2);
    funNavHomPageOnLogin(strInfo);

//    var vardate = new Date();
//    var html = $.ajax({
//                 url: "Xmlhttp.aspx",
//                 data: "Type=endemulation&Id="+vardate,                         
//                 async: false
//                }).responseText;
                //funFoxFastHomeClick();

}
function funUserPrefClick()
{
    if(window.document.getElementById("hdnMode"))
    {
        window.document.getElementById("hdnMode").value = "userpreferences";
    }
    else if(window.document.getElementById("ctl00_ContentPlaceHolder1_hdnMode"))
    {
        window.document.getElementById("ctl00_ContentPlaceHolder1_hdnMode").value = "userpreferences";
    }    
    window.document.forms[0].action = "UserPreferences.aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}
function fnBuildDetails(obj, type)
{ 
    var pageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
    var hdnCurrentPageNo = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo");

    if (pageName.value == "customerlist" || pageName.value == "DownloadedAssetsLicense")
    {
        if(obj.id == "aPrev")
        {
            hdnCurrentPageNo.value = parseInt(hdnCurrentPageNo.value) - 1;
        }
        else if(obj.id == "aNext")
        {
            hdnCurrentPageNo.value = parseInt(hdnCurrentPageNo.value) + 1;
        }
        else
        {
            hdnCurrentPageNo.value = obj.id;
        } 
        
        window.document.forms[0].__VIEWSTATE.name= "";
        window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain","");
    }
    else
    {
        var hdnCategories = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategories");
        
        var hdnNoOfTitleReq = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnNoofTitlesPerPage");
        var lblTotalTitles = window.document.getElementById("ctl00_ctl00_BodyContent_Views1_lblTotalTitles");
        
        var strClearParentChildYN = 'N';
        
        if(type == "noOfRecords")
        {
            hdnCurrentPageNo.value = 1;
            hdnNoOfTitleReq.value = obj;
        }   
        else if(type == "chk")
        {
            hdnCurrentPageNo.value = 1;
            strClearParentChildYN = 'Y';
        } 
        else if(obj.id == "aPrev")
        {
            hdnCurrentPageNo.value = parseInt(hdnCurrentPageNo.value) - 1;
        }
        else if(obj.id == "aNext")
        {
            hdnCurrentPageNo.value = parseInt(hdnCurrentPageNo.value) + 1;
        }
        else if(type != "sortBy" && type != "viewMode")
        {
            hdnCurrentPageNo.value = obj.id;
        } 

         window.scrollTo(0,0);  
         
        
        if(pageName && pageName.value == "SearchResults")
        {
            window.document.forms[0].__VIEWSTATE.name= "";
            window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain","");
        }
        else
        {
            // Doing Asyncronous PostBack for the TitleList Page.
             funTitleListAsyncronouPostBack(strClearParentChildYN);
         }
     }
     
     return false;
        
}

function fnBuildDetails1(obj)
{ 
    var pageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
    window.scrollTo(0,0);      
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = 1;
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnNoofTitlesPerPage").value = obj.id;

    if (pageName && pageName.value == "DownloadedAssetsLicense") {
        window.document.forms[0].__VIEWSTATE.name = "";
        window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain", "");
    }
    else {
        var vardate = new Date();
        // Updating the Userpreferences for this session.
        var strResult = funGetHtmlFromJQuery("Xmlhttp.aspx", "Option=" + obj.id + "~" + vardate + "&Type=userprefupdate");

        // Doing Asyncronous PostBack for the TitleList Page.
        if (pageName && pageName.value == "SearchResults") {
            window.document.forms[0].__VIEWSTATE.name = "";
            window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain", "");
        }
        else {
            funTitleListAsyncronouPostBack('N');
        }
    }
    return false;
}

function funGetSelectedCategoryDetails(obj, strValue, type)
{
    var vardate = new Date();
    var hdnCategories = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategories");
    var divShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy");
    var divChkShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divChkShowHierarchy");
    var flagHierarchyYN = "N";
    var hdnGetParentChild = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild");
    var hdnShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnShowHierarchy");
    
    if(type == "Series" || type == "Season" || type == "Episode")
    {
        if(divShowHierarchy && divShowHierarchy.style.display == 'block')
        {
            if(divChkShowHierarchy.className == "groupCheckbox group_on" && obj.className == "filterChecked")
            {
                hdnShowHierarchy.value = "N";
            }
        }
    }
        
    if(hdnCategories.value.indexOf(strValue) > -1)
    {
        hdnCategories.value = hdnCategories.value.replace(strValue+",","");
    }
    else
    {
        hdnCategories.value += strValue + ",";
    }
    
      /*Setting show hirearchy flag*/
    
    var strResult =  funGetHtmlFromJQuery("Xmlhttp.aspx","OptionCat="+ hdnCategories.value + "~"+ vardate + "&Type=userprefCatupdate&flagHierarchyYN="+flagHierarchyYN);
    
    /*Checkbox delay functionality*/
    clearTimeout(timer);    
    timer=window.setTimeout("fnBuildDetails('', 'chk')",2000);
}
/*Category Links*/
function funCategoryLinks(strValue)
{
    if(window.document.getElementById('hdnCategoryLinkId'))
    {
        window.document.getElementById('hdnCategoryLinkId').value = strValue;
    }
    if(window.document.getElementById('ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem'))
    {
        window.document.getElementById('ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem').value = "All";
    }
    if(window.document.getElementById('ctl00_ctl00_MainMenu1_hdnTitleMenu'))
    {
        window.document.getElementById('ctl00_ctl00_MainMenu1_hdnTitleMenu').value = "All";
    }
    
    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_hdnCurrentPageNo") != null)
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = 1;
    }
    
    funLeftFilter_SessionMemberPreference_Update('All');
    // Function call to update the All Filter Option in Session_member_preference_type table when request for titles in this mode.
    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 funGetSelectedCatDetFromMainMenu(strValue, chkId, parentId,TitleMenuItem,TitlesMenuId,LeftNavItemName)
{
    var hdnCategories = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategories");
    var vardate = new Date();
    window.document.getElementById("hdnLeftNavItems").value = strValue;
    if(chkId == "filter1000")
    { 
        if(TitleMenuItem == "All" )
        {
            funLeftFilter_SessionMemberPreference_Update('ESE');
        }
        else if(TitleMenuItem == 'Licensed Titles')
        {
            funLeftFilter_SessionMemberPreference_Update('EE');
        }
        else
        {
            funLeftFilter_SessionMemberPreference_Update('All');
        }
        
        if(hdnCategories != null)
        {
            hdnCategories.value = "";
        }
        obj=window.document.getElementsByName("filProdCategory");
        for (intCount=0;intCount<obj.length;intCount++)
        {  
            if(!obj[intCount].disabled)
            {
                if(hdnCategories != null)
                {		   
                    hdnCategories.value += obj[intCount].value + ",";		    
                }
            }
        }    
    }
    else
    {
        var hdnShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnShowHierarchy");
        if(hdnCategories != null)
        {
            hdnCategories.value = strValue + ",";
        }
        if(hdnShowHierarchy)
        {
            hdnShowHierarchy.value = "Y";
        }
        var strResult =  funGetHtmlFromJQuery("Xmlhttp.aspx","OptionCat="+ strValue + "~"+ vardate + "&Type=userprefCatupdate");
    } 
        
    if(window.document.getElementById("ctl00_ctl00_MainMenu1_hdnSelectedMainMenuItem") != null)
    {
        window.document.getElementById("ctl00_ctl00_MainMenu1_hdnSelectedMainMenuItem").value = parentId; 
    }
    else
    {
        window.document.getElementById("MainMenu1_hdnSelectedMainMenuItem").value = parentId; 
    }
    window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = TitleMenuItem;
    if(window.document.getElementById(TitlesMenuId))
    {
        window.document.getElementById(TitlesMenuId).style.backgroundColor = "#ffac13";
    }

    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;
    }
    window.document.forms[0].action = "TitlesList.aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
    
}

//---------------------------------------------------------------------------------------------  
//Description		: Adding/Removing all the CategoryIds to Hiddenvariable.
//Remarks		    : RegisterStartupScript.
//Input Params		: CheckBoxGroupName, CheckBoxId
//--------------------------------------------------------------------------------------------- 
function funGetMainMenuSelected(menuId)
{
    /*****For Checking the Left Menu items if navigated from the Top Header Main Menu. ***/
    menuId = menuId.split('~');
    if(window.document.getElementById(menuId[0]) != null)
    {
        window.document.getElementById(menuId[0]).style.backgroundColor = "#ffac13";
    }
}

//---------------------------------------------------------------------------------------------  
//Description		: Adding/Removing all the CategoryIds to Hiddenvariable.
//Remarks		    : On Click of All CheckBox from LeftNav.
//Input Params		: CheckBoxGroupName, CheckBoxId
//--------------------------------------------------------------------------------------------- 
function funCheckAllFilOptions(chkAllObj,chkObj)
{
  var obj=new Array();
  var objAll;
  var intCount;
  var vardate = new Date();
  var hdnCategories = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategories");
  var divShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy");
  var divChkShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divChkShowHierarchy");
  var hdnShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnShowHierarchy");
  var flagHierarchyYN = "N";
  hdnCategories.value = "";
  var objAll = window.document.getElementById(chkObj);
  obj=window.document.getElementsByName(chkAllObj);         
  if(objAll.checked)
  {     
  }
  else
  {
    for (intCount=0;intCount<obj.length;intCount++)
    {  
        if(!obj[intCount].disabled)
        {		   
	        var strValue = obj[intCount].value;
	        hdnCategories.value += strValue + ",";		    
        }
    }
  }
  
  if(divShowHierarchy && divShowHierarchy.style.display == 'block')
  {
    if(divChkShowHierarchy.className == "groupCheckbox group_on")
    {
    }
  }
  
  if(hdnCategories.value != "")
  {
    var strResult =  funGetHtmlFromJQuery("Xmlhttp.aspx","OptionCat=0"+ "~"+ vardate + "&Type=userprefCatupdate");
  }
  else
  {
    if(hdnShowHierarchy)
    {
        hdnShowHierarchy.value = "N";
    }
    var strResult =  funGetHtmlFromJQuery("Xmlhttp.aspx","OptionCat=1"+ "~"+ vardate + "&Type=userprefCatupdate&flagHierarchyYN="+flagHierarchyYN);
  }
  
  clearTimeout(timer);    
  timer=window.setTimeout("fnBuildDetails('', 'chk')",2000);
}

//---------------------------------------------------------------------------------------------  
//Description		: Building the TotalTitlesCount/No.ofRecrodsPerPage/Pagination for the List Pages.
//Remarks		    : RegisterStartUpScript.
//Input Params		: -
//--------------------------------------------------------------------------------------------- 
function funSetTotalTitles()
{
    if(window.document.getElementById("divtotalTitles") != null)
    {
        window.document.getElementById("divtotalTitles").innerHTML = "Total Titles:&nbsp;"+window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTotalTitles").value;
        if(window.document.getElementById("divtotalTitlesTop") != null)
        {
            window.document.getElementById("divtotalTitlesTop").innerHTML = "Total Titles:&nbsp;"+window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTotalTitles").value;
        }
        
        var hdnNoofTitlesPerPage = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnNoofTitlesPerPage").value;
        var hdnTotalTitles = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTotalTitles").value;
        var hdnCurrentPageNo = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value;
        var divPagenation = window.document.getElementById("divPagenation");
        var divPagenationBottom = window.document.getElementById("divPagenationBottom");
        var lblTitleInCart = window.document.getElementById("ctl00_ctl00_MainMenu1_lblTitleInCart");
        var lblAssetsInCart = window.document.getElementById("ctl00_ctl00_MainMenu1_lblAssetsInCart");
        var hdnTitleInCart = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleInCart");
        var hdnAssetsInCart = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAssetsInCart");
        var lblBQAssetsInCart = window.document.getElementById("ctl00_ctl00_MainMenu1_lblBQAssetsInCart");
        
        funSetPagination(hdnNoofTitlesPerPage,hdnTotalTitles,hdnCurrentPageNo,divPagenation,divPagenationBottom);
        
        funBuildDisplayNos(hdnNoofTitlesPerPage);
    
        if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId").value == "sortID1")
        {
            window.document.getElementById("sortID1").className = "sortOptions_on";
            window.document.getElementById("sortID2").className = "sortOptions_off";
            if(window.document.getElementById("sortID3") != null)
            {
                window.document.getElementById("sortID3").className = "sortOptions_off";
            }
        }
        else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId").value == "sortID2")
        {
            window.document.getElementById("sortID1").className = "sortOptions_off";
            window.document.getElementById("sortID2").className = "sortOptions_on";
            if(window.document.getElementById("sortID3") != null)
            {
                window.document.getElementById("sortID3").className = "sortOptions_off";
            }
        } 
        else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId").value == "sortID3")
        {
            if(window.document.getElementById("sortID3") != null)
            {
                window.document.getElementById("sortID1").className = "sortOptions_off";
                window.document.getElementById("sortID2").className = "sortOptions_off";
                window.document.getElementById("sortID3").className = "sortOptions_on";
            }
        }
        
        if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnViewId").value == "viewID1")
        {
            window.document.getElementById("viewID1").className = "viewOptions_on";
            window.document.getElementById("viewID2").className = "viewOptions_off";
            window.document.getElementById("viewID3").className = "viewOptions_off";
            
            var divShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy")
            if(divShowHierarchy)
            {
                window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy").style.display = 'none';
            }
        }
        else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnViewId").value == "viewID2")
        {
            window.document.getElementById("viewID1").className = "viewOptions_off";
            window.document.getElementById("viewID2").className = "viewOptions_on";
            window.document.getElementById("viewID3").className = "viewOptions_off";
            
            var divShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy")
            if(divShowHierarchy)
            {
                window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy").style.display = 'none';
            }
        } 
        else if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnViewId").value == "viewID3")
        {
            window.document.getElementById("viewID1").className = "viewOptions_off";
            window.document.getElementById("viewID2").className = "viewOptions_off";
            window.document.getElementById("viewID3").className = "viewOptions_on";
            
            var hdnTitleMenuItem = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem");
            var pageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
            var hdnGetParentChild = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnGetParentChild");
            var hdnTitleDetailsForCast = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleDetailsForCast");
            var hdnCategoryLinkId = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategoryLinkId");
            
            var hdnShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnShowHierarchy");
            var divShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy")
            if(divShowHierarchy)
            {
                if(pageName && pageName.value == "TitleList")
                {
                    if(hdnShowHierarchy && hdnShowHierarchy.value == "O")
                    {
                        window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy").style.display = 'none';
                    }
                    else
                    {
                        window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy").style.display = 'block';
                    }
                }
                else
                {
                    window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divShowHierarchy").style.display = 'none';
                }
            }
        }
    }
    if(lblTitleInCart != null && hdnTitleInCart != null)
    {
        var strTitCartCount = Trim(hdnTitleInCart.value);
        lblTitleInCart.innerHTML = (strTitCartCount == "1") ? strTitCartCount + " title" : strTitCartCount + " titles";
    }
//    if (lblAssetsInCart != null && hdnAssetsInCart != null) {
//        lblAssetsInCart.innerHTML = (hdnAssetsInCart.value.indexOf("~") != -1) ? Trim(hdnAssetsInCart.value.split('~')[0]) : hdnAssetsInCart.value;
//    }
//    if (lblBQAssetsInCart != null && hdnAssetsInCart != null) {
//        lblBQAssetsInCart.innerHTML = (hdnAssetsInCart.value.indexOf("~") != -1) ? Trim(hdnAssetsInCart.value.split('~')[1]) : hdnAssetsInCart.value;
//    }
    // Function call for closing the HOver popup/video popup if opened.
    funCloseVideoDialog();
}

function funUpdateAssestsCount() {
    var lblAssetsInCart = window.document.getElementById("ctl00_ctl00_MainMenu1_lblAssetsInCart");
    var hdnAssetsInCart = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAssetsInCart");
    var lblBQAssetsInCart = window.document.getElementById("ctl00_ctl00_MainMenu1_lblBQAssetsInCart");
    if (lblAssetsInCart != null && hdnAssetsInCart != null) {
        var strAssetCartCount = (hdnAssetsInCart.value.indexOf("~") != -1) ? Trim(hdnAssetsInCart.value.split('~')[0]) : Trim(hdnAssetsInCart.value);
        lblAssetsInCart.innerHTML = (strAssetCartCount == "1") ? strAssetCartCount + " asset" : strAssetCartCount + " assets";
    }
    if (lblBQAssetsInCart != null && hdnAssetsInCart != null) {
        var strBQAssetCartCount = (hdnAssetsInCart.value.indexOf("~") != -1) ? Trim(hdnAssetsInCart.value.split('~')[1]) : Trim(hdnAssetsInCart.value);
        lblBQAssetsInCart.innerHTML = (strBQAssetCartCount == "1") ? strBQAssetCartCount + " BQ Asset" : strBQAssetCartCount + " BQ Assets";
    }
}

function funDisplayHideControls()
{
    if(window.document.getElementById("cartControls") != null)
    {
        window.document.getElementById("cartControls").style.display = 'block';
    }
//    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName") != null && window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName").value.toLowerCase() == "titlecart")
//    {
//        if(window.document.getElementById("bcContainer"))
//        {
//            window.document.getElementById("bcContainer").style.display = "none"; 
//        }
//    }   
}


function funSetPaginationforCustomerList() {
    // For highlighting internal links link when clicked on customerlist
    if (window.document.getElementById("liMainIntLinks")) {
        window.document.getElementById("liMainIntLinks").style.backgroundColor = "#ffac13";  
    }
    var hdnNoofTitlesPerPage = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnNoofTitlesPerPage").value;
    var hdnTotalTitles = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTotalTitles").value;
    var hdnCurrentPageNo = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value;
    var divPagenation = window.document.getElementById("divPagenation");
    var divPagenationBottom = window.document.getElementById("divPagenationBottom");
    
    funSetPagination(hdnNoofTitlesPerPage,hdnTotalTitles,hdnCurrentPageNo,divPagenation,divPagenationBottom);
}

function funDownloadedAssetsLicence() {
    // 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.forms[0].action = "DownloadedAssetsLicense.aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}
function funSetPaginationforDownloadedAssetsLicense(mode) {

    var hdnNoofTitlesPerPage = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnNoofTitlesPerPage").value;
    var hdnTotalTitles = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTotalTitles").value;
    var hdnCurrentPageNo = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value;
    var divPagenation = window.document.getElementById("divPagenation");
    var divPagenationBottom = window.document.getElementById("divPagenationBottom");

    funChangeBgcolor();
    
    // For highlighting internal links link when clicked on customerlist
    if (window.document.getElementById("liMainIntLinks")) {
        window.document.getElementById("liMainIntLinks").style.backgroundColor = "#ffac13";
    }
    
    if (window.document.getElementById("bcContainer")) {
        window.document.getElementById("bcContainer").style.display = "none";
    }
    if (window.document.getElementById("titleTypeLegend")) {
        window.document.getElementById("titleTypeLegend").style.display = "none";
    }

    if (window.document.getElementById("divDALView") != null) {
        window.document.getElementById("divDALView").style.display = "none";
    }

    window.document.getElementById("divtotalTitles").innerHTML = "Total Assets:&nbsp;" + hdnTotalTitles;
    funSetPagination(hdnNoofTitlesPerPage, hdnTotalTitles, hdnCurrentPageNo, divPagenation, divPagenationBottom);
    funBuildDisplayNos(hdnNoofTitlesPerPage);

    if (mode == "licensedownloaded") {
        var strMsg = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnMessage").value;
        if (strMsg == "") {
            funBuildAlterMsg("Video License Downloaded Sucessfully.", "OK");
        }
        else {
            //strMsg = strMsg.replace("~@@~", "<br\>&nbsp;&nbsp;•&nbsp;");
            //strMsg = strMsg.replace(/~@@~/g, "<br\>&nbsp;&nbsp;•&nbsp;");
            funBuildAlterMsg(strMsg, "OK");
        }
        toggleVis('saveSearchDialog');
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnMode").value = "";
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnMessage").value = "";
    }

    if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId").value == "sortID1") {
        window.document.getElementById("sortID1").className = "sortOptions_on";
        window.document.getElementById("sortID2").className = "sortOptions_off";
        if (window.document.getElementById("sortID3") != null) {
            window.document.getElementById("sortID3").className = "sortOptions_off";
        }
    }
    else if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId").value == "sortID2") {
        window.document.getElementById("sortID1").className = "sortOptions_off";
        window.document.getElementById("sortID2").className = "sortOptions_on";
        if (window.document.getElementById("sortID3") != null) {
            window.document.getElementById("sortID3").className = "sortOptions_off";
        }
    }
    else if (window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnSortId").value == "sortID3") {
        if (window.document.getElementById("sortID3") != null) {
            window.document.getElementById("sortID1").className = "sortOptions_off";
            window.document.getElementById("sortID2").className = "sortOptions_off";
            window.document.getElementById("sortID3").className = "sortOptions_on";
        }
    }
}

function funCheckDownloadedAssetsLicense(obj, strValue) {
    var DwnlLicenseSourceurl1s = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDwnlLicenseFileObjObjIds");
    if (obj.className == "cartUnchecked") {
        DwnlLicenseSourceurl1s.value += strValue + ",";
    }
    else {
        DwnlLicenseSourceurl1s.value = DwnlLicenseSourceurl1s.value.replace(strValue + ",", "");
    }
}

function funCreateDRMLicenseforDownloadedAssets() {
    var DwnlLicenseFileObjObjIds = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDwnlLicenseFileObjObjIds");
    if (DwnlLicenseFileObjObjIds.value == "") {
        funBuildAlterMsg("Please select at least one asset.", "OK");
        toggleVis('saveSearchDialog');
    }
    else {

        document.getElementById('divProgressDialog').style.display = '';
        window.setTimeout("funCreateDRMLicenseforDownloadedAssets1()", 1000);
    }
}
function funCreateDRMLicenseforDownloadedAssets1() {
    var DwnlLicenseFileObjObjIds = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnDwnlLicenseFileObjObjIds");
    var fileObjObjId = "";
    var strError = "";
    var ArrDwnlLicenseFileObjObjIds = DwnlLicenseFileObjObjIds.value.split(',');
    for (var i = 0; i < ArrDwnlLicenseFileObjObjIds.length - 1; i++) {
        fileObjObjId = ArrDwnlLicenseFileObjObjIds[i];
        strError = funStoreLicenseforDownloadedAssets(fileObjObjId);
        if (strError != "") {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnMessage").value = "A technical error had occured. Please try again.";
            break;
        }
    }
    
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnMode").value = "licensedownloaded";
    DwnlLicenseFileObjObjIds.value = "";
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = "1";
    window.document.forms[0].action = "DownloadedAssetsLicense.aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}



//---------------------------------------------------------------------------------------------  
//Description		: Building the Pagination for the List Pages.
//Remarks		    : Called from 'funSetTotalTitles' Method.
//Input Params		: NoofTitlesPerPage,TotalTitles,CurrentPageNo,divPagenation,divPagenationBottom
//--------------------------------------------------------------------------------------------- 
function funSetPagination(hdnNoofTitlesPerPage,hdnTotalTitles,hdnCurrentPageNo,divPagenation,divPagenationBottom)
{
    var strContent = "";
    var strHTML = "";
    if(hdnNoofTitlesPerPage == "All")
    {
        hdnNoofTitlesPerPage = hdnTotalTitles;
    }
    var TotalNoofPages = parseInt(hdnTotalTitles)/parseInt(hdnNoofTitlesPerPage);
    TotalNoofPages = Math.ceil(TotalNoofPages);
    
    // Checking wheater pagination requires or not.
    if(parseInt(hdnTotalTitles) > 0)
    {
        if(TotalNoofPages <= 1)
        {
            strHTML = "Page&nbsp; <a href='#' title='Previous' onclick='javascript:return false;'>"+
                        "<img alt='previous' src='../images/arrowGrayL.gif' border='0' align='middle' onclick='javascript:return false;'/></a>";
            strHTML += "<span class='current'>1</span>"; 
                        
            strHTML += "<a href='#' title='Next' onclick='javascript:return false;'>"+
                        "<img alt='next' src='../images/arrowGrayR.gif' border='0' align='middle' /></a>";
        }
        else
        {
            if(hdnCurrentPageNo == "1")
            {
                strContent = "<span class='current'>1</span>&nbsp;"; 
            }
            else
            {
                strContent = "<a id='1' href='#' onclick='javascript:return fnBuildDetails(this);'>1</a>&nbsp;"; 
            }
            
            // if the Current PageNo is less then 3.
            if(parseInt(hdnCurrentPageNo) <= 3)
            { 
                strContent += "<span class='gray'>|</span>&nbsp";       
                for(var i=2; i < TotalNoofPages; i++)
                {
                    
                    if(i == 5)
                    {
                        strContent += "<span class='gray'>&hellip;</span>&nbsp; ";
                        break;
                    } 
                    else
                    {
                        if(parseInt(hdnCurrentPageNo) == i)
                        {
                            strContent += "<span class='current'>"+i+"</span>&nbsp;";//<span class='gray'>|</span>&nbsp";
                        }
                        else
                        {
                            strContent += "<a href='#' id='"+i+"' onclick='javascript:return fnBuildDetails(this);'>"+i+"</a>&nbsp;";
                        }
                    }
                    
                    strContent += "<span class='gray'>|</span>&nbsp;";            
                }
            }       
            else if(parseInt(hdnCurrentPageNo) >= (parseInt(TotalNoofPages)-2))
            {
                var intCount = i=(parseInt(TotalNoofPages)-3);
                if(intCount != 0 && intCount != 1)
                {
                    if(TotalNoofPages != "5")
                    {
                        strContent += "<span class='gray'>&hellip;</span>&nbsp; ";
                    }
                    else
                    {
                        strContent += "<span class='gray'>|</span>&nbsp;";  
                    }
                }
                for(var i=0; i < 3; i++)
                {
                    if(parseInt(hdnCurrentPageNo) == intCount)
                    {
                        strContent += "<span class='current'>"+intCount+"</span>&nbsp;";//<span class='gray'>|</span>&nbsp";
                    }
                    else
                    {
                        if(intCount != 0 && intCount != 1)
                        {
                            strContent += "<a href='#' id='"+intCount+"' onclick='javascript:return fnBuildDetails(this);'>"+intCount+"</a>&nbsp;";
                        }
                    }
                    strContent += "<span class='gray'>|</span>&nbsp;";
                    intCount++;
                }
            }
            else
            {
                strContent += "<span class='gray'>&hellip;</span>&nbsp; ";
                strContent += "<a href='#' id='"+(parseInt(hdnCurrentPageNo)-1)+"' onclick='javascript:return fnBuildDetails(this);'>"+(parseInt(hdnCurrentPageNo)-1)+"</a>&nbsp;<span"+
                        "class='gray'>|</span>&nbsp;";
                strContent += "<span class='current'>"+hdnCurrentPageNo+"</span>&nbsp;<span class='gray'>|</span>&nbsp;"; 
                strContent += "<a href='#' id='"+(parseInt(hdnCurrentPageNo)+1)+"' onclick='javascript:return fnBuildDetails(this);'>"+(parseInt(hdnCurrentPageNo)+1)+"</a>&nbsp;";
                strContent +=  "<span class='gray'>&hellip;</span>&nbsp;";     
            }
            
            if(hdnCurrentPageNo == TotalNoofPages)
            {
                strContent += "<span class='current'>"+TotalNoofPages+"</span>"; 
                
            }
            else
            {
                 strContent += "<a href='#' id='"+TotalNoofPages+"' onclick='javascript:return fnBuildDetails(this);'>"+TotalNoofPages+"</a>"; 
                
            }

            if(hdnCurrentPageNo == "1")
            {
                strHTML = "Page&nbsp; <a href='#' title='Previous' onclick='javascript:return false;'>"+
                        "<img alt='previous' src='../images/arrowGrayL.gif' border='0' align='middle' onclick='javascript:return false;'/></a>";
            }
            else
            {
                strHTML = "Page&nbsp; <a href='#' id='aPrev' title='Previous' onclick='javascript:fnBuildDetails(this);'>"+
                        "<img alt='previous' src='../images/arrowGrayL.gif' border='0' align='middle' /></a>";
            }
            
            strHTML += strContent;
            
            if(hdnCurrentPageNo == TotalNoofPages)
            {
                strHTML += "<a href='#' title='Next' onclick='javascript:return false;'>"+
                        "<img alt='next' src='../images/arrowGrayR.gif' border='0' align='middle' /></a>";
            }
            else
            {
                strHTML += "<a href='#' id='aNext' title='Next' onclick='javascript:fnBuildDetails(this);'>"+
                        "<img alt='next' src='../images/arrowGrayR.gif' border='0' align='middle' /></a>";
            }
        }
        
        divPagenation.innerHTML = strHTML;
        divPagenationBottom.innerHTML = strHTML;
    }
    else
    {
        divPagenation.innerHTML = "&nbsp;";
        divPagenationBottom.innerHTML = "&nbsp;";
    }
    
}

//---------------------------------------------------------------------------------------------  
//Description		: Building the No. of Records per Page.
//Remarks		    : Called from 'funSetTotalTitles' Method.
//Input Params		: SavedSearchId
//--------------------------------------------------------------------------------------------- 
function funBuildDisplayNos(NoofTitlesPerPage)
{
    var divdisplayNum = window.document.getElementById("divdisplayNum");
    var strHTML = "";
    var strType = 'noOfRecords';
    
    if(NoofTitlesPerPage == "10")
    {
        strHTML = "View&nbsp; <span class='current'>10</span>&nbsp;<span class='gray'>|</span>&nbsp;"+
        "<span class='gray'></span><a id='25' href='#' onclick='javascript:return fnBuildDetails1(this);' title='25 per page'>25</a>&nbsp;<span class='gray'>|</span>&nbsp; <a id='50' href='#'"+
            "title='50 per page' onclick='javascript:return fnBuildDetails1(this);'>50</a>&nbsp;<span class='gray'>|</span>&nbsp; <a id='100' onclick='javascript:return fnBuildDetails1(this);' href='#' title='100 per page'>"+
                "100</a>";
    }
    if(NoofTitlesPerPage == "25")
    {
        strHTML = "View&nbsp; <span class='gray'><a id='10' href='#' onclick='javascript:return fnBuildDetails1(this);' title='10 per page'>10</a></span>&nbsp;<span class='gray'>|</span>&nbsp;"+
        "<span class='current'>25</span>&nbsp;<span class='gray'>|</span>&nbsp; <a id='50' href='#'"+
            "title='50 per page' onclick='javascript:return fnBuildDetails1(this);'>50</a>&nbsp;<span class='gray'>|</span>&nbsp; <a id='100' onclick='javascript:return fnBuildDetails1(this);' href='#' title='100 per page'>"+
                "100</a>";
    }
    if(NoofTitlesPerPage == "50")
    {
        strHTML = "View&nbsp; <span class='gray'><a id='10' href='#' onclick='javascript:return fnBuildDetails1(this);' title='10 per page'>10</a></span>&nbsp;<span class='gray'>|</span>&nbsp;"+
        "<span class='gray'></span><a id='25' href='#' onclick='javascript:return fnBuildDetails1(this);' title='25 per page'>25</a>&nbsp;<span class='gray'>|</span>&nbsp;"+
        "<span class='current'>50</span>&nbsp;<span class='gray'>|</span>&nbsp; <a id='100' onclick='javascript:return fnBuildDetails1(this);' href='#' title='100 per page'>"+
                "100</a>";
    }
    if(NoofTitlesPerPage == "100")
    {
        strHTML = "View&nbsp; <span class='gray'><a id='10' href='#' onclick='javascript:return fnBuildDetails1(this);' title='10 per page'>10</a></span>&nbsp;<span class='gray'>|</span>&nbsp;"+
        "<span class='gray'></span><a id='25' href='#' onclick='javascript:return fnBuildDetails1(this);' title='25 per page'>25</a>&nbsp;<span class='gray'>|</span>&nbsp; <a id='50' href='#'"+
            "title='50 per page' onclick='javascript:return fnBuildDetails1(this);'>50</a>&nbsp;<span class='gray'>|</span>&nbsp;"+
                "<span class='current'>100</span>";
    }
    if(NoofTitlesPerPage == "All")
    {
        strHTML = "View&nbsp; <span class='gray'><a id='10' href='#' onclick='javascript:return fnBuildDetails1(this);' title='10 per page'>10</a></span>&nbsp;<span class='gray'>|</span>&nbsp;"+
        "<span class='gray'></span><a id='25' href='#' onclick='javascript:return fnBuildDetails1(this);' title='25 per page'>25</a>&nbsp;<span class='gray'>|</span>&nbsp; <a id='50' href='#'"+
            "title='50 per page' onclick='javascript:return fnBuildDetails1(this);'>50</a>&nbsp;<span class='gray'>|</span>&nbsp; <a id='100' onclick='javascript:return fnBuildDetails1(this);' href='#' title='100 per page'>"+
                "100</a>";
    }
    
    divdisplayNum.innerHTML = strHTML;
}


//---------------------------------------------------------------------------------------------  
//Description		: Function for getting the Titles based on the SavedSearch Selected.
//Remarks		    : OnClick of SavedSearch from MainMenu.
//Input Params		: SavedSearchId
//--------------------------------------------------------------------------------------------- 
function funGetAdvSrchTitleDetails(SearchId)
{
    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
        
    var pageName = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnPageName");
    window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "";
    window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = 'Saved Searches';
    if(window.document.getElementById("liRecentlyViewedTM"))
    {
        window.document.getElementById("liRecentlyViewedTM").style.backgroundColor = "";
    }
    if(window.document.getElementById("liNewTM"))
    {
       window.document.getElementById("liNewTM").style.backgroundColor = "";
    }
    if(window.document.getElementById("liFavoritesTM"))
    {
       window.document.getElementById("liFavoritesTM").style.backgroundColor = "";
    }
    if(window.document.getElementById("liLicensedTitlesTM"))
    {
       window.document.getElementById("liLicensedTitlesTM").style.backgroundColor = "";
    }
    if(window.document.getElementById("liAllTitlesTM"))
    {
       window.document.getElementById("liAllTitlesTM").style.backgroundColor = "";
    }
    
    if(window.document.getElementById("liSearchResult"))
    {
       window.document.getElementById("liSearchResult").style.backgroundColor = "";
    }
    
    if(window.document.getElementById("liSavedSearch"))
    {
       window.document.getElementById("liSavedSearch").style.backgroundColor = "";
    }
    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchMode") != null)
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchMode").value = "";
    }
    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchText") != null)
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleSearchText").value = "";
    }
    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem"))
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem").value = "Saved Searches"
    }
    if(window.document.getElementById("hdnAdvSrchId") != null)
    {
        if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCartIds") != null)
        {
            window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCartIds").value = "";
        }
        window.document.getElementById("hdnAdvSrchId").value = SearchId;
        window.document.forms[0].action="SearchResults.aspx";
        window.document.forms[0].__VIEWSTATE.name = "";
        window.document.forms[0].submit();
        return false;
    }
}

//---------------------------------------------------------------------------------------------  
//Description		: Function for getting the Titles based on the Previous Saved Search Result.
//Remarks		    : OnClick of SavedSearch from MainMenu.
//Input Params		: SavedSearchId
//--------------------------------------------------------------------------------------------- 
function funGetTitleSearchResult()
{
    var AdvSearchId = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnAdvSrchId");
    var RepSearchId = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnRepeateSrchId");
      if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem"))
      {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleMenuItem").value = "Search Results"
      }
    if(AdvSearchId && RepSearchId)
    {
        if(AdvSearchId.value != "")
        {
            AdvSearchId.value = RepSearchId.value;
        }
    }            
    window.document.forms[0].action="SearchResults.aspx";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
    
    return false;
}

//---------------------------------------------------------------------------------------------  
//Description		: Function for getting the Titles based on the Previous Saved Search Result.
//Remarks		    : OnClick of SavedSearch from MainMenu.
//Input Params		: SavedSearchId
//--------------------------------------------------------------------------------------------- 
function funRefineSearch()
{
    if(window.document.getElementById("hdnRefineSearchFlag"))
    {
        window.document.getElementById("hdnRefineSearchFlag").value = "Y";
    }
    window.document.forms[0].action="AdvancedSearch.aspx";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
    
    return false;
}

function funGetShowHierarchy(strValue)
{
    var vardate = new Date();
    var chkCount = 0;
    var hdnCategories = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCategories");
    var strValurArr = strValue.split(',');
    var divChkShowHierarchy = window.document.getElementById("ctl00_ctl00_BodyContent_Views1_divChkShowHierarchy");
    if(divChkShowHierarchy.className == "groupCheckbox group_off")
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnShowHierarchy").value = "Y";
    }
    else
    {
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnShowHierarchy").value = "N";
    }

    window.document.forms[0].__VIEWSTATE.name= "";
    window.__doPostBack("ctl00_ctl00_BodyContent_updPanelMain","");
}
function funNavScreeningRoom(strvalue)
{
    // Added for showing Loading wait.. Message.
    toggleVis('divProgressDialog');
    //Mode for Playlist.
    window.document.getElementById("hdnScrnRoomMenuCat").value = strvalue;
    //Mode for screenign room navaigation.
    window.document.getElementById("hdnScreenNavMode").value = "menu";
    //To set the default value of page no to 1.
    if(window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo") != null)
    {
       window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnCurrentPageNo").value = "1";
    }
    //Mode for submenu.
    window.document.getElementById("ctl00_ctl00_MainMenu1_hdnTitleMenu").value = "All";
    funLeftFilter_SessionMemberPreference_Update('All');
    window.document.forms[0].action= "ScreeningRoom.aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}

function funGetSelectedAccessCategory(obj, strCategory)
{
    var strYN = "N";
    if(obj.className == "filterUnchecked")
    {
        strYN = "Y"
    }
        
    var vardate = new Date();
    // Updating the Userpreferences for this session.
    var strResult =  funGetHtmlFromJQuery("Xmlhttp.aspx","Option="+ strYN + "~"+ vardate + "&Type=userprefupdate&Category="+strCategory);  
    
    /*Checkbox delay functionality*/
    clearTimeout(timer);    
    timer=window.setTimeout("fnBuildDetails('', 'chk')",2000);
    
}

function funGetSelectedRunTimeCategory(obj, strValue, mode)
{
    var strYN = "N";
    var hdnCategories = '';
    if(mode == "titlestatus")
    {
        hdnCategories = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTitleStatusCategories");
    }
    else
    {
        hdnCategories = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnRunTimeCategories");
    }
    
    if(hdnCategories)
    {
        if(strValue == "filterRunTime")
        {
            funGetSelectedRunTimeCatForAll(obj, strValue);
        }
        else
        {
            if(obj.className == "filterUnchecked")
            {
                hdnCategories.value += strValue + ",";
                strYN = "Y";
            }
            else
            {
               hdnCategories.value = hdnCategories.value.replace(strValue+",",""); 
            }
        }
            
        var vardate = new Date();
        // Updating the Userpreferences for this session.
        var strResult =  funGetHtmlFromJQuery("Xmlhttp.aspx","Option="+ strYN + "~"+ vardate + "&Type=userprefruntimeupdate&CategoryId="+hdnCategories.value+"&mode="+mode);  
        
        /*Checkbox delay functionality*/
        clearTimeout(timer);    
        timer=window.setTimeout("fnBuildDetails('', 'chk')",2000);
    }
}

function funGetSelectedRunTimeCatForAll(objChk, chkAllObj)
{
    var hdnRunTimeCategories = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnRunTimeCategories");
    obj=window.document.getElementsByName(chkAllObj); 
    hdnRunTimeCategories.value = "";          
    if(objChk.className == "filterUnchecked")
    { 
        for (intCount=0;intCount<obj.length;intCount++)
        {  
            if(!obj[intCount].disabled)
            {		   
                hdnRunTimeCategories.value += obj[intCount].value + ",";		    
            }
        }
    }
}
function funSetPlayeronSpotlight(condition) 
{
    try 
    {
        var objPlayer;
        if (window.document.getElementById("divSlpCheck")) {
            if (window.document.getElementById("QTBody")) {
                window.document.getElementById("QTBody").innerHTML = "";
            }
        }
        else {
            if (window.frames["MediaPlayer_iframe"] && (window.frames["MediaPlayer_iframe"].document.getElementById("MediaPlayer")) && (window.document.getElementById("WMVPlayer") && window.document.getElementById("WMVPlayer").style.display == 'block')) {
                objPlayer = window.frames["MediaPlayer_iframe"].document.getElementById("MediaPlayer");
                if (condition == "show") {
                    objPlayer.controls.play();
                }
                else {
                    objPlayer.controls.pause();
                }
            }
            else if (window.frames["QT_Player_iframe"] && (window.frames["QT_Player_iframe"].document.getElementById("QuicktimePlayer")) && (window.document.getElementById("QTPlayer") && window.document.getElementById("QTPlayer").style.display == 'block')) {
                objPlayer = window.frames["QT_Player_iframe"].document.getElementById("QuicktimePlayer");
                if (condition == "show") {
                    objPlayer.Play();
                }
                else {
                    objPlayer.SetRate(0);
                }
            }
            else if (window.frames["MediaPlayer_iframe"] && (window.frames["MediaPlayer_iframe"].document.getElementById("slp")) && (window.document.getElementById("WMVPlayer") && window.document.getElementById("WMVPlayer").style.display == 'block')) {
                objPlayer = window.frames["MediaPlayer_iframe"].document.getElementById("slp");
                if (condition == "show") {
                    if (window.document.getElementById("QTBody")) {
                        window.document.getElementById("QTBody").innerHTML = "";
                        //objPlayer.controls.play();
                    }
                }
                else {
                    if (window.document.getElementById("QTBody")) {
                        window.document.getElementById("QTBody").innerHTML = "";
                        //objPlayer.controls.pause();
                    }
                }
            }
        }
    }
    catch (e) 
    {
    }
}

function funDatePopUp(objId) {
    var obj = window.document.getElementById(objId);
    DatePopup(obj, 'dd-MMM-yyyy');
}
function funDownloadWebTrends() {
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_lblMsg").innerHTML = "";
    var DateFormat = "DD-MMM-YYYY";
    var FromDate = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtFromDate");
    var ToDate = window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_txtToDate");
    if (FromDate.value == "") {
//        funBuildAlterMsg("Please Enter From Date.", "OK");
//        toggleVis('saveSearchDialog');
        window.alert("Please Enter From Date.");
        FromDate.focus();
    }
    else if (ToDate.value == "") {
//        funBuildAlterMsg("Please Enter To Date.", "OK");
//        toggleVis('saveSearchDialog');
        window.alert("Please Enter To Date.");
        ToDate.focus();
    }
    else {
            var blnValidDate = true;
            if (FromDate.value.length > 0) {
                blnValidDate = CheckValid(FromDate.value, DateFormat)
                if (blnValidDate == false) {
                    if (isLetter(FromDate.value.charAt(0)) || isLetter(FromDate.value.charAt(3))) {
                        blnValidDate = CheckValid(FromDate.value, DateFormat)
                    }
                    if (blnValidDate == false) {
//                        funBuildAlterMsg("Enter From Date in Valid Format : " + DateFormat, "OK");
//                        toggleVis('saveSearchDialog');
                        window.alert("Enter From Date in Valid Format : " + DateFormat);
                        FromDate.value = '';
                        FromDate.focus();
                        return false;
                    }
                }
            }
            blnValidDate = true;
            if (ToDate.value.length > 0) {
                blnValidDate = CheckValid(ToDate.value, DateFormat)
                if (blnValidDate == false) {
                    if (isLetter(ToDate.value.charAt(0)) || isLetter(ToDate.value.charAt(3))) {
                        blnValidDate = CheckValid(ToDate.value, DateFormat)
                    }
                    if (blnValidDate == false) {
//                        funBuildAlterMsg("Enter To Date in Valid Format : " + DateFormat, "OK");
//                        toggleVis('saveSearchDialog');
                        window.alert("Enter To Date in Valid Format : " + DateFormat);
                        ToDate.value = '';
                        ToDate.focus();
                        return false;
                    }
                }
            }
            var IntDateDifference = CompareDatesDiff(FromDate.value, ToDate.value, DateFormat);
            if (IntDateDifference == 3) {
                window.alert("To Date should be greater than or equal to From Date");
                return false;
            }
            if (FromDate.value != "") {
                window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnWebTrendsFromDate").value = FromDate.value;
            }
            if (ToDate.value != "") {
                window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnWebTrendsToDate").value = ToDate.value;
            }
//        var strValue = "all";
//        if (window.document.getElementsByName("rdoOption")[1].checked == true) {
//            strValue = "download";
//        }
//        else if (window.document.getElementsByName("rdoOption")[2].checked == true) {
//            strValue = "play";
//        }
            //        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTrendsDownloadOption").value = strValue;
        window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTrendsDownloadYN").value = "Y";
        window.document.forms[0].action = "DownloadWebTrends.aspx";
        window.document.forms[0].method = "post";
        window.document.forms[0].__VIEWSTATE.name = "";
        window.document.forms[0].submit();
    }
}
function funDownloadTrendsOption(strValue) {
    window.document.getElementById("ctl00_ctl00_BodyContent_SubBodyContent_hdnTrendsDownloadOption").value = strValue;
}
function funTrendsDownloadCancel() {
    window.document.forms[0].action = "TitleList.aspx";
    window.document.forms[0].method = "post";
    window.document.forms[0].__VIEWSTATE.name = "";
    window.document.forms[0].submit();
}

function CompareDatesDiff(DateOne, DateTwo, strDateFormat) {
    var strStart = getFormatedDate(DateOne, strDateFormat);
    var strEnd = getFormatedDate(DateTwo, strDateFormat);
    if (strStart.length > 0 && strEnd.length > 0) {
        var dtStart = new Date(strStart);
        var dtEnd = new Date(strEnd);
        var diff = dtEnd - dtStart;
        if (diff == 0)	//startdate is less than end date
            return 1;
        else if (diff > 0)
            return 2;
        else
            return 3;
    }
}

var NUMYEAR = 30;
function getFormatedDate(str_date, strDateFormat) {
    var strUserDateFormat = strDateFormat.toUpperCase();
    if (strUserDateFormat == 'DD-MMM-YYYY') {
        var arrMonth = new String("JanFebMarAprMayJunJulAugSepOctNovDec");
        var arrDate = str_date.split("-");
        if (arrDate.length != 3) {
            return "";
        }
        var intIndex = arrMonth.toLowerCase().indexOf(arrDate[1].toLowerCase())
        if (intIndex > -1) {
            if (arrDate[2] < 100) arrDate[2] = Number(arrDate[2]) + (arrDate[2] < NUMYEAR ? 2000 : 1900);
            str_date = (intIndex + 3) / 3 + "/" + (parseInt(arrDate[0], 10) < 10 ? '0' : '') + parseInt(arrDate[0], 10) + "/" + arrDate[2];
            return str_date;

        }
    }
    else if (strUserDateFormat == 'DD/MM/YYYY') {
        var arrDate = str_date.split("/");
        if (arrDate.length != 3)
            return "";
        else
            return (arrDate[1] + '/' + arrDate[0] + '/' + arrDate[2]);
    }
    else {
        return str_date;
    }

    return "";
}


function CheckValid(UserDate, UserDateFormat) {
    var intTemp;
    var blnMonthInLetters = false;
    var blnLeapYear = true;
    var varDay, varMonth, varYear;
    var strTemp = UserDate;
    //strTemp = stripWhitespace(strTemp);
    UserDateFormat = stripWhitespace(UserDateFormat);
    var strTemp1 = strTemp;
    var strUserDateFormat = UserDateFormat.toUpperCase();
    if (UserDateFormat.length == 0) {
        return false;
    }
    if (UserDate.length == 0) {
        return true;
    }
    if (strUserDateFormat.substr(0, 2) == "DD") {
        //alert("User Has Choosend Us British format");
        intTemp = strTemp.indexOf("/")
        if (intTemp == -1) {
            intTemp = strTemp.indexOf("-")
            if (intTemp == -1)
                return false
            else {
                strPreviousSeperator = "-"
            }
        }
        else {
            strPreviousSeperator = "/"
        }

        if (intTemp == -1) {
            // Invalid Seperator character entered return false
            return false
        }
        else {
            strDay = strTemp.substr(0, intTemp)
            strTemp1 = strTemp.substr(intTemp + 1, strTemp.length - intTemp - 1)
            intTemp = strTemp1.indexOf(strPreviousSeperator)
            if (intTemp == -1) {
                // Invalid Seperator character entered return false
                return false
            }
            else {
                strMonth = strTemp1.substr(0, intTemp)
                strTemp1 = strTemp1.substr(intTemp + 1, strTemp1.length - intTemp - 1)
                strYear = strTemp1
            }
        }
    }
    else if ((strUserDateFormat.substr(0, 2) == "MM") || (strUserDateFormat.substr(0, 3) == "MMM") || (strUserDateFormat.substr(0, 4) == "MMMM")) {
        //alert("User Has Choosend Us English format");
        intTemp = strTemp.indexOf("/")
        if (intTemp == -1) {
            intTemp = strTemp.indexOf("-")
            if (intTemp == -1)
                return false
            else {
                strPreviousSeperator = "-"
            }
        }
        else {
            strPreviousSeperator = "/"
        }
        if (intTemp == -1) {
            // Invalid Seperator character entered return false
            return false
        }
        else {
            strMonth = strTemp.substr(0, intTemp);
            strTemp1 = strTemp.substr(intTemp + 1, strTemp.length - intTemp - 1)
            intTemp = strTemp1.indexOf(strPreviousSeperator);
            if (intTemp == -1) {
                // Invalid Seperator character entered return false
                return false;
            }
            else {
                strDay = strTemp1.substr(0, intTemp);
                strTemp1 = strTemp1.substr(intTemp + 1, strTemp1.length - intTemp - 1)
                strYear = strTemp1;
            }
        }
    }
    else {
        //Invalid date format
        return false;
    }

    intTemp = strYear.indexOf(strPreviousSeperator)
    if (intTemp >= 0) {
        //Some characters are there in year
        return false;
    }
    // if (strYear.length != 2 && strYear.length != 4)
    if (strYear.length != 4) {
        return false;
    }
    if (strDay.length != 1 && strDay.length != 2) {
        return false;
    }
    if (strUserDateFormat == 'DD-MMM-YYYY') {
        if (strMonth.length != 3) {
            return false;
        }
    }
    else {
        if (strMonth.length != 1 && strMonth.length != 2) {
            return false;
        }
    }


    if (strDay.length > 0 && strMonth.length > 0 && strYear.length > 0) {
        for (i = 0; i < strDay.length; i++) {
            if (isLetter(strDay.charAt(i))) {
                return false;
            }
        }
        for (i = 0; i < strYear.length; i++) {
            if (isLetter(strYear.charAt(i))) {
                return false;
            }
        }
        intDay = parseInt(strDay, 10)
        if (intDay > 31 || intDay <= 0) {
            // Invalid Day
            return false;
        }
        for (i = 0; i < strTemp.length; i++) {
            if (isLetter(strTemp.charAt(i))) {
                intTemp = 0
                break;
            }
            else {
                intTemp = -1
            }
        }
        if (intTemp == 0) {
            //User Entered characters in date
            strMonth = strMonth.toUpperCase()
            if ((strMonth == "JANUARY") || (strMonth == "JAN")) {
                intMonth = 1;
            }
            else if ((strMonth == "FEBRUARY") || (strMonth == "FEB")) {
                intMonth = 2;
            }
            else if ((strMonth == "MARCH") || (strMonth == "MAR")) {
                intMonth = 3;
            }
            else if ((strMonth == "APRIL") || (strMonth == "APR")) {
                intMonth = 4;
            }
            else if ((strMonth == "MAY")) {
                intMonth = 5;
            }
            else if ((strMonth == "JUNE") || (strMonth == "JUN")) {
                intMonth = 6;
            }
            else if ((strMonth == "JULY") || (strMonth == "JUL")) {
                intMonth = 7;
            }
            else if ((strMonth == "AUGUST") || (strMonth == "AUG")) {
                intMonth = 8;
            }
            else if ((strMonth == "SEPTEMBER") || (strMonth == "SEP")) {
                intMonth = 9;
            }
            else if ((strMonth == "OCTOBER") || (strMonth == "OCT")) {
                intMonth = 10;
            }
            else if ((strMonth == "NOVEMBER") || (strMonth == "NOV")) {
                intMonth = 11;
            }
            else if ((strMonth == "DECEMBER") || (strMonth == "DEC")) {
                intMonth = 12;
            }
            else {
                return false;
            }
        }
        else {
            intMonth = parseInt(strMonth, 10)
            if (intMonth > 12 || intMonth <= 0) {
                //Invalid Month
                return false;
            }
            for (i = 0; i < strMonth.length; i++) {
                if (!isDigit(strMonth.charAt(i))) {
                    // User entered some invalid characters
                    return false;
                }
            }
        }
        intYear = parseInt(strYear, 10)
        if (strYear.length == 4 && intYear <= 0) {
            return false;
        }
        if (strYear.length == 4 && intYear < 1753) {
            return false;
        }
        intTemp = daysInFebruary(intYear)
        if ((intMonth == 2) && (intDay > intTemp)) {
            // More days entered for february
            return false;
        }
        if ((intMonth == 4) || (intMonth == 6) || (intMonth == 9) || (intMonth == 11)) {
            if (intDay > 30) {
                // Days should not be greater than 30
                return false;
            }
        }
        else {
            if (intDay > 31) {
                // Days should not be greater than 31
                return false;
            }
        }
    }
    else {
        return false;
    }
    return true;
}

var whitespace = " \t\n\r";

function stripWhitespace(s) {
    return stripCharsInBag(s, whitespace)
}

function stripCharsInBag(s, bag) {
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++) {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}


function isDigit(c) {
    return ((c >= "0") && (c <= "9"))
}

function isLetter(c) {
    return (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")))
}

function daysInFebruary(year) {
    if ((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) {
        return 29
    }
    else {
        return 28
    }
}



