﻿/* UserManagement.js */

//Global variable, represents handle to popupradwindow
var popupWindow;
var loginPopupWindow;

function onPerfomUpdateItemsSelection(chkSelectedID, itemID) {

    var checkItem = document.getElementById(chkSelectedID);
  
    Amway.Core.Web.UI.UserManagement.Renewal.AutoRenewalOrderControl.UpdateSelectedItems(itemID, checkItem.checked);
}

function loadPrices(checkboxId) {

    blockPageNoValidation();

    var controlLookupTable = new Array();
    var selectedProducts = new Array();

    for (var i = 0; i < ControlProductLinks.length; i++) {
        controlLookupTable[ControlProductLinks[i].SKU] = ControlProductLinks[i].PriceClientID;
        if ($("#" + ControlProductLinks[i].TriggerClientID).is(":checked")) {
            selectedProducts.push(ControlProductLinks[i].SKU);
        }
    }

    Amway.Core.Web.UI.UserManagement.Registration.RegistrationItemsControl.UpdateCartPrices(
    selectedProducts,
    function(returnVal) {
        var summaryControlDTO = returnVal.value;
        var productPriceDTOs = summaryControlDTO.ProductPriceDTOs;

        for (var i = 0; i < productPriceDTOs.length; i++) {
            $('#' + controlLookupTable[productPriceDTOs[i].ProductSKU]).html(productPriceDTOs[i].Price);
        }

        if (summaryControlDTO.AOBOData != null) {
            //Decides what rows to show/hide
            ShowHideSummaryControlRowsWithAOBO(_summaryControl, summaryControlDTO.Data, summaryControlDTO.AOBOData);
            RefreshSummaryControlAmounts(_summaryControl, summaryControlDTO.Data);
            RefreshSummaryControlAmounts(_summaryControlAOBO, summaryControlDTO.AOBOData);
            //Shows the AOBO column
            $('.MC_LYT_OS_AOBOOrder').show();
        }
        else {
            //Decides what rows to show/hide
            ShowHideSummaryControlRows(_summaryControl, summaryControlDTO.Data);
            RefreshSummaryControlAmounts(_summaryControl, summaryControlDTO.Data);
            //Hides the AOBO column
            $('.MC_LYT_OS_AOBOOrder').hide();
        }
        unblockPage();

    },
    null,
    null,
    null,
    function(bValue) {
        //alert('Request Timed Out.');
        unblockPage();
    });
}

function loadRenewalPrices(jqueryCheckBox) {
    
    blockPageNoValidation();

    var selectedProducts = new Array();
    
    $(".registrationItemCheckBox").find('input[type=checkbox]:checked').each(
            function(intIndex) {            
                var sku = $(this).attr('SKU');
                selectedProducts.push(sku);
                });

                Amway.Core.Web.UI.UserManagement.Registration.RegistrationItemsGridControl.GetSelectedProductSummary(
        selectedProducts,
        function(returnVal) {
            var summaryControlDTO = returnVal.value;
            if (summaryControlDTO != null) {

                //foreachCheckbox that is checked, find the sku, and update the price.
                $(".registrationItemCheckBox").find("input[type=checkbox]").each(
                function(intIndex) {
                    var sku = $(this).attr('SKU');
                    var targetPriceControlId = $(this).attr('targetPriceControlID');
                    var targetControl = $('#' + targetPriceControlId);

                    for (var i = 0; i < summaryControlDTO.ProductPriceDTOs.length; i++) {
                        if (summaryControlDTO.ProductPriceDTOs[i].ProductSKU == $(this).attr('SKU')) {
                            targetControl.html(summaryControlDTO.ProductPriceDTOs[i].Price);
                        }
                    }
                });
                UpdateSummaryPrices(summaryControlDTO);                
            }
            unblockPage();
        },
        null,
        null,
        null,
        function(bValue) {
            //alert('Request Timed Out.');
            unblockPage();
        });       
}


function UpdateSummaryPrices(summaryControlDTO) {
        if (summaryControlDTO.AOBOData != null) {
            //Decides what rows to show/hide
            ShowHideSummaryControlRowsWithAOBO(_summaryControl, summaryControlDTO.Data, summaryControlDTO.AOBOData);
            RefreshSummaryControlAmounts(_summaryControl, summaryControlDTO.Data);
            RefreshSummaryControlAmounts(_summaryControlAOBO, summaryControlDTO.AOBOData);
            //Shows the AOBO column
            $('.MC_LYT_OS_AOBOOrder').show();
        }
        else {
            //Decides what rows to show/hide
            ShowHideSummaryControlRows(_summaryControl, summaryControlDTO.Data);
            RefreshSummaryControlAmounts(_summaryControl, summaryControlDTO.Data);
            //Hides the AOBO column
            $('.MC_LYT_OS_AOBOOrder').hide();        } 

}

// Change login button enabled/disabled based on username and password textboxes are entered
function EnableLoginButton(username, password, btnLogin) {
    if (btnLogin != '') {
        var usernameId = document.getElementById(username);
        var pwdId = document.getElementById(password);
        var loginButtonId = document.getElementById(btnLogin);
        var loginButtonEnable = document.getElementById('libtn_' + btnLogin);
        if (usernameId.value.trim().length > 0 && pwdId.value.trim().length > 0) {
            loginButtonId.disabled = false;
            loginButtonEnable.className = "btn_primary";
        }
        else {
            loginButtonId.disabled = true;
            loginButtonEnable.className = "btn_disabled";
        }
    }
}

function DisableLoginButton(btnLogin) {
    var loginButtonId = document.getElementById(btnLogin);
    var loginButtonEnable = document.getElementById('libtn_' + btnLogin);
    loginButtonId.disabled = true;
    loginButtonEnable.className = "btn_disabled";
}

// Set the focus on the usernametextbox or pwdtextbox based on userid
function Test() {
    var loginPanel = document.getElementById('loginButtonPanel');
    loginPanel.disabled = true;
}

function SetFocus(userid, usertext, pwdtext) {
    var userid = document.getElementById(userid);
    var username = document.getElementById(usertext);
    var pwd = document.getElementById(pwdtext);
    if (userid != null) {

        if (userid.value.length > 0) {
            pwd.focus();
        }
    }
    else { username.focus(); }
}

function returnFalse() {
    return false;
}

function enableLinkButton(clientID) {
    document.getElementById(clientID).disabled = "";
    document.getElementById(clientID).onclick = "";
}

function disableLinkButton(clientID) {
    document.getElementById(clientID).disabled = "disabled";
    document.getElementById(clientID).onclick = returnFalse;
}


/*Description: This method is called when MultipleProfile dropdownlist's selected index is changed. It sets the selected index to a hidden control and
sets the hidden control which tells whether MultipleProfile dropdownlist is clicked or not to True.
Parameters:
ddlMultiProfileId                 : MultipleProfile dropdownlist's client id
hdnMultiProfilelSelectedValue :Client id of the hidden control which stores SortBy dropdownlist's selected value
*/
function storeMultipleProfileDdlSelectedValue(ddlMultiProfileId, hdnMultiProfilelSelectedValue) {
    document.getElementById(hdnMultiProfilelSelectedValue).value = document.getElementById(ddlMultiProfileId).options[document.getElementById(ddlMultiProfileId).selectedIndex].value;
}

function storeNumberOfFailedAttempt(hdnNumberOfAttempt) {
    document.getElementById(hdnNumberOfAttempt).value = parseInt(document.getElementById(hdnNumberOfAttempt).value) + 1;
}

//Description: This method is to close the login popradwindow opened
function closePopupWindow(dopostback) {
    if (parent.popupWindow != null) {
        parent.loginPopupWindow.Close();
    }
    if (dopostback != "false") {
        window.parent.location.reload(true);
    }
}

//Description: This method is to close the login popradwindow opened and redirect to theAmwayHome page
function closePopupWindowRedirectTo(redirectionUrl) {
    if (parent.loginPopupWindow != null) {
        if (parent.loginPopupWindow._wndMgr != null) {
            parent.loginPopupWindow._wndMgr.Close();
        }
        else { parent.loginPopupWindow.Close(); }
    }
    parent.window.location = redirectionUrl;
    return false;
}

//Description: This method is to close the login popradwindow opened and redirect to theAmwayHome page
function closePopupWindowRedirectToSuccessfullPage(redirectionUrl) {
    window.location = redirectionUrl;
}

//Description: This method is to close the login popradwindow opened
function closePopupWindowNoRefresh() {
    parent.loginPopupWindow.Close();
}

//Description: Method to intialize the handle to login popupradwindow 
function onWindowShow(sender, args) {
    loginPopupWindow = sender;
}

function updatePopupWindowSize(height, width) {
    //popupWindow will always be null because it is not longer assigned in showPopup
    if (parent.popupWindow != null) {
        parent.popupWindow._wndRef.SetWidth(width);
        parent.popupWindow._wndRef.SetHeight(height);
    }
}

function showPopup(controlId, pageUrl) {
    var options = { resize: true };
    options.OnClientClose = OnAmwayPopupClientBeforeClose;
    var wnd = new AmwayPopupWindow(controlId, options);
    wnd.showWindow(pageUrl);
    return false;
}


