﻿// Contains JavaScript functions for the Register wizard.

function contactOptionChanged() {
    // Enable/disable the contact input controls based on the selected option.
    var radioList = document.getElementById("_ctl0_ContentPlaceHolder1_Wizard1_rblContact");
    var options = radioList.getElementsByTagName('input');
    
    if (options[0].checked) {
        enableContactInputs(true);  // Yes is selected.
    }
    else {
        enableContactInputs(false); // No is selected.
    }
}

function enableContactInputs(enable) {
    // Enable all phone type CheckBoxes.
    var checkList = document.getElementById("_ctl0_ContentPlaceHolder1_Wizard1_cblContactPhoneType");
    var options = checkList.getElementsByTagName('input');
    
    for (i = 0; i < options.length; i++) {
        options[i].disabled = !enable;
    }
    
    // Enable the best contact time TextBox.
    var txtBestTime = document.getElementById("_ctl0:ContentPlaceHolder1:Wizard1:txtBestContactTime");
    txtBestTime.disabled = !enable;
}

function selectState(index) {
    var checkBox = document.getElementById("_ctl0_ContentPlaceHolder1_Wizard1_cblStates_" + index);
    if (checkBox != null && checkBox != 'undefined') {
        if (!checkBox.checked) {
            checkBox.checked = true;
        }
    }
}
