var g_stateWin = null;
function lookupState ()
{
  var ctryIndex = document.mainForm.Country.selectedIndex;
  var ctry = document.mainForm.Country.options [ctryIndex].value;
  var opts;
  var url = 'stateLookup.html?c=' + ctry;

  if (ctryIndex < 0)
  {
    alert ('Please select a country');
  }
  else
  {
    opts = 'width=480,height=400,hotkeys,resizable,scrollbars,dependent';

    if (ctry == 'US' || ctry == 'CA')
    {
      if (g_stateWin == null || g_stateWin.closed)
      {
        g_stateWin = window.open (url,"_state",opts);
        if (g_stateWin.opener == null)
        {
          g_stateWin.opener = self;
        }
      }
      else
      {
        g_stateWin.location = url;
      }
      g_stateWin.focus ();
    }
    else if (ctry != null && ctry != '')
    {
      alert ("State information is not available for " + ctry + "\r\nEnter an appropriate value.");
    }
    else
    {
      alert ("Please select a country");
    }
  }
}