function SetContinueButton(continueButton, type, profileCombo, hdnMultiProfilelSelectedValue) {
    if (continueButton != '') {
        var continueButtonEnable = document.getElementById('libtn_' + continueButton);
        var continueButtonId = document.getElementById(continueButton);
        var profileComboId = document.getElementById(profileCombo);
        if (profileComboId.value != 0) {
            continueButtonId.disabled = false;
            MapToCSS(continueButtonId, continueButtonEnable, type);
        }
        else {
            continueButtonId.disabled = true;
            MapToCSS(continueButtonId, continueButtonEnable, type);
        }

    }
    storeMultipleProfileDdlSelectedValue(profileCombo, hdnMultiProfilelSelectedValue);
}

function OnSelectedIndexChange(hiddenField, DropDown) {

    var stateObj = document.getElementById(DropDown);
    document.getElementById(hiddenField).value = stateObj.value;

}

function setPostalCodeEnabled(enabled, pnlZipCode, valZip1, valZip2, valRegexZip1, tbxZip1, tbxZip2) {
    var panelZip = document.getElementById(pnlZipCode);

    if (!enabled) {
        panelZip.style.display = "none";
        ValidatorEnable(document.getElementById(valZip1), false);
        ValidatorEnable(document.getElementById(valZip2), false);
        ValidatorEnable(document.getElementById(valRegexZip1), false);
    }
    else {
        if (panelZip != null) {

            panelZip.style.display = "block";
        }

        ValidatorEnable(document.getElementById(valZip1), true);
        ValidatorEnable(document.getElementById(valZip2), true);
        ValidatorEnable(document.getElementById(valRegexZip1), true);
    }

    if (tbxZip1 != '') {
        document.getElementById(tbxZip1).value = '';
    }

    if (tbxZip2 != '') {
        document.getElementById(tbxZip2).value = '';
    }
}

function OnSelectedIndexChangeAddress(hiddenField, DropDown, valZip1, valZip2, valRegexZip1, pnlZipcode, valStateList, tbxZip1, tbxZip2) {

    var stateObj = document.getElementById(DropDown);
    var panelZip = document.getElementById(pnlZipcode);
    document.getElementById(hiddenField).value = stateObj.value.substring(0, 2);
    var pos = stateObj.value.indexOf(':');

    if (pos > 0) {
        if (stateObj.value.substring(3, stateObj.value.length).toUpperCase() == 'TRUE') {
            setPostalCodeEnabled(false, pnlZipcode, valZip1, valZip2, valRegexZip1, tbxZip1, tbxZip1, tbxZip2);
        }
        else {
            setPostalCodeEnabled(true, pnlZipcode, valZip1, valZip2, valRegexZip1, tbxZip1, tbxZip1, tbxZip2);
        }
    }
    if (document.getElementById(DropDown).value == null || document.getElementById(DropDown).value == '') {

        ValidatorEnable(document.getElementById(valStateList), true);
    }
    else {

        ValidatorEnable(document.getElementById(valStateList), false);
    }
    // for Address verification popup
    if (typeof ChangeTextForButtons == "function") {
        ChangeTextForButtons();
    }
}
function OnSelectedIndexChangePhoneType(DropDown, saveButton, hiddenField) {

    var phoneTypeObj = document.getElementById(DropDown);

    document.getElementById(hiddenField).value = phoneTypeObj.value;
    OnSelectedIndexChangePersonalInfo(DropDown, saveButton);
}
function OnSelectedIndexChangePreferences(hiddenField, DropDown, btnSave, hdnInvalid) {

    var Obj = document.getElementById(DropDown);
    document.getElementById(hiddenField).value = Obj.value;
    if (btnSave != '') {

        var SaveButtonId = document.getElementById(btnSave);

        var SaveButtonappendedID = document.getElementById('libtn_' + btnSave);

        SaveButtonId.disabled = false;
        SaveButtonappendedID.className = "btn_primary";

    }

}
function CheckForSamePrimaryandSecondary(hiddenField, DropDown, btnSave) {

    OnSelectedIndexChangePreferences(hiddenField, DropDown, btnSave);
}
function EnablePreferencesSaveButton(btnSave) {
    if (btnSave != '') {

        var SaveButtonId = document.getElementById(btnSave);

        var SaveButtonappendedID = document.getElementById('libtn_' + btnSave);

        SaveButtonId.disabled = false;
        SaveButtonappendedID.className = "btn_primary";

    }
}

//At some point these parameters should be moved to client side vars, the list is getting long
function PopulatePrimaryAddress(cbxClientId, City, AddressFirst, AddressSecond, ZipCodeOne, ZipCodeTwo, State, hidden, country, panelZip, valZip1, valZip2, valRegexZip1, includeOffshore) {

    Amway.Core.Web.UI.Common.AddressControl.PopulatePrimaryAddress(document.getElementById(cbxClientId).checked, function(response) {
        if (response.error != null) {
            var errorMessage = response.error.Message;
        }
        if (response.value != null) {
            //If the region is offshore, we dont want to show the postal code
            if (response.value.RegionType == 'OffShore') {
                setPostalCodeEnabled(false, panelZip, valZip1, valZip2, valRegexZip1, ZipCodeOne, ZipCodeTwo);
            }
            else {
                setPostalCodeEnabled(true, panelZip, valZip1, valZip2, valRegexZip1, ZipCodeOne, ZipCodeTwo);
            }

            var regionSelection = response.value.RegionCode.trim();

            if (includeOffshore) {
                //Tack on offshore identification so the correct item in the dropdown can be selected
                regionSelection += response.value.RegionType == 'OffShore' ? ":True" : ":False";
            }

            document.getElementById(hidden).value = response.value.RegionCode.trim();
            document.getElementById(State).value = regionSelection;
            document.getElementById(City).value = response.value.City;
            document.getElementById(AddressFirst).value = response.value.Line1;
            document.getElementById(AddressSecond).value = response.value.Line2;

            if (country == 'US') {
                document.getElementById(ZipCodeOne).value = response.value.PostalCode.substring(0, 5);
                document.getElementById(ZipCodeTwo).value = response.value.PostalCode.substring(5, 9);
            }
            if (country == 'CA') {
                document.getElementById(ZipCodeOne).value = response.value.PostalCode.substring(0, 3);
                document.getElementById(ZipCodeTwo).value = response.value.PostalCode.substring(3, 6);
            }
            // Apply update to validation based on any changes we just made
            if (response.valueOf.RegionType != 'OffShore') {
                ValidatorValidate(document.getElementById(valZip1));
                ValidatorValidate(document.getElementById(valZip2));
                ValidatorValidate(document.getElementById(valRegexZip1));
            }

        }
    });
}

function PopulateShippingAddressInRegistration(cbxClientId, sCity2, sAddressShipLine1, sAddressShipLine2, sZipCodeShip1, sZipCodeShip2, sState2, shidden, mCity2, mAddressShipLine1, mAddressShipLine2, mZipCodeShip1, mZipCodeShip2, mState2, mhidden, sLine1Req, sCityReq, sStateReq, sZip1Req, sZipReq) {
    if (document.getElementById(cbxClientId).checked) {
        document.getElementById(shidden).value = document.getElementById(mhidden).value;
        document.getElementById(sState2).value = document.getElementById(mState2).value;
        document.getElementById(sCity2).value = document.getElementById(mCity2).value;
        document.getElementById(sAddressShipLine1).value = document.getElementById(mAddressShipLine1).value;
        document.getElementById(sAddressShipLine2).value = document.getElementById(mAddressShipLine2).value;
        document.getElementById(sZipCodeShip1).value = document.getElementById(mZipCodeShip1).value;
        document.getElementById(sZipCodeShip2).value = document.getElementById(mZipCodeShip2).value;

        if (document.getElementById(sAddressShipLine1).value != null) {
            document.getElementById(sLine1Req).style.display = 'none';
        }
        if (document.getElementById(sCity2).value != null) {
            document.getElementById(sCityReq).style.display = 'none';
        }
        if (document.getElementById(sState2).value != null) {
            document.getElementById(sStateReq).style.display = 'none';
        }
        if (document.getElementById(sZipCodeShip1).value != null) {
            document.getElementById(sZip1Req).style.display = 'none';
            document.getElementById(sZipReq).style.display = 'none';
        }
    }
    else {
        document.getElementById(shidden).value = '';
        document.getElementById(sState2).value = '';
        document.getElementById(sCity2).value = '';
        document.getElementById(sAddressShipLine1).value = '';
        document.getElementById(sAddressShipLine2).value = '';
        document.getElementById(sZipCodeShip1).value = '';
        document.getElementById(sZipCodeShip2).value = '';
    }

}

