var county = new Array();

county['DC'] = new Array('DC');
county['DE'] = new Array('New Castle');
county['MD'] = new Array('Anne Arundel','Baltimore City','Baltimore County','Calvert','Carroll','Cecil','Charles','Frederick','Garrett','Harford','Howard','Montgomery','Prince Georges','St. Marys','Washington');
county['NJ'] = new Array('Atlantic','Bergen','Burlington','Camden','Cape May','Cumberland','Essex','Gloucester','Hudson','Hunderdon','Mercer','Middlesex','Monmouth','Morris','Ocean','Passaic','Salem','Somerset','Sussex','Union','Warren');
county['OH'] = new Array('Franklin','Delaware','Union','Marion','Morrow','Madison','Logan','Champaign','Clark','Miami','Fayette','Pickaway','Fairfield','Ross','Hocking');
county['PA'] = new Array('Allegheny','Beaver','Bucks','Butler','Chester','Delaware','Fayette','Greene','Montgomery','Philadelphia','Washington','Westmoreland');
county['VA'] = new Array('Arlington','Fairfax','Loudoun','Prince William');
county['WV'] = new Array('Brooke','Hancock','Monongalia','Marion','Ohio','Preston');

function setCounties() {
  stateSel = document.getElementById('state');
  countyList = county[stateSel.value];
  changeSelect('county', countyList, countyList);
  //setCities();
}

function changeSelect(fieldID, newOptions, newValues) {
  selectField = document.getElementById(fieldID);
  selectField.options.length = 0;
  for (i=0; i<newOptions.length; i++) {
    selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
  }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


