/**
 * Opens the map window.
 */
function openMap()
{
    var topP = screen.height/2 - 300;
    var leftP = screen.width/2 - 450;
    var params = 'location=no,menubar=no,status=yes,resizable,height=600,width=900,left=' + leftP + ',top=' + topP;

    var w = window.open('','mapWindow',params);
    w.focus();
}

/**
 * Populates the given select element with county select 
 * options for the given state abbreviation.
 * 
 * @param abbrv     The two character state abbreviation (capitalized)
 * @param docObj    The document DOM object for the stateCountyArrays.html
 *                  document.
 * @param countySelect The select DOM object which needs populating.
 */
function populateCounties(abbrv,docObj,countySelect)
{
    if (abbrv != 'no') {
      var countyArray = docObj.getElementById(abbrv + 'c').innerHTML.split("|");
      countySelect.options.length=0;
      for(var i = 0; i<countyArray.length;i++)
      {
          if (!countyArray[i]) continue;

          var fips_name = countyArray[i].split(":");

          countySelect.options[i] = new Option(fips_name[1],fips_name[0]);
      }
    }
}

/**
 * Populates the given select element with congressional district select 
 * options for the given state abbreviation.
 * 
 * @param abbrv     The two character state abbreviation (capitalized)
 * @param docObj    The document DOM object for the stateCountyArrays.html
 *                  document.
 * @param countySelect The select DOM object which needs populating.
 */
function populateCongressionalDistricts(abbrv,docObj,congDistSelect)
{
    if (abbrv != 'no') {
      var congDistArray = docObj.getElementById(abbrv + 'cd').innerHTML.split("|");
      congDistSelect.options.length=0;
      for(var i = 0; i<congDistArray.length;i++)
      {
          if (!congDistArray[i]) continue;

          var district_name = congDistArray[i].split(":");

          congDistSelect.options[i] = new Option(district_name[0] + ' - ' + district_name[1],district_name[0]);
      }
    }
}

/**
 * Sets all of the given select's options selected=false
 */
function clearSelect(selectObj){
    for (i=0;i < selectObj.options.length;i++) {
        selectObj.options[i].selected=false;
    }
}