function PopulateRegistrationAddress(cbxClientId, sCity2, sAddressShipLine1, sAddressShipLine2, sZipCodeShip1, sZipCodeShip2, sState2, shidden, strAddLine1, strAddLine2, strCity, strState, strZip, sLine1Req, sCityReq, sStateReq, sZipReq, countryCode) {
    if (document.getElementById(cbxClientId).checked) {
        document.getElementById(shidden).value = strState;
        document.getElementById(sState2).value = strState;
        document.getElementById(sCity2).value = strCity;
        document.getElementById(sAddressShipLine1).value = strAddLine1;
        document.getElementById(sAddressShipLine2).value = strAddLine2;
        if (countryCode == 'US') {
            document.getElementById(sZipCodeShip1).value = strZip.substring(0, 5);
            document.getElementById(sZipCodeShip2).value = strZip.substring(5, 9);
        }
        if (countryCode == 'CA') {
            document.getElementById(sZipCodeShip1).value = strZip.substring(0, 3);
            document.getElementById(sZipCodeShip2).value = strZip.substring(3, 6);
        }
        if (document.getElementById(sAddressShipLine1).value != null) {
            document.getElementById(sLine1Req).style.display = 'none';
        }
        if (document.getElementById(sCity2).value != null) {
            document.getElementById(sCityReq).style.display = 'none';
        }
        if (document.getElementById(sState2).value != null) {
            document.getElementById(sStateReq).style.display = 'none';
        }
        if (document.getElementById(sZipCodeShip1).value != null) {
            document.getElementById(sZipReq).style.display = 'none';
        }
    }
    else {
        document.getElementById(shidden).value = '';
        document.getElementById(sState2).value = '';
        document.getElementById(sCity2).value = '';
        document.getElementById(sAddressShipLine1).value = '';
        document.getElementById(sAddressShipLine2).value = '';
        document.getElementById(sZipCodeShip1).value = '';
        document.getElementById(sZipCodeShip2).value = '';
    }

}
function EnableDisableEmailBoxes(cbxOffers, cbxNewsLetters, valEmail, valRegExpEmail, valReqReEnterEmail, valExpReEnterEmail, valCmpEmail, tbxEmailId, tbxReEnterEmail, cbxNoEmaild, hdnEmailId, valAuxValidatorId) {

    var CheckBoxExists = document.getElementById(cbxNoEmaild);
    if (CheckBoxExists != null) {

        if (document.getElementById(cbxNoEmaild).checked == true) {
            document.getElementById(tbxReEnterEmail).value = '';
            document.getElementById(tbxEmailId).value = '';
            document.getElementById(tbxEmailId).disabled = true;
            document.getElementById(tbxReEnterEmail).disabled = true;
            document.getElementById(tbxReEnterEmail).value = '';
            ValidatorEnable(document.getElementById(valEmail), false);
            ValidatorEnable(document.getElementById(valRegExpEmail), false);
            ValidatorEnable(document.getElementById(valReqReEnterEmail), false);
            ValidatorEnable(document.getElementById(valExpReEnterEmail), false);
            ValidatorEnable(document.getElementById(valCmpEmail), false);
            if (document.getElementById(cbxOffers) != null) {
                document.getElementById(cbxOffers).disabled = true;
            }
            if (document.getElementById(cbxNewsLetters) != null) {
                document.getElementById(cbxNewsLetters).disabled = true;
            }
            if (document.getElementById(hdnEmailId) != null) {
                document.getElementById(hdnEmailId).value = "checked";
            }
            // optional, used for "phone or email" validation in registration
            if (valAuxValidatorId.length > 0) {
                ValidatorEnable($get(valAuxValidatorId), true);
            }
        }
        else {
            if (document.getElementById(tbxEmailId) != null) {

                document.getElementById(tbxEmailId).disabled = false;
            }
            if (document.getElementById(tbxReEnterEmail) != null) {
                document.getElementById(tbxReEnterEmail).disabled = false;
            }
            ValidatorEnable(document.getElementById(valEmail), true);
            ValidatorEnable(document.getElementById(valRegExpEmail), true);
            ValidatorEnable(document.getElementById(valReqReEnterEmail), true);
            ValidatorEnable(document.getElementById(valExpReEnterEmail), true);
            ValidatorEnable(document.getElementById(valCmpEmail), true);
            if (document.getElementById(cbxOffers) != null) {
                document.getElementById(cbxOffers).disabled = false;
            }
            if (document.getElementById(cbxNewsLetters) != null) {
                document.getElementById(cbxNewsLetters).disabled = false;
            }
            if (document.getElementById(hdnEmailId) != null) {
                document.getElementById(hdnEmailId).value = "unchecked";
            }
            // optional, used for "phone or email" validation in registration
            if (valAuxValidatorId.length > 0) {
                ValidatorEnable($get(valAuxValidatorId), false);
            }
        }
    }

}
function MapToCSS(continueButtonId, continueButtonEnable, type) {
    switch (type) {
        case "Secondary":
            if (continueButtonId.disabled) {
                continueButtonEnable.className = "btn_disabled";
            } else {
                continueButtonEnable.className = "btn_secondary";
            }
        default:
            if (continueButtonId.disabled) {
                continueButtonEnable.className = "btn_disabled";
            } else {
                continueButtonEnable.className = "btn_primary";
            }
    }
}
function IBOInformationVisible(checkBoxId, divId, iboNumberId, iboKeyId, sponsorTypeId) {

    if (document.getElementById(checkBoxId).checked == true) {
        document.getElementById(divId).style.display = "block";
    }
    else {
        document.getElementById(divId).style.display = "none";
        document.getElementById(iboNumberId).value = "";
        document.getElementById(iboKeyId).value = "";
    }
}

function expandcollapse(pnlId, img, hdnCoReg) {
    var pnl = document.getElementById(pnlId);
    var img = document.getElementById(img);
    if (pnl.style.display == "none") {
        pnl.style.display = "block";
        img.src = "../Images/ico_minimize.gif";
        document.getElementById(hdnCoReg).value = "expand";
    }
    else {
        pnl.style.display = "none";
        img.src = "../Images/ico_maximize.gif";
        document.getElementById(hdnCoReg).value = "collaspe";
    }
}

function SelectOnlyOne(radioButtonId, dataGridId, customerId, hdnSearchIBOOption) {
    var rdo = document.getElementById(radioButtonId);
    var grid = document.getElementById(dataGridId);
    var all = document.getElementsByTagName("input");
    for (i = 0; i < all.length; i++) {

        if (all[i].type == "radio" && all[i].id != rdo.id) {
            var count = all[i].id.indexOf(dataGridId);
            if (count != -1) {
                all[i].checked = false;
            }
        }
    }

    document.getElementById($get(hdnCustomerId).id).value = customerId;
    $get(hdnSearchIBOCustomerId).value = customerId;

    var SearchIBOOption = document.getElementById(hdnSearchIBOOption);

    var searchOption = document.getElementById($get(hdnIBOSearchOption).id);

    if (searchOption != null) {
        searchOption.value = SearchIBOOption.value;
    }

    rdo.checked = true;
}


function ShowHide(controlid, panelid) {

    var pnl = document.getElementById(panelid);

    if (pnl.style.display == 'none') {
        pnl.style.display = 'block';
        ValidatorEnable(document.getElementById(controlid), true);
        return false;
    }
    else {
        pnl.style.display = 'none';
        ValidatorEnable(document.getElementById(controlid), false);
        return false;
    }
}


function ApplyMask(maskedFieldId, hiddenFieldId, reqValId, regValId) {

    var maskedField = document.getElementById(maskedFieldId);
    var hiddenField = document.getElementById(hiddenFieldId);

    if (maskedField != null && hiddenField != null) {
        if (maskedField.value.indexOf('*') == -1) {
            hiddenField.value = maskedField.value;
            if (hiddenField.value.trim() != '') {
                maskedField.value = '**************';
            }
        }
    }
    if (reqValId != null) {
        var reqVal = document.getElementById(reqValId);
        ValidatorEnable(reqVal, true);
    }

    if (regValId != null) {
        var regVal = document.getElementById(regValId);
        ValidatorEnable(regVal, true);
    }
}

function ShowHidePanel(firstvalidator, secondvalidator, panelid) {

    var pnl = document.getElementById(panelid);

    if (pnl.style.display == 'none') {
        pnl.style.display = 'block';
        ValidatorEnable(document.getElementById(firstvalidator), true);
        ValidatorEnable(document.getElementById(secondvalidator), true);
        return false;
    }
    else {
        pnl.style.display = 'none';
        ValidatorEnable(document.getElementById(firstvalidator), false);
        ValidatorEnable(document.getElementById(secondvalidator), false);
        return false;
    }
}

function SetSearchIBOOption() {

    ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), false);
    ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), false);
    document.getElementById(valReqIBONumSearchIBO).style.display == 'none';
    ValidatorEnable(document.getElementById(valReqIBONumSearchIBO), true);
    ValidatorValidate(document.getElementById(valReqIBONumSearchIBO));


    if (document.getElementById(valReqIBONumSearchIBO).style.display == 'none') {

        var SearchIBOOption1 = document.getElementById(radlstConnectToIBOOptions + '_0');

        var SearchIBOOption2 = document.getElementById(radlstConnectToIBOOptions + '_1');

        if (SearchIBOOption1.checked == true) {
            var searchOption1 = document.getElementById($get(hdnIBOSearchOption).id);

            if (searchOption1 != null) {
                searchOption1.value = SearchIBOOption1.value;
            }
        }
        if (SearchIBOOption2.checked == true) {
            var searchOption2 = document.getElementById($get(hdnIBOSearchOption).id);

            if (searchOption2 != null) {
                searchOption2.value = SearchIBOOption2.value;
            }
        }
        return true;
    }
    else { return false; }
}

function ShowAgeErrorPanel(radioButton, divError, hdnId, hdnClientId, parentButtonId) {

    var radio = document.getElementById(radioButton);
    var inputElement = radio.getElementsByTagName('INPUT');

    if (inputElement[0].checked) {
        document.getElementById(divError).style.display = "none";
        document.getElementById(parentButtonId).style.display = "block";
        document.getElementById(hdnId).value = "Yes";
        document.getElementById(hdnClientId).value = "Yes";
    }
    else {
        document.getElementById(divError).style.display = "block";
        document.getElementById(parentButtonId).style.display = "none";
        document.getElementById(hdnId).value = "No";
        document.getElementById(hdnClientId).value = "No";
    }


}

//Validate phone number for 10 digit US numbers.

