

  var country=new Array("Please Choose Country","United States","Canada","Mexico");

  var countrykeys=new Array("2","17","73","88");

  var a2 = new Array("Please Choose Country First");

  var a2keys = new Array("-1");

  var a17= new Array("Choose State","AL","AK","AZ","AR","CA","CO","CT","DE","DC","FL","GA","GU","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","PR","RI","SC","SD","TN","TX","UT","VT","VA","VI","WA","WV","WI","WY");

  var a17keys= new Array("73","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","68","67","69","70","71","72");

  var a73= new Array("Choose Province","AB","BC","MB","NB","NL","NT","NS","NU","ON","PE","QC","SK","YT");

  /*var a73= new Array("Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland","Northwest Territories","Nova Scotia","Nunavut Territory","Ontario","Prince Edward Is.","Quebec","Sasakatchewan","Yukon Territory");*/

  var a73keys= new Array("73","75","76","77","78","79","80","81","82","83","84","85","86","87");

  var a88= new Array("Aguascalientes","Baja California","Baja California Sur","Campeche","Chiapas","Chihuahua","Coahuila de Zaragoza","Colima","Distrito Federal","Durango","Guanajuato","Guerrero","Hidalgo","Jalisco","Michoacan","Morelos","Nayarit","Nuevo Leon","Oaxaca","Pueblo","Queretaro","Quintana Roo","San Luis Potosi","Sinaloa","Sonora","Tabasco","Tamaulipas","Tlaxcala","Veracruz","Yucatan","Zacatecas");

  var a88keys= new Array("90","91","92","93","94","95","96","97","98","99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120");

    

function stateChanged()

{

  isOther('state');

}



function countryChanged()

{

  country_select = getPsInput('country');
    if(!country_select.options){
    country_select = document.getElementById('country');
  }
  state_select = getPsInput('state');
    if(!state_select.options){
    state_select = document.getElementById('state');
  }
  state_select.options.length = 0;

  defSelInd = 0;

  if ((defSelInd = -isOther('country')) == 0)

  {

    ind = country_select.selectedIndex;

    key = country_select.options[ind].value;

    if (key >= 0)

    {

      state_array = eval('a' + key);

      state_key_array = eval('a' + key + 'keys');

      setOptionsWithKeys(state_select, state_array, state_key_array);

    } else if (key == -111) {

      insertOption(state_select, 'Choose country first', -111, 0);

      state_select.selectedIndex = 0;

      stateChanged();

      return;

    }

  } else {

    insertOption(state_select, 'Other', -1, -1);

    defSelInd = -1;

  }

  addAdditionalOptions('state');

  defSelInd = (defSelInd == -1) ? state_select.options.length-1: defSelInd;

  state_select.selectedIndex = defSelInd;

  stateChanged();

}



function initStates(key)

{

      state_array = eval('a' + key);

      state_key_array = eval('a' + key + 'keys');

      setOptionsWithKeys(getPsInput('state'), state_array, state_key_array);

}



function initCountry()

{

  setOptionsWithKeys(getPsInput('country'), country, countrykeys);
  insertOption(getPsInput('state'), 'Choose country first', -111, 0);

}



function selectCountry(id)

{

  selectOptionWithValue(getPsInput('country'), id);

  countryChanged();

}



function initStatesByName(country_name)

{

  for (i = 0; country.length; i++)

  {

    if (country[i].toLowerCase() == country_name.toLowerCase())

    {

      initStates(countrykeys[i]);

      break;

    }

  }

}



function selectState(id)

{

  selectOptionWithValue(getPsInput('state'), id);

  stateChanged();

}





    