﻿function checkState(stateDropdown, elemCountryId, elemValidatorId, toggleCSSVisibility) {
    var elemCountry = $("#" + elemCountryId);
    var elemValidator = null;

    if (elemValidatorId != null)
        elemValidator = $("#" + elemValidatorId);
        
    if (stateDropdown.options[stateDropdown.selectedIndex].value == "Other") {
        if (toggleCSSVisibility)
            elemCountry.css('visibility', 'visible');
        else
            elemCountry.css('display', 'block');
        
        if(elemValidator != null)
            ValidatorEnable(document.getElementById(elemValidatorId), true);
    }
    else {
        if (toggleCSSVisibility)
            elemCountry.css('visibility', 'hidden');
        else
            elemCountry.css('display', 'none');

        if (elemValidator != null)
            ValidatorEnable(document.getElementById(elemValidatorId), false);
    }
}

function toggleEnabledIfValueSelected(elemSelect, value, elemDisabledId) {
    var elemDisabled = $("#" + elemDisabledId).get(0);

    if (elemSelect.options[elemSelect.selectedIndex].value == value)
        elemDisabled.disabled = false;
    else
        elemDisabled.disabled = true;
}

function checkboxToggleDisabled(elemCheckbox, elemDisabledId) {
    var elemDisabled = $("#" + elemDisabledId).get(0);

    elemDisabled.disabled = !elemCheckbox.checked;
}

function disableElement(elemDisabledId) {
    var elemDisabled = $("#" + elemDisabledId).get(0);
    elemDisabled.disabled = true;
}