function maskPhone(hiddenPhoneFieldId, phoneFieldId, regValId) {
    var num = document.getElementById(phoneFieldId).value.replace(/[^\d]/g, '');

    document.getElementById(hiddenPhoneFieldId).value = num;
    if (regValId != null) {
        var regVal = document.getElementById(regValId);
        ValidatorEnable(regVal, true);
    }
    if (num.length == 10) {
        document.getElementById(phoneFieldId).maxLength = 14;
        document.getElementById(phoneFieldId).value = "(" + num.substring(0, 3) + ") " + num.substring(3, 6) + "-" + num.substring(6);
    }
}

function unmaskPhone(hiddenPhoneFieldId) {
    var num = document.getElementById(hiddenPhoneFieldId).value.replace(/[^\d]/g, '');

    document.getElementById(hiddenPhoneFieldId).maxLength = 10;
    document.getElementById(hiddenPhoneFieldId).value = num;
}


function ShowSponsorDetailYesPanel(radioButtonId, dvRefIBO, dvSearchIBO) {
    var radioButton = document.getElementById(radioButtonId);
    if (radioButton.checked) {
        document.getElementById(dvRefIBO).style.display = "block";
        document.getElementById(dvSearchIBO).style.display = "none";
        //        var hdnRadioId = document.getElementById('ctl00_PlaceHolderMain_ctl00___hdnRadioId');
        //        if (hdnRadioId != null) {
        //          hdnRadioId.value = "RefIBO";
        //      }
        if (typeof (hdnradioIdParent) == "string") {
            var hdnRadioId = $get(hdnradioIdParent);
        }

        if (hdnRadioId != null) {
            hdnRadioId.value = "RefIBO";
        }
    }

}

function ShowSponsorDetailNoPanel(radioButtonId, dvRefIBO, dvSearchIBO, dvIBOResult, lblInvalidIBO, tbxIBOKey, tbxIBONum, lblRefIBO, radDoNotConnect) {
    var radioButton = document.getElementById(radioButtonId);
    var noConnectRadioButon = document.getElementById(radDoNotConnect);

    //noConnectRadioButon.style.visibility = "visible";
    noConnectRadioButon.style.display = "block";

    if (radioButton.checked) {

        document.getElementById(dvRefIBO).style.display = "none";
        document.getElementById(dvSearchIBO).style.display = "block";
        document.getElementById(tbxIBOKey).value = '';
        document.getElementById(tbxIBONum).value = '';

        var lbl = document.getElementById(lblRefIBO);

        if (lbl != null) {
            lbl.value = '';
        }

        if (typeof (divShareInfoSearchControl) == "string") {
            var divShare = $get(divShareInfoSearchControl);
        }
        if (divShare != null) {
            divShare.style.display = "none";
        }

        if (typeof (divSponsorSearchResults) == "string") {
            var divSponsorSearch = $get(divSponsorSearchResults);
        }
        if (divSponsorSearch != null) {
            divSponsorSearch.style.display = "none";
        }

        //var hdnRadioId = document.getElementById('ctl00_PlaceHolderMain_ctl00___hdnRadioId');
        if (typeof (hdnradioIdParent) == "string") {
            var hdnRadioId = $get(hdnradioIdParent);
        }
        var zip = null;
        var zip1 = null;
        var hdnState = null;
        var ddlLanguagePreference = null;
        if (typeof (sponsorDetailZipCodeID) == "string") {
            zip = $get(sponsorDetailZipCodeID);
        }

        if (typeof (sponsorDetailZipCode1ID) == "string") {
            zip1 = $get(sponsorDetailZipCode1ID);

        }
        if (typeof (hdnStateParent) == "string") {
            hdnState = $get(hdnStateParent);
        }
        if (typeof (sponsorDetailDdlLanguagePreferenceID) == "string") {
            ddlLanguagePreference = $get(sponsorDetailDdlLanguagePreferenceID);
        }
        if (hdnRadioId != null) {
            hdnRadioId.value = "NoRefIBO";
        }
        if (zip != null && zip1 != null && zip1.value != null) {

            zip.value = zip1.value;
        }
        if (hdnState != null && hdnState.value != null && ddlLanguagePreference != null) {
            var t = hdnState.value;
            for (i = 0; i < ddlLanguagePreference.length; i++) {
                if (ddlLanguagePreference.options[i].value == t) {
                    ddlLanguagePreference.selectedIndex = i;
                }
            }
        }
    }
}


function SetValueById(id, val) {
    var obj = document.getElementById(id)
    if (obj != null) {
        obj.value = val;
    }
}

function SetStyleDisplayById(id, val) {
    var obj = document.getElementById(id)
    if (obj != null) {
        obj.style.display = val;
    }
}

function HideDivForNoSponsor(radioButtonId, dvRefIBO, dvSearchIBO) {

    var radioButton = document.getElementById(radioButtonId);
    if (radioButton.checked) {
        document.getElementById(dvRefIBO).style.display = "none";
        document.getElementById(dvSearchIBO).style.display = "none";
        //        var hdnRadioId = document.getElementById('ctl00_PlaceHolderMain_ctl00___hdnRadioId');
        if (typeof (hdnradioIdParent) == "string") {
            var hdnRadioId = $get(hdnradioIdParent);
        }
        if (hdnRadioId != null) {
            hdnRadioId.value = "NoSponsor";
        }

    }


}

function disableButtonForBonusPayment(clientID) {
    if (document.getElementById(clientID) != null) {
        if (document.getElementById(clientID).disabled) {
            document.getElementById(clientID).disabled = false;
            document.getElementById('libtn_' + clientID).className = "btn_primary";
        }
        if (!document.getElementById(clientID).disabled) {
            document.getElementById(clientID).disabled = true;
            document.getElementById('libtn_' + clientID).className = "btn_disabled";
        }
    }
}

function disableButton(clientID) {
    document.getElementById(clientID).disabled = true;
    document.getElementById('libtn_' + clientID).className = "btn_disabled";
}

function EnableUploadButton(clientID) {
    if (document.getElementById(clientID).disabled) {
        document.getElementById(clientID).disabled = false;
        document.getElementById('libtn_' + clientID).className = "btn_primary";
    }
}
function SetAddressControlValidators(addressID, enabled) {
    var customAddressValidator = document.getElementById(addressID + "_valAddressValidator");
    var careOfNameRequiredValidator = document.getElementById(addressID + "_valCareOfName");
    var careOfRegularExpressionValidator = document.getElementById(addressID + "_valNameAsciiRegex");
    var addressLine1RequiredValidator = document.getElementById(addressID + "_valAddrLine1");
    var addressLine1RegularExpressionValidator = document.getElementById(addressID + "_valAddress1AsciiRegex");
    var addressLine2RegularExpressionValidator = document.getElementById(addressID + "_valCityAsciiRegex");
    var cityRequiredValidator = document.getElementById(addressID + "_valCity");
    var cityRegularExpressionValidator = document.getElementById(addressID + "_valAddress2AsciiRegex");
    var stateListRequiredValidator = document.getElementById(addressID + "_valStateListRequired");
    var zipRequiredValidator = document.getElementById(addressID + "_valZip");
    var zip1RegularExpressionValidator = document.getElementById(addressID + "_valZipAsciiRegex");
    var zip2RegularExpressionValidator = document.getElementById(addressID + "_valZip2AsciiRegex");

    //currently not using careof or line2 may need to implement differently in future if something else requires these 
    var careOfNameRequired = false;
    var addressLine2Required = false;

    if (careOfNameRequiredValidator != null) {
        ValidatorEnable(careOfNameRequiredValidator, (careOfNameRequired && enabled));
    }
    if (addressLine1RequiredValidator != null) {
        ValidatorEnable(addressLine1RequiredValidator, enabled);
    }
    if (cityRequiredValidator != null) {
        ValidatorEnable(cityRequiredValidator, enabled);
    }
    if (stateListRequiredValidator != null) {
        ValidatorEnable(stateListRequiredValidator, enabled);
    }
    if (zipRequiredValidator != null) {
        ValidatorEnable(zipRequiredValidator, enabled);
    }
}

