﻿/*jslint bitwise: true, browser: true, eqeqeq: true, nomen: true, undef: false, white: true */

function rdo_OnClick(r)
{
    var ctlAmount = document.getElementById(txtAmountID);
    var ctlAthon = document.getElementById(chkIsAthonID);
    var ctlAmountReqVal = document.getElementById(m_oReqValidatorAmountID);
    var ctlAmountCmpVal = document.getElementById(m_oCmpValidatorAmountID);
    //var ctlAmountRegExVal = document.getElementById(m_oRegExValidatorAmountID);
    var ctlRequired = document.getElementById(lblAmtRequiredMarkerID);
    //ViM on 2/4/08 for CR292496-013008
    // Value comparison is sufficient here. No need to compare type. Replacing === with ==
    if (setGivingLevel(r) == -1)
    {
        ctlAmount.disabled = false;
        if (ctlAthon !==  null)
        {
            ctlAthon.disabled = false;
        }
        try
        {
            ctlAmountReqVal.enabled = true;
            ctlAmountCmpVal.enabled = true;
            //ctlAmountRegExVal.enabled = true;
        }
        catch(e) {}
        ctlRequired.style.visibility = 'visible';
    }
    else
    {
        if (ctlAmount !==  null)
        {
            ctlAmount.disabled = true;
            ctlAmount.value = '';
        }
        if (ctlAthon !==  null)
        {
            ctlAthon.disabled = true;
        }
        try
        {
            ctlAmountReqVal.enabled = false;
            ctlAmountCmpVal.enabled = false;
            //ctlAmountRegExVal.enabled = false;
        }
        catch(e) {}
        if (ctlRequired !==  null)
        {
            ctlRequired.style.visibility = 'hidden';
        }
    }
}

function setGivingLevel(r)
{
    var ctlHidden = document.getElementById(HiddenIDID);
    var level = r.parentNode.attributes.getNamedItem('itemIndex').nodeValue;
    ctlHidden.value = level;
    return level;
}

function DonationGiftAidHelp()
{
    var sFeatures = 'WIDTH=510px,HEIGHT=425px,RESIZABLE=YES,SCROLLBARS=NO,TOOLBAR=NO,LEFT=5,TOP=20,location=No;status=No';
    var oPopUp = new PopUpDialogBB('~/Admin/DonationHelp.ascx', '_blank', sFeatures, '&mode=4');
    oPopUp.Show();
}

function ddlTribute_OnChange(ddl)
{
    var chkAcknowledge = document.getElementById(chkAcknowledgeID);
    var m_oReqValidator_TribName = document.getElementById(m_oReqValidator_TribNameID);
    var tdTributeRequiredMarker = document.getElementById(tdTributeRequiredMarkerID);
    if (!suppressTributeDesc)
    {
        var m_oReqValidator_TribDesc = document.getElementById(m_oReqValidator_TribDescID);
        var txtTributeDescription = document.getElementById(txtTributeDescriptionID);
        var tdTributeDescRequiredMarker = document.getElementById(tdTributeDescRequiredMarkerID);
    }
    
    if ((ddl.selectedIndex !== 0) || (chkAcknowledge.checked))
    {
        if (m_oReqValidator_TribName !== null)
        {
            m_oReqValidator_TribName.enabled = true;
        }
        if (tdTributeRequiredMarker)
        {
            tdTributeRequiredMarker.style.visibility = 'visible';
        }
        if (ddl.selectedIndex !== 0)
        {
            if (txtTributeDescription)
            {
                txtTributeDescription.disabled = false;
            }
            if (tdTributeDescRequiredMarker)
            {
                tdTributeDescRequiredMarker.style.visibility = 'visible';
            }
            try
            {
                if (m_oReqValidator_TribDesc)
                {
                    m_oReqValidator_TribDesc.enabled = true;
                }
                var w = ddl.selectedIndex;
                var selected_text = ddl.options[w].text;
                if (m_oReqValidator_TribDesc)
                {
                    m_oReqValidator_TribDesc.errormessage = selected_text + ' Description: Required';
                }
            }
            catch(e) {}
        }
        else
        {
            if (txtTributeDescription)
            {
                txtTributeDescription.disabled = true;
            }
            if (m_oReqValidator_TribDesc)
            {
                m_oReqValidator_TribDesc.enabled = false;
            }
            if (tdTributeDescRequiredMarker)
            {
                tdTributeDescRequiredMarker.style.visibility = 'hidden';
            }
        }
    }
    else
    {
        if (txtTributeDescription)
        {
            txtTributeDescription.disabled = true;
        }
        if (tdTributeRequiredMarker)
        {
            tdTributeRequiredMarker.style.visibility = 'hidden';
        }
        if (tdTributeDescRequiredMarker)
        {
            tdTributeDescRequiredMarker.style.visibility = 'hidden';
        }
        
        try
        {
            m_oReqValidator_TribName.enabled = false;
            if (m_oReqValidator_TribDesc)
            {
                m_oReqValidator_TribDesc.enabled = false;
            }
        }
        catch(e) {}
    }
}

function ddlDesignations_OnChange(ddl)
{
    var m_oReqValidator_Designation = document.getElementById(m_oReqValidator_DesignationID);
    var trDesignationOther = document.getElementById(trDesignationOtherID);
    if (ddl.value === DESIGNATION_OTHER)
    {
        m_oReqValidator_Designation.enabled = true;
        trDesignationOther.style.visibility = '';
    }
    else {
        m_oReqValidator_Designation.enabled = false;
        trDesignationOther.style.visibility = 'hidden';
    }
}

function chkDonationReady_OnClick()
{
    var chkDonationReady = document.getElementById(chkDonationReadyID);
    var btnNext = document.getElementById(btnNextID);
    btnNext.disabled = !chkDonationReady.checked;
}

function donationToggleECards()
{
    if ($get(donationSendAnECardID).checked)
    {
        $get(trECardsDataID).style.display = "";
    }
    else
    {
        $get(trECardsDataID).style.display = "none";
    }
}

////////////////////////////////////////////
// End of script
if (typeof(Sys) !== 'undefined')
{
    Sys.Application.notifyScriptLoaded();
}
////////////////////////////////////////////
// Do not add any code below this
////////////////////////////////////////////
