﻿function masterLoad() {
    //debugger

    var hfPopupToBeShown = document.getElementById("ctl00_hfPopupToBeShown")

    if (hfPopupToBeShown.value == "false") {
        displayFlash();
    }
    else {
        HideFlash();
    }
}

function HideFlash() {
    //debugger
    MehtaMainFlash = document.getElementById("MehtaMainFlash");
    MehtaMainFlash.style.display = "none";

    pnlHomeFlash = document.getElementById("ctl00_MehtaMainCPH_HomeMarathiFlash");

    if (pnlHomeFlash != null) {
        pnlHomeFlash.style.display = "none";
    }

}
function displayFlash() {
    //debugger
    MehtaMainFlash = document.getElementById("MehtaMainFlash");
    MehtaMainFlash.style.display = "block";

    pnlHomeFlash = document.getElementById("ctl00_MehtaMainCPH_HomeMarathiFlash");

    if (pnlHomeFlash != null) {
        pnlHomeFlash.style.display = "block";
    }
}

function ClosePopupLogin() 
{
    displayFlash();
    $find('pnlPopUpLoginIdBehave').hide();    
}

function SetHFGenRep(strValue) 
{
    //debugger
    var hfGenRep = document.getElementById("ctl00_MehtaMainCPH_hfGenRep");
    hfGenRep.value = strValue;
    return true;
}

function DisplayCartBookCount(HiddenFieldToReadOnPage) {
    //debugger;
    try {
        if (HiddenFieldToReadOnPage == 'M')                 // Master Page
        {
            var hfCartBookCount = document.getElementById("ctl00_hfCartBookCountMP");
        }
        else if (HiddenFieldToReadOnPage == 'P')           //  Content Page 
        {
            var hfCartBookCount = document.getElementById("ctl00_MehtaMainCPH_hfCartBookCount");
        }

        if (hfCartBookCount != null) {
            var lblCartBookCount = document.getElementById("ctl00_lblCartBookCount");
            var btnViewCart = document.getElementById("ctl00_btnViewCart");

            if (parseFloat(hfCartBookCount.value) > 0) {
                btnViewCart.style.display = "block";
                lblCartBookCount.innerHTML = "Carts Book Count : " + hfCartBookCount.value
            }
            else if (parseFloat(hfCartBookCount.value) == 0) {
                btnViewCart.style.display = "none";
                lblCartBookCount.innerHTML = "";
            }
        }

    } //try
    catch (err) {
        alert(err);
    }
}

function displayPopupLoginTab(tabIndex) {
    var tbSignUp = document.getElementById("ctl00_tbSignUp");
    var tbSignin = document.getElementById("ctl00_tbSignin");
    var pnlPopupSignUp = document.getElementById("ctl00_pnlPopupSignUp");
    var pnlPopupSignIn = document.getElementById("ctl00_pnlPopupSignIn");

    tbSignUp.className = "SignUpOrig"
    tbSignin.className = "SignInOrig";
    pnlPopupSignUp.style.display = "none";
    pnlPopupSignIn.style.display = "none";

    if (tabIndex == 0) {
        tbSignin.className = "SignInSel"
        pnlPopupSignIn.style.display = "block";
    }
    else if (tabIndex == 1) {
        tbSignUp.className = "SignUpSel";
        pnlPopupSignUp.style.display = "block";
    }

    return false;
}


function MehtaLinksHover(objLink) 
{
    if (objLink.className != "MehtaLinksBgSel") 
    {
        objLink.className = "MehtaLinksBgHover";
    }
   return false;
}

function MehtaLinksMouseOut(objLink) 
{
    if (objLink.className != "MehtaLinksBgSel")
    {
        objLink.className = "MehtaLinksBg";
    }
    return false;
}

function BeginRequest() 
{
    var hfGenRep = document.getElementById("ctl00_MehtaMainCPH_hfGenRep");

    if ($find('pnlPricewiseBooksBehave') != null) $find('pnlPricewiseBooksBehave').hide();
    if ($find('pnlPopUpLoginIdBehave') != null) $find('pnlPopUpLoginIdBehave').hide();
    if ($find('pnlPublishYearwiseBooksBehave') != null) $find('pnlPublishYearwiseBooksBehave').hide();
    if ($find('pnlFeedbackBehave') != null) $find('pnlFeedbackBehave').hide();
    if ($find('pnlPostFeedbackBehave') != null) $find('pnlPostFeedbackBehave').hide();
    if ($find('pnlWhyRegisterBehave') != null) $find('pnlWhyRegisterBehave').hide();

    if (hfGenRep != null) {
        if (hfGenRep.value == "false") {
            HideFlash();
            if ($find('pnlWaitingBehave') != null) $find('pnlWaitingBehave').show();
        }
        else {
            hfGenRep.value = "false";
        }
    }
    else {
        HideFlash();
        if ($find('pnlWaitingBehave') != null) $find('pnlWaitingBehave').show();
    }
}

function EndRequest() 
{
    //debugger 
    
    var hfPopupToBeShown = document.getElementById("ctl00_MehtaMainCPH_hfPopupToBeShown")

    $find('pnlWaitingBehave').hide();

    if (hfPopupToBeShown != null) 
    {
        if (hfPopupToBeShown.value == "false") 
        {
            displayFlash();
        }
    }
    else 
    {
        displayFlash();
    }    
    
    DisplayCartBookCount('P');
}