function SetCreditCardControlValidators(creditCardID, enabled) {
    var valCurrentCardNumberRequired = document.getElementById(creditCardID + "_valCurrentCardNumberRequired");
    var valCurrentCardNumberRegex = document.getElementById(creditCardID + "_valCurrentCardNumberRegex");
    var valCurrentCardNumberMod10 = document.getElementById(creditCardID + "_valCurrentCardNumberMod10");
    //var valNewCardNumberValidator = document.getElementById(creditCardID + "_valNewCardNumberValidator");
    var valNewCardNumberRegex = document.getElementById(creditCardID + "_valNewCardNumberRegex");
    var valNewCardNumberMod10 = document.getElementById(creditCardID + "_valNewCardNumberMod10");
    var valCardDescriptionValidator = document.getElementById(creditCardID + "_valCardDescriptionValidator");
    var valCardDescriptionRegex = document.getElementById(creditCardID + "_valCardDescriptionRegex");
    var valCardHolderNameValidator = document.getElementById(creditCardID + "_valCardHolderNameValidator");
    var valCardHolderNameRegex = document.getElementById(creditCardID + "_valCardHolderNameRegex");
    var valCardToAdd = document.getElementById(creditCardID + "_valCardToAdd");
    var valCreditCardRegex = document.getElementById(creditCardID + "_valCreditCardRegex");
    var valCreditCardNumberMod10 = document.getElementById(creditCardID + "_valCreditCardNumberMod10");
    var valCardExpirationMonth = document.getElementById(creditCardID + "_valCardExpirationMonth");
    var valCardExpirationYear = document.getElementById(creditCardID + "_valCardExpirationYear");
    var valCardExpirationDateMonth = document.getElementById(creditCardID + "_valCardExpirationDateMonth");
    var valCardExpirationDateYear = document.getElementById(creditCardID + "_valCardExpirationDateYear");
    var valSecurityCode = document.getElementById(creditCardID + "_valSecurityCode");
    var expSecurityCode = document.getElementById(creditCardID + "_expSecurityCode");
    //var valCurrentCardNumberValidator = document.getElementById(creditCardID + "_valCurrentCardNumberValidator");
    //var valCreditCardNumberValidator = document.getElementById(creditCardID + "_valCreditCardNumberValidator");
    var valCardExpirationDateValidator = document.getElementById(creditCardID + "_valCardExpirationDateValidator");

    if (valCurrentCardNumberRequired != null) ValidatorEnable(valCurrentCardNumberRequired, enabled);
    if (valCurrentCardNumberRegex != null) ValidatorEnable(valCurrentCardNumberRegex, enabled);
    if (valCurrentCardNumberMod10 != null) ValidatorEnable(valCurrentCardNumberMod10, enabled);
    //if (valNewCardNumberValidator != null) ValidatorEnable(valNewCardNumberValidator, enabled);
    if (valNewCardNumberRegex != null) ValidatorEnable(valNewCardNumberRegex, enabled);
    if (valNewCardNumberMod10 != null) ValidatorEnable(valNewCardNumberMod10, enabled);
    if (valCardDescriptionValidator != null) ValidatorEnable(valCardDescriptionValidator, enabled);
    if (valCardDescriptionRegex != null) ValidatorEnable(valCardDescriptionRegex, enabled);
    if (valCardHolderNameValidator != null) ValidatorEnable(valCardHolderNameValidator, enabled);
    if (valCardHolderNameRegex != null) ValidatorEnable(valCardHolderNameRegex, enabled);
    if (valCardToAdd != null) ValidatorEnable(valCardToAdd, enabled);
    if (valCreditCardRegex != null) ValidatorEnable(valCreditCardRegex, enabled);
    if (valCreditCardNumberMod10 != null) ValidatorEnable(valCreditCardNumberMod10, enabled);
    if (valCardExpirationMonth != null) ValidatorEnable(valCardExpirationMonth, enabled);
    if (valCardExpirationYear != null) ValidatorEnable(valCardExpirationYear, enabled);
    if (valCardExpirationDateMonth != null) ValidatorEnable(valCardExpirationDateMonth, enabled);
    if (valCardExpirationDateYear != null) ValidatorEnable(valCardExpirationDateYear, enabled);
    if (valSecurityCode != null) ValidatorEnable(valSecurityCode, enabled);
    if (expSecurityCode != null) ValidatorEnable(expSecurityCode, enabled);
    //if (valCurrentCardNumberValidator != null) ValidatorEnable(valCurrentCardNumberValidator, enabled);
    //if (valCreditCardNumberValidator != null) ValidatorEnable(valCreditCardNumberValidator, enabled);
    if (valCardExpirationDateValidator != null) ValidatorEnable(valCardExpirationDateValidator, enabled);
}
function ShowHideIdentifySponsorPanel(radioButtonId, dvIBOSponsor, strValue, clientId, buttonId) {
    var radioButton = document.getElementById(radioButtonId);
    if (radioButton.checked && strValue == 'yes') {
        document.getElementById(dvIBOSponsor).style.display = "block";
        if (document.getElementById(clientId).checked) {
            document.getElementById(buttonId).disabled = false;
        }
        else {
            document.getElementById(buttonId).disabled = true;
        }
    }
    else if (radioButton.checked && strValue == 'no') {
        document.getElementById(dvIBOSponsor).style.display = "none";
        document.getElementById(buttonId).disabled = false;
        document.getElementById('libtn_' + buttonId).className = "btn_primary";
    }
}


function ChangeOfPhoneDropDownPreferences(labelMessage, DropDownPrimary, DropDownSecondary, btnSave) {



    var ObjPrimary = document.getElementById(DropDownPrimary);
    var ObjSecondary = document.getElementById(DropDownSecondary);

    var SaveButtonId = document.getElementById(btnSave);

    var SaveButtonappendedID = document.getElementById('libtn_' + btnSave);
    if (ObjPrimary.value == '' && ObjSecondary.value == '') {

        document.getElementById(labelMessage).innerHTML = 'Either Primary Day OR Primary Evening must always have a phone number selected';



        SaveButtonId.disabled = true;
        SaveButtonappendedID.className = "btn_disabled";

        return false;
    }
    else {

        document.getElementById(labelMessage).innerHTML = '';
        SaveButtonId.disabled = false;
        SaveButtonappendedID.className = "btn_primary";
    }

}

function ChangeOfEmailDropDownPreferences(labelMessage, DropDownPrimary, DropDownSecondary, btnSave) {

    var ObjPrimary = document.getElementById(DropDownPrimary);
    var ObjSecondary = document.getElementById(DropDownSecondary);

    var SaveButtonId = document.getElementById(btnSave);

    var SaveButtonappendedID = document.getElementById('libtn_' + btnSave);

    if (ObjPrimary.value == ObjSecondary.value && (ObjPrimary.value != "" && ObjSecondary.value != "")) {
        //document.getElementById(labelMessage).innerHTML = 'Primary Mail And Secondary Mail can not be same';
        document.getElementById(labelMessage).style.display = 'block';
        SaveButtonId.disabled = true;
        SaveButtonappendedID.className = "btn_disabled";

        return false;

    }
    else {
        //document.getElementById(labelMessage).innerHTML = '';
        document.getElementById(labelMessage).style.display = 'none';
        SaveButtonId.disabled = false;
        SaveButtonappendedID.className = "btn_primary";
    }

}


function AjaxSubmit(IBONum, IBOKey) {

    ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), true);
    ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), true);
    ValidatorEnable(document.getElementById(valReqIBONumSearchIBO), false);


    var txtIBONum = document.getElementById(IBONum);
    var txtIBOKey = document.getElementById(IBOKey);

    if (txtIBONum.value != '' && txtIBOKey.value != '') {
        Amway.Core.Web.UI.UserManagement.Registration.SponsorDetailControl.AjaxSubmit(txtIBONum.value, txtIBOKey.value, function(response) {
            if (response.error != null) {
                var errorMessage = response.error.Message;

            }
            if (response.value != null) {

                var Array = response.value.split(',');

                if (Array[0] == "") {


                    document.getElementById(lblInvalidIBONumber).innerHTML = '';
                    document.getElementById(lblError).innerHTML = Array[1];

                    var dvIBO = document.getElementById(dvIBOResults);

                    if (dvIBO != null) {
                        dvIBO.style.display = 'none';
                    }
                    document.getElementById(lblInvalidIBONumber).innerHTML = Array[1];
                }
                else {
                    document.getElementById(lblInvalidIBONumber).innerHTML = '';
                    document.getElementById(lblError).innerHTML = '';
                    document.getElementById(lblRefIBO).innerHTML = Array[1];

                    var dvIBO = document.getElementById(dvIBOResults);

                    if (dvIBO != null) {

                        dvIBO.style.display = '';

                    }
                }
            }
        });
    }
}

function SelectOnlyOneIBO(radioButtonId, dataGridId, customerId, hdnCustId) {
    var rdo = document.getElementById(radioButtonId);
    var grid = document.getElementById(dataGridId);
    var all = document.getElementsByTagName("input");
    for (i = 0; i < all.length; i++) {

        if (all[i].type == "radio" && all[i].id != rdo.id) {
            var count = all[i].id.indexOf(dataGridId);
            if (count != -1) {
                all[i].checked = false;
            }
        }
    }
    document.getElementById(hdnCustId).value = customerId;
    rdo.checked = true;
}

function RetainFilePath(filePath, hiddenFieldId) {

    var fileUploadControl = document.getElementById(filePath);
    var hiddenFieldControl = document.getElementById(hiddenFieldId);
    hiddenFieldControl.value = fileUploadControl.value;
}

function OnSelectedIndexChangePersonalInfo(OnChangeControl, btnSave, comparevalidator, primaryEmailTextBox) {
    if (btnSave != '') {

        var SaveButtonId = document.getElementById(btnSave);

        var SaveButtonappendedID = document.getElementById('libtn_' + btnSave);

        SaveButtonId.disabled = false;
        SaveButtonappendedID.className = "btn_primary";

    }
    if (comparevalidator != null) {
        if (primaryEmailTextBox != '') {
            document.getElementById(comparevalidator).valuetocompare = document.getElementById(primaryEmailTextBox).value.trim().toUpperCase();

        }
    }

}
function EnableDateOfBirth(radioButton, valDOB) {
    var dateOfBirthReqMarker = document.getElementById("spanDobMarker");
    var radio = document.getElementById(radioButton);
    var inputElement = radio.getElementsByTagName('INPUT');
    if (inputElement[0].checked) {
        ValidatorEnable(document.getElementById(valDOB), false);
        if (dateOfBirthReqMarker != null) {
            dateOfBirthReqMarker.innerHTML = "";
        }
    }
    else {
        ValidatorEnable(document.getElementById(valDOB), true);
        if (dateOfBirthReqMarker != null) {
            dateOfBirthReqMarker.innerHTML = "*";
        }
    }

}

function OnClickShowHidePanel(panelID) {

    var panel = document.getElementById(panelID);
    if (document.getElementById(panelID).style.display == "none") {
        document.getElementById(panelID).style.display = "block";
    }
    else if (document.getElementById(panelID).style.display == "block") {
        document.getElementById(panelID).style.display = "none";
    }
    return false;
}


