/**
 * UICC Payment Module Functions
 * 
 * @package All_Packages
 * @subpackage PresentationScripts
 * @copyright UICC 2006
 */


/** 
 * Change the "disabled" property of the fields
 *
 * @param object form_p the form
 * @param array fieldNames_p the names of the fields to change
 * @return array the names of the fields that haven't changed
 */
function changeDisabledPropertyOfFields(form_p, fieldNames_p, toValue_p) {
    var nbFields = form_p.elements.length;
    var out = new Array();
    var i = 0;
    for(i = 0 ; i < nbFields ; i++) {
        if (0 > searchInArray(form_p.elements[i].name, fieldNames_p)) {continue;}
        if (form_p.elements[i].disabled == toValue_p) {out.push(form_p.elements[i].name);}
        form_p.elements[i].disabled = toValue_p;
    }
    return out;
}

/** 
 * Disable the person and address fields
 *
 * @param object form_p the form
 * @param array skip_p the values to be skipped
 * @return array the names of the fields that haven't changed (i.e. that were already disabled)
 */
function disablePersonAndAddressFields(form_p, skip_p) {
    var arr = ['title_en', 'title', 'first_name', 'middle_name_1', 'middle_name_2', 'last_name', 'street_address_1', 'street_address_2', 'city', 'country', 'state', 'zip', 'extension'];
    if (skip_p) {arr = arrayDiff(arr, skip_p);}
    return changeDisabledPropertyOfFields(form_p, arr, true);
}

/** 
 * Enable the person and address fields
 *
 * @param object form_p the form
 * @param array skip_p the values to be skipped
 * @return array the values that haven't changed (i.e. that were already enabled)
 */
function enablePersonAndAddressFields(form_p, skip_p) {
    var arr = ['title_en', 'title', 'first_name', 'middle_name_1', 'middle_name_2', 'last_name', 'street_address_1', 'street_address_2', 'city', 'country', 'state', 'zip', 'extension'];
    if (skip_p) {arr = arrayDiff(arr, skip_p);}
    return changeDisabledPropertyOfFields(form_p, arr, false);
}


