// turn on/off any "other"fields
function fb_other_on (othername) {
    var box = document.getElementById(othername);
    box.removeAttribute('disabled');
}

function fb_other_off (othername) {
    var box = document.getElementById(othername);
    box.setAttribute('disabled', 'disabled');
}

function validate_form_create (form) {
    var alertstr = '';
    var invalid  = 0;
    var invalid_fields = new Array();

    // title: standard text, hidden, password, or textarea box
    var title = form.elements['title'].value;
    if (title == null || title === "") {
        alertstr += '- Invalid entry for the "Title" field\n';
        invalid++;
        invalid_fields.push('title');
    }
    // section: select list, always assume it's multiple to get all values
    var section = null;
    var selected_section = 0;
    for (var loop = 0; loop < form.elements['section'].options.length; loop++) {
        if (form.elements['section'].options[loop].selected) {
            section = form.elements['section'].options[loop].value;
            selected_section++;
            if (section == '_other_section') section = form.elements['_other_section'].value;
            if (section == null || section === "") {
                alertstr += '- Invalid entry for the "Section" field\n';
                invalid++;
                invalid_fields.push('section');
            }
        } // if
    } // for section
    if (! selected_section) {
        alertstr += '- Invalid entry for the "Section" field\n';
        invalid++;
    }
    // type: select list, always assume it's multiple to get all values
    var type = null;
    var selected_type = 0;
    for (var loop = 0; loop < form.elements['type'].options.length; loop++) {
        if (form.elements['type'].options[loop].selected) {
            type = form.elements['type'].options[loop].value;
            selected_type++;
            if (type == '_parent') section = form.elements['_parent'].value;
            if (type == null || type === "") {
                alertstr += '- Invalid entry for the "Type" field\n';
                invalid++;
                invalid_fields.push('type');
            }
        } // if
    } // for type
    if (! selected_type) {
        alertstr += '- Invalid entry for the "Type" field\n';
        invalid++;
    }

    if (invalid > 0 || alertstr != '') {
        if (! invalid) invalid = 'The following';   // catch for programmer error
        alert(''+invalid+' error(s) were encountered with your submission:'+'\n\n'
                +alertstr+'\n'+'Please correct these fields and try again.');
        return false;
    }
    return true;  // all checked ok
}