function CreateRegistrationCart(productId, chkBox) {
    var additem = document.getElementById(chkBox).checked;
    Amway.Core.Web.UI.UserManagement.Registration.RegistrationItemsControl.AddItems(productId, additem);
}

function textCounter(field, maxlimit) {
    var textBox = document.getElementById(field);
    if (textBox.value.length > maxlimit) // if too long...trim it!
        textBox.value = textBox.value.substring(0, maxlimit);
}
function UplineSponsorPanelVisiblity(checkBoxId, panelId, hdnFieldId) {

    if (document.getElementById(checkBoxId).checked == true) {
        document.getElementById(panelId).style.display = "block";
        document.getElementById(hdnFieldId).value = "checked";
    }
    else {
        document.getElementById(panelId).style.display = "none";
        document.getElementById(hdnFieldId).value = "unchecked";
    }
}
function OnSelectedIndexChangeIBO(hiddenField, DropDown, radioButtonId, valReqField) {

    var stateObj = document.getElementById(DropDown);
    document.getElementById(hiddenField).value = stateObj.value;
    if (stateObj.value == "MAC") {
        document.getElementById(radioButtonId + "_0").disabled = true;
        document.getElementById(radioButtonId + "_1").disabled = true;
        ValidatorEnable(document.getElementById(valReqField), false);
    }
    else {
        document.getElementById(radioButtonId + "_0").disabled = false;
        document.getElementById(radioButtonId + "_1").disabled = false;
        ValidatorEnable(document.getElementById(valReqField), true);
    }

}
function IBOEditLinkValue(hdnField, strValue) {
    document.getElementById(hdnField).value = strValue;
}

/*Toggles the hidden value that indicates whether or not the user is 
editing their existing credit card number*/
function ToggleEditCreditCardNumber(hdnField) {
    var element = document.getElementById(hdnField);

    if (element != null) {
        element.value = element.value == "" || element.value == null || element.value == "true" ? "false" : "true";
    }
}

function EnableCreditCardDescription(checkboxId, pnlCreditCardId, valCreditCard) {
    if (document.getElementById(checkboxId).checked) {
        document.getElementById(pnlCreditCardId).style.display = "block";
        ValidatorEnable(document.getElementById(valCreditCard), true);
    }
    else {
        document.getElementById(pnlCreditCardId).style.display = "none";
        ValidatorEnable(document.getElementById(valCreditCard), false);
    }
}
function BusinessInformationVisible(checkBoxId, divId) {

    if (document.getElementById(checkBoxId).checked == true) {
        document.getElementById(divId).style.display = "block";
    }
    else {
        document.getElementById(divId).style.display = "none";
    }
}


function EnableShipping(checkBoxId, pnlShipping, hdnCoReg, valCareOfName,
valAddrLine1, valCity, valStateListRequired, valZip) {
    var checkbox = document.getElementById(checkBoxId);
    var shippingPanel = document.getElementById(pnlShipping);

    if (checkbox != null && shippingPanel != null) {
        if (checkbox.checked == true) {
            shippingPanel.style.display = "block";
            SetAddressControlRequiredFieldValidators(valCareOfName, valAddrLine1, valCity, valStateListRequired, valZip, true);
        }
        else {
            shippingPanel.style.display = "none";
            document.getElementById(hdnCoReg).value = "collaspe";
            SetAddressControlRequiredFieldValidators(valCareOfName, valAddrLine1, valCity, valStateListRequired, valZip, false);
        }
    }
}

function DisableOrderDetailCheckBox(checkBoxContact, checkBoxOrder, hdnCheckBox) {
    if (document.getElementById(checkBoxContact).checked) {
        document.getElementById(checkBoxOrder).disabled = false;
        document.getElementById(hdnCheckBox).value = "checked";
    }
    else {
        document.getElementById(checkBoxOrder).checked = false;
        document.getElementById(checkBoxOrder).disabled = true;
        document.getElementById(hdnCheckBox).value = "unchecked";
    }
}


/******************************Before WindowClosed******************/
function OnAmwayPopupClientBeforeClose(sender, args) {
    //To handle the OnClientClose event it is better to specify a different method name than 
    //than the one already defined in AmwayPopup.js
    if (typeof sender.dopostback != "undefined" && sender.dopostback != null && sender.dopostback != "true") {
        closePopupWindow(sender.dopostback);
    }
}

function DisableButtonChangePersonalInfo(btnSave) {
    if (btnSave != '') {

        var SaveButtonId = document.getElementById(btnSave);
        //SaveButtonId.disabled = true;
        var SaveButtonappendedID = document.getElementById('libtn_' + btnSave);

        SaveButtonId.disabled = true;
        SaveButtonappendedID.className = "btn_disabled";

    }
}

function PersonalInfoDisableButton(clientIDOne, clientIDTwo) {


    if (clientIDOne != '' && document.getElementById(clientIDOne) != null) {

        document.getElementById(clientIDOne).disabled = true;
        var SaveButtonappendedID = document.getElementById('libtn_' + clientIDOne);
        SaveButtonappendedID.className = "btn_disabled";

    }

    if (clientIDTwo != '' && document.getElementById(clientIDTwo) != null) {

        document.getElementById(clientIDTwo).disabled = true;
        var SaveButtonappendedIDtwo = document.getElementById('libtn_' + clientIDTwo);
        SaveButtonappendedIDtwo.className = "btn_disabled";
    }
    if (document.getElementById('ctl00_PlaceHolderMain_ctl00___ctl02___btnSaveUserInfo') != '' && document.getElementById('ctl00_PlaceHolderMain_ctl00___ctl02___btnSaveUserInfo') != null) {
        var id = document.getElementById('ctl00_PlaceHolderMain_ctl00___ctl02___btnSaveUserInfo');
        id.disabled = true;
        var SaveButtonappendedIDthree = document.getElementById('libtn_ctl00_PlaceHolderMain_ctl00___ctl02___btnSaveUserInfo');
        SaveButtonappendedIDthree.className = "btn_disabled";
    }
}

function PersonalIdentificationDisableButton(clientIDOne) {
    if (document.getElementById(clientIDOne) != null) {
        document.getElementById(clientIDOne).disabled = true;
        var SaveButtonappendedID = document.getElementById('libtn_' + clientIDOne);
        SaveButtonappendedID.className = "btn_disabled";

    }

}
/***********************************/
//Global Nav IBO contact info
//show/hide contact info

function ShowContactInfo(contactInfoDivID, containerDivId) {
    var contactInfoDiv = document.getElementById(contactInfoDivID);
    var containerDiv = document.getElementById(containerDivId);
    if (contactInfoDiv) {
        //contactInfoDiv.style.position = "absolute";
        //contactInfoDiv.style.width = getElementWidth(containerDivId) + "px";
        //contactInfoDiv.style.zIndex = "100";
        //contactInfoDiv.style.top = findPosY(containerDiv) + getElementHeight(containerDivId) + "px";
        //contactInfoDiv.style.left = findPosX(containerDiv) - 25 + "px";
        contactInfoDiv.style.display = "block";
        if (containerDiv) {
            containerDiv.onmouseout = function(e) {
                if (!e) var e = window.event;
                var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
                while (reltg != null) {
                    if (reltg.id == this.id) return false;
                    reltg = reltg.parentNode;
                }
                contactInfoDiv.style.display = "none";
            }
        }
    }
}

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent)
        while (1) {
        curtop += obj.offsetTop;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}
function getElementHeight(Elem) {
    if (document.getElementById) {
        var elem = document.getElementById(Elem);
    } else if (document.all) {
        var elem = document.all[Elem];
    }
    if (elem.style.pixelHeight) {
        xPos = elem.style.pixelHeight;
    } else {
        xPos = elem.offsetHeight;
    }
    return xPos;
}

function getElementWidth(Elem) {
    if (document.getElementById) {
        var elem = document.getElementById(Elem);
    } else if (document.all) {
        var elem = document.all[Elem];
    }
    if (elem.style.pixelWidth) {
        xPos = elem.style.pixelWidth;
    } else {
        xPos = elem.offsetWidth;
    }
    return xPos;
}

var creditCardValidationGroup = "";
function ShowHideDescription(chkboxID, divID, validatorRequiredID, validatorRegexID) {

    var objDiv = $get(divID);
    var objChk = $get(chkboxID);
    var valRequired = $get(validatorRequiredID);
    var valRegex = $get(validatorRegexID);

    if ((objDiv != null) && (objChk != null) && (valRequired != null) && (valRegex != null)) {
        if (valRequired.validationGroup != "") {
            creditCardValidationGroup = valRequired.validationGroup;
        }
        if (objChk.checked == false) {
            objDiv.style.display = "none";
            //objDiv.style.visibility = "hidden";
            valRequired.enabled = false;
            valRegex.enabled = false;
            valRequired.validationGroup = "";
            valRegex.validationGroup = "";
        }
        else {
            objDiv.style.display = "block";
            objDiv.style.visibility = "visible";
            valRequired.enabled = true;
            valRegex.enabled = true;
            valRequired.validationGroup = creditCardValidationGroup;
            valRegex.validationGroup = creditCardValidationGroup;
        }
    }
}

