function updateChoices(s, i) {
    // s: One of the 'interest'+i select objects
    // i: 1 or 2
    var f = s.form;
    var cat = s.options[s.selectedIndex];
    
    // sub-dropdown
    var cbi;
    if (i == 1) cbi = f.interest1;
    else if (i == 2) cbi = f.interest2;
    else cbi = f.interest;
    
    for (var ii = 0; ii < cbi.length; ii++) {
	cbi.options[0] = null;
    }
    cbi.options.length = 0;
    
    if (!cat || cat.value == 'no answer') {
	cbi.options[0] = new Option("(No category selected)", "no answer");
	cbi.disabled = true;
    } else {
	cbi.disabled = false;
	
	var n = options[cat.value];
	cbi.options[0] = new Option("-- Please Select --", '');
	for (var ii = 0; ii < n.length; ii++) {
	    cbi.options[ii + 1] = new Option(n[ii]);
	}
    }
}

// the following is a compatibility hack for really old browsers.
// (my main concern here is NS4...)
function isEnabled(obj) {
    return !obj.disabled;
}

function isblank(s) {
    if (s == "") return true;
    for (var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\r') && (c != '\t')) return false;
    }
    return true;
}

function verify(f) {
    // Hack to always send disabled Interest fields.
    if (f.interest) {
        f.interest.disabled = false;
    }
    
    if (f.interest2) {
        f.interest2.disabled = false;
    }

    return true;
}

function clear_selection(radio_group) {
  for (var i = 0; i < radio_group.length; i++) { 
    if (radio_group[i].checked) { 
      radio_group[i].checked = false; 
    }
  }
  return false;
}

var infobox_window = null;

function open_window(title) {
  if (infobox_window && infobox_window.close) {
     infobox_window.close()
  }
  infobox_window = open("infobox.php?program=" + escape(title), "infobox", 
                        "width=450,height=380,scrollbars=yes");
  return false;
}

function update_current_school_state() {
    var cur_state = document.inquiry.current_school_state;
    var ceeb = document.inquiry.ceeb.value;
    
    if (cur_state.selectedIndex == 0 || ceeb == '') {
        cur_state.selectedIndex = document.inquiry.state.selectedIndex;
    }
}