function SetAddressControlRequiredFieldValidators(valCareOfName, valAddrLine1, valCity, valStateListRequired, valZip, enabled) {
    var careOfNameRequiredValidator = document.getElementById(valCareOfName);
    var addressLine1RequiredValidator = document.getElementById(valAddrLine1);
    var cityRequiredValidator = document.getElementById(valCity);
    var stateListRequiredValidator = document.getElementById(valStateListRequired);
    var zipRequiredValidator = document.getElementById(valZip);
    if (careOfNameRequiredValidator != null) {
        ValidatorEnable(careOfNameRequiredValidator, false);
    }
    if (addressLine1RequiredValidator != null) {
        ValidatorEnable(addressLine1RequiredValidator, enabled);
    }
    if (cityRequiredValidator != null) {
        ValidatorEnable(cityRequiredValidator, enabled);
    }
    if (stateListRequiredValidator != null) {
        ValidatorEnable(stateListRequiredValidator, enabled);
    }
    if (zipRequiredValidator != null) {
        ValidatorEnable(zipRequiredValidator, enabled);
    }
}

function enableNextButton(nextbuttonid, checkBoxID, shpAddresspanel, cbxShipping, valCareOfName,
valAddrLine1, valCity, valStateListRequired, valZip, affiliationCheckBox, pnlBusinessInfo) {
    if (document.getElementById(nextbuttonid) != null) {
        if (document.getElementById(checkBoxID) != null) {
            if (document.getElementById(checkBoxID).checked) {
                document.getElementById(nextbuttonid).disabled = false;
                document.getElementById('libtn_' + nextbuttonid).className = "btn_primary";
            }
            else {
                document.getElementById(nextbuttonid).disabled = true;
                var SaveButtonappendedID = document.getElementById('libtn_' + nextbuttonid);
                SaveButtonappendedID.className = "btn_disabled";
            }
        }
    }
    var cbxShipping = document.getElementById(cbxShipping);
    var shpAddresspanel = document.getElementById(shpAddresspanel);
    if (cbxShipping != null && shpAddresspanel != null) {
        if (cbxShipping.checked) {
            shpAddresspanel.style.display = "block";
            SetAddressControlRequiredFieldValidators(valCareOfName, valAddrLine1, valCity, valStateListRequired, valZip, true);
        } else {
            shpAddresspanel.style.display = "none";
            SetAddressControlRequiredFieldValidators(valCareOfName, valAddrLine1, valCity, valStateListRequired, valZip, false);
        }
    }
    if (document.getElementById(affiliationCheckBox) != null) {
        if (document.getElementById(pnlBusinessInfo) != null) {
            if (document.getElementById(affiliationCheckBox).checked) {
                document.getElementById(pnlBusinessInfo).style.display = "block";
            }
            else {
                document.getElementById(pnlBusinessInfo).style.display = "none";
            }
        }
    }
}

function IBORegDisableButton(clientIDOne, checkBoxClientID, clientIDTwo, checkBoxClientIDTwo, affiliationCheckBox, pnlBusinessInfo) {
    if (document.getElementById(clientIDOne) != null) {
        if (document.getElementById(checkBoxClientIDTwo) != null) {
            if (document.getElementById(checkBoxClientIDTwo).checked) {
                document.getElementById(clientIDOne).disabled = false;
                document.getElementById('libtn_' + clientIDOne).className = "btn_primary";
            }
            else {
                document.getElementById(clientIDOne).disabled = true;
                var SaveButtonappendedID = document.getElementById('libtn_' + clientIDOne);
                SaveButtonappendedID.className = "btn_disabled";
            }
        }
    }
    if (document.getElementById(checkBoxClientID) != null) {
        if (document.getElementById(clientIDTwo) != null) {
            if (document.getElementById(checkBoxClientID) != null) {
                if (document.getElementById(checkBoxClientID).checked) {
                    document.getElementById(clientIDTwo).disabled = false;
                    document.getElementById('libtn_' + clientIDTwo).className = "btn_primary";
                }
                else {
                    document.getElementById(clientIDTwo).disabled = true;
                    var SaveButtonappendedIDTwo = document.getElementById('libtn_' + clientIDTwo);
                    SaveButtonappendedIDTwo.className = "btn_disabled";

                }
            }
        }
    }
    if (document.getElementById(affiliationCheckBox) != null) {
        if (document.getElementById(pnlBusinessInfo) != null) {
            if (document.getElementById(affiliationCheckBox).checked) {
                document.getElementById(pnlBusinessInfo).style.display = "block";
            }
            else {
                document.getElementById(pnlBusinessInfo).style.display = "none";
            }
        }
    }
}
function EnableLoginCopyPaste(btnLogin) {
    //Enable Login button	            
    var loginButtonId = document.getElementById(btnLogin);
    var loginButtonEnable = document.getElementById('libtn_' + btnLogin);
    loginButtonId.disabled = false;
    loginButtonEnable.className = "btn_primary";
}

function EnableDisableBioButton(clientIDOne, checkBoxClientID) {
    if (document.getElementById(clientIDOne) != null) {
        if (document.getElementById(checkBoxClientID) != null) {
            if (document.getElementById(checkBoxClientID).checked) {
                document.getElementById(clientIDOne).disabled = false;
                document.getElementById('libtn_' + clientIDOne).className = "btn_primary";
            }
            else {
                document.getElementById(clientIDOne).disabled = true;
                var SaveButtonappendedID = document.getElementById('libtn_' + clientIDOne);
                SaveButtonappendedID.className = "btn_disabled";
            }
        }
    }

}
function ShowAddressDittoInfo(contactInfoDivID, containerDivId) {
    var contactInfoDiv = document.getElementById(contactInfoDivID);
    var containerDiv = document.getElementById(containerDivId);
    if (contactInfoDiv) {
        contactInfoDiv.style.position = "absolute";
        contactInfoDiv.style.zIndex = "100";
        contactInfoDiv.style.top = (findPosY(containerDiv) - 120).toString() + "px";
        contactInfoDiv.style.left = (findPosX(containerDiv) - 90).toString() + "px";
        contactInfoDiv.style.display = "block";
        if (containerDiv) {
            containerDiv.onmouseout = function(e) {
                if (!e) var e = window.event;
                var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
                while (reltg != null) {
                    if (reltg.id == this.id) return false;
                    reltg = reltg.parentNode;
                }
                contactInfoDiv.style.display = "none";
            }
        }
    }
}

function RunCustomerRegistrationValidation(tbxPhoneID, valPhoneID, tbxEmailID, valEmailID) {
    ValidatePhoneOrEmailRequired(tbxPhoneID, valPhoneID, tbxEmailID, valEmailID);
    return Page_ClientValidate();
}

function ValidatePhoneOrEmailRequired(tbxPhoneID, valPhoneID, tbxEmailID, valEmailID) {

    // Email or Phone is required
    var tbxPhone = $get(tbxPhoneID);
    var valPhone = $get(valPhoneID);
    var tbxEmail = $get(tbxEmailID);
    var valEmail = $get(valEmailID);

    if (tbxEmail && tbxPhone && valPhone && valEmail) {
        if (tbxEmail.value.length == 0 && tbxPhone.value.length == 0) {
            ValidatorEnable(valPhone, true);
            ValidatorEnable(valEmail, true);
        }
        else {
            ValidatorEnable(valPhone, false);
            ValidatorEnable(valEmail, false);
        }
    }
}

function OnSelectedIndexChangeSecurityQuestion(hiddenField, DropDown, btnSave) {

    var stateObj = document.getElementById(DropDown);
    document.getElementById(hiddenField).value = stateObj.value;
    if (btnSave != '') {

        var SaveButtonId = document.getElementById(btnSave);

        var SaveButtonappendedID = document.getElementById('libtn_' + btnSave);

        SaveButtonId.disabled = false;
        SaveButtonappendedID.className = "btn_primary";

    }
}



function ShowSponsorDetailPanelBasedOnSelectedOptions(radioButtonId) {

    if (document.getElementById(radioButtonId + "_0").checked) {
        $get(divReferringIBO).style.display = "block";
        $get(divSearchIBO).style.display = "none";

        ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), true);
        ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), true);
        ValidatorEnable(document.getElementById(valReqIBONumSearchIBO), false);
        document.getElementById(valReqIBONumSponsorIBO).style.display = "none";
        document.getElementById(valReqIBOKeySponsorIBO).style.display = "none";

        if (typeof (hdnradioIdParent) == "string") {
            var hdnRadioId = $get(hdnradioIdParent);
        }

        if (hdnRadioId != null) {
            hdnRadioId.value = "RefIBO";
        }
        if (typeof (hdnRefIBOYesNo) == "string") {
            $get(hdnRefIBOYesNo).value = "YesRefIBO";
        }

        $get(hdnSearchOptions).value = '';
    }

    if (document.getElementById(radioButtonId + "_1").checked) {

        ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), false);
        ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), false);
        ValidatorEnable(document.getElementById(valReqIBONumSearchIBO), true);
        document.getElementById(valReqIBONumSearchIBO).style.display = "none";

        $get(divReferringIBO).style.display = "none";
        $get(divSearchIBO).style.display = "block";
        CommonFuncForDontHaveRefIBO();

        //TODO: Replace this 'text:REGISTRATION:IBOSEARCH_OPTIONS1' with some relevant value its being used for now because befor refactoring it was being used in other manner.
        $get(hdnSearchOptions).value = 'text:REGISTRATION:IBOSEARCH_OPTIONS1';
    }


    if (document.getElementById(radioButtonId + "_2").checked) {
        $get(divReferringIBO).style.display = "none";
        $get(divSearchIBO).style.display = "block";

        ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), false);
        ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), false);

        var tempValidator = document.getElementById(valReqIBONumSearchIBO);
        if (tempValidator != null) {
            ValidatorEnable(tempValidator, true);
        }
        document.getElementById(valReqIBONumSearchIBO).style.display = "none";

        CommonFuncForDontHaveRefIBO();
        //TODO: Replace this 'text:REGISTRATION:IBOSEARCH_OPTIONS2' with some relevant value its being used for now because befor refactoring it was being used in other manner.
        $get(hdnSearchOptions).value = 'text:REGISTRATION:IBOSEARCH_OPTIONS2';
    }

    if (document.getElementById(radioButtonId + "_3").checked) {

        ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), false);
        ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), false);
        ValidatorEnable(document.getElementById(valReqIBONumSearchIBO), false);

        $get(divReferringIBO).style.display = "none";
        $get(divSearchIBO).style.display = "none";
        $get(dvIBOResults).style.display = "none";

        if (typeof (hdnradioIdParent) == "string") {
            var hdnRadioId = $get(hdnradioIdParent);

        }
        if (hdnRadioId != null) {
            hdnRadioId.value = "NoSponsor";
        }
        $get(hdnSearchOptions).value = '';
        $get(hdnRefIBOYesNo).value = '';

    }


}


function CommonFuncForDontHaveRefIBO() {


    if (typeof (hdnRefIBOYesNo) == "string") {
        $get(hdnRefIBOYesNo).value = "NoRefIBO";
    }

    if (typeof (divShareInfoSearchControl) == "string") {
        var divShare = $get(divShareInfoSearchControl);
    }
    if (divShare != null) {
        divShare.style.display = "none";
    }

    if (typeof (divSponsorSearchResults) == "string") {
        var divSponsorSearch = $get(divSponsorSearchResults);
    }
    if (divSponsorSearch != null) {
        divSponsorSearch.style.display = "none";
    }

    if (typeof (hdnradioIdParent) == "string") {
        var hdnRadioId = $get(hdnradioIdParent);
    }

    /* BEGIN COPYING ZIP CODES */
    //Source zip codes
    var zip1 = $get(sponsorDetailZipCode1ID);
    var zip2 = $get(sponsorDetailZipCode2ID);

    //Target zip codes
    var targetZipTxtBx = $get(sponsorDetailZipCodeID);
    var tbxPostalCode2 = $get(tbxZipCode2ID);



    //Copy the values
    if (targetZipTxtBx != null && zip1 != null) {
        targetZipTxtBx.value = zip1.value;
    }

    if (tbxPostalCode2 != null && zip2 != null) {
        tbxPostalCode2.value = zip2.value;
    }


    var hdnState = null;
    var ddlLanguagePreference = null;

    if (typeof (hdnStateParent) == "string") {
        hdnState = $get(hdnStateParent);
    }
    if (typeof (sponsorDetailDdlLanguagePreferenceID) == "string") {
        ddlLanguagePreference = $get(sponsorDetailDdlLanguagePreferenceID);
    }
    if (hdnRadioId != null) {
        hdnRadioId.value = "NoRefIBO";
    }

    if (hdnState != null && hdnState.value != null && ddlLanguagePreference != null) {
        var t = hdnState.value;
        for (i = 0; i < ddlLanguagePreference.length; i++) {
            if (ddlLanguagePreference.options[i].value == t) {
                ddlLanguagePreference.selectedIndex = i;
            }
        }
    }


}

function SetDropDownHiddenValue(ddlClientId, hdnClientId) {
    var ddl = $get(ddlClientId);
    var hdn = $get(hdnClientId);

    if (ddl && hdn) {
        if (ddl.options) {
            hdn.value = ddl.options[ddl.selectedIndex].value;
        }
    }
}

function SetCheckboxHiddenValue(chkClientId, hdnClientId) {
    var chk = $get(chkClientId);
    var hdn = $get(hdnClientId);

    if (chk && hdn) {
        hdn.value = chk.checked;
    }
}


//function SponsorDetailStartUpScript(radioButtonId) {


//    if (document.getElementById(radioButtonId + "_1")) {
//        if (document.getElementById(radioButtonId + "_1").checked) {

//            //This ensures that the sponsor gets setup correctly for ibo search
//            $get(hdnSearchOptions).value = 'text:REGISTRATION:IBOSEARCH_OPTIONS1';

//            document.getElementById(divReferringIBO).style.display = "none";
//            document.getElementById(divSearchIBO).style.display = "block";
//            ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), false);
//            ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), false);
//            ValidatorEnable(document.getElementById(valReqIBONumSearchIBO), true);
//            document.getElementById(valReqIBONumSearchIBO).style.display = "none";

//            var divSponsorSearch = null;

//            if (typeof (divSponsorSearchResults) == "string") {
//                divSponsorSearch = $get(divSponsorSearchResults);
//            }
//            if (divSponsorSearch != null) {
//                divSponsorSearch.style.display = "block";
//            }
//        }
//    }
//    if (document.getElementById(radioButtonId + "_2")) {
//        if (document.getElementById(radioButtonId + "_2").checked) {

//            //This ensures that the sponsor gets setup correctly for ibo search
//            $get(hdnSearchOptions).value = 'text:REGISTRATION:IBOSEARCH_OPTIONS2';

//            document.getElementById(divReferringIBO).style.display = "none";
//            document.getElementById(divSearchIBO).style.display = "block";
//            ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), false);
//            ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), false);
//            ValidatorEnable(document.getElementById(valReqIBONumSearchIBO), true);
//            document.getElementById(valReqIBONumSearchIBO).style.display = "none";

//            var divSponsorSearch = null;

//            if (typeof (divSponsorSearchResults) == "string") {
//                divSponsorSearch = $get(divSponsorSearchResults);
//            }
//            if (divSponsorSearch != null) {
//                divSponsorSearch.style.display = "block";
//            }
//        }
//    }
//    if (document.getElementById(radioButtonId + "_0")) {
//        if (document.getElementById(radioButtonId + "_0").checked) {

//            document.getElementById(divReferringIBO).style.display = "block";
//            document.getElementById(divSearchIBO).style.display = "none";
//            ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), true);
//            ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), true);
//            ValidatorEnable(document.getElementById(valReqIBONumSearchIBO), false);
//            document.getElementById(valReqIBONumSponsorIBO).style.display = "none";
//            document.getElementById(valReqIBOKeySponsorIBO).style.display = "none";
//        }
//    }
//    if (document.getElementById(radioButtonId + "_3")) {
//        if (document.getElementById(radioButtonId + "_3").checked) {

//            document.getElementById(divReferringIBO).style.display = "none";
//            document.getElementById(divSearchIBO).style.display = "none";
//            ValidatorEnable(document.getElementById(valReqIBONumSponsorIBO), false);
//            ValidatorEnable(document.getElementById(valReqIBOKeySponsorIBO), false);
//            ValidatorEnable(document.getElementById(valReqIBONumSearchIBO), false);
//        }
//    }

//    if (typeof (btnContinueCustReg) != 'undefined') {
//        $get(btnContinueCustReg).disabled = true;
//        $get('libtn_' + btnContinueCustReg).className = "btn_disabled";

//        if (typeof (tbxfirstnamePersonalInfo) != 'undefined') {
//            if ($get(tbxfirstnamePersonalInfo) != '') {

//                $get(tbxfirstnamePersonalInfo).focus();

//            }
//        }

//    }

//}


//function OnSelectedIndexChangeCustReg(AddressLineOneClientID, PanelShippingAddressClientID, AddLineOneValClientID, CityValClientID, StateValClientID, ZipValClientID, lblPOBOXErrorClientID) {



//    POBOXValidation(AddressLineOneClientID, PanelShippingAddressClientID, AddLineOneValClientID, CityValClientID, StateValClientID, ZipValClientID, lblPOBOXErrorClientID);



//    if ($get(tbxSecurityAnswer).value != '') {
//        $get(btnContinueCustReg).disabled = false;
//        $get('libtn_' + btnContinueCustReg).className = "btn_primary";
//    }












//}

function EnableBusinessInfoSaveButton() {

    $get(btnSaveBusinessInfo).disabled = false;
    $get('libtn_' + btnSaveBusinessInfo).className = "btn_primary";

}



function SetHiddenPostBack(hiddenSaveAction) {
    document.getElementById(hiddenSaveAction).value = "True";
}

function AltAddSaveClick(buttonName) {

    if (buttonName != null && buttonName != '') {
        var btn = document.getElementById(buttonName);
        if (btn != null) {
            btn.click();
        }
    }
}

function POBOXValidation(AddressLineOneClientID, PanelShippingAddressClientID, AddLineOneValClientID, CityValClientID, StateValClientID, ZipValClientID, lblPOBOXErrorClientID) {

    var AddressLineOne = document.getElementById(AddressLineOneClientID).value;
    var PanelShippingAddress = document.getElementById(PanelShippingAddressClientID);
    if (AddressLineOne != null) {
        if ((AddressLineOne.toUpperCase().match('PO ') == null) && (AddressLineOne.toUpperCase().match(' PO') == null) && (AddressLineOne.toUpperCase().match(' PO ') == null)) {
            if (PanelShippingAddress != null) {

                ValidatorEnable(document.getElementById(AddLineOneValClientID), false);
                ValidatorEnable(document.getElementById(CityValClientID), false);
                ValidatorEnable(document.getElementById(StateValClientID), false);
                ValidatorEnable(document.getElementById(ZipValClientID), false);
                if (lblPOBOXErrorClientID != null) {
                    document.getElementById(lblPOBOXErrorClientID).style.display = 'none';
                }
                PanelShippingAddress.style.display = "none";
                return true;
            }
        }
    }

}
