
if (!document.getElementById && document.all)
	document.getElementById = function(id)
	{
		return document.all[id];
	}

var coords;

function convertText(textCoords, quiet, showMap)
{

  if (showMap == null)
	showMap = true;

//  alert(textCoords);

  textCoords = String(textCoords);
  if (textCoords == "" || textCoords == null || textCoords == "undefined")
  {
  //alert("test1");
    if (!quiet)
      //alert("Please enter some GPS coordinates");
  
      return false;
  }

  var mantissa = 1000000;

  coords = new GPSCoordinateSet(textCoords);
//alert("test4");
  if (coords.isValid())
  {
  //alert("test2");
  //setValue("address", Math.round(coords.getLat().toDec() * mantissa) / mantissa);
    //setValue("lat_dec", Math.round(coords.getLat().toDec() * mantissa) / mantissa);
    //setValue("long_dec", Math.round(coords.getLong().toDec() * mantissa) / mantissa);

    //setValue("lat_dms", coords.getLat().toDMSString());
    //setValue("long_dms", coords.getLong().toDMSString());

    //setValue("zone_utm", coords.getHemi() + coords.getZone());
    //setValue("x_utm", Math.round(coords.getUTMx()));
    //setValue("y_utm", Math.round(coords.getUTMy()));

    //setValue("lat_gps", coords.getLat().toGPSString());
    //setValue("long_gps", coords.getLong().toGPSString());

    if (showMap)
      {mapURL();}

    return true;
  }
  else 
  {
  //alert("test3");
    if (!quiet)
      //alert("Sorry, your coordinates could not be understood.");
    return false;
  }
}


function mapURL(mag)
{

 var lat = coords.getLat().toDec();
 var lon = coords.getLong().toDec();

  if (lat > 0)
  {

 if (mag == null)
 {
   mag = ".070";
 }

//showGMap(lat, lon);

 //document.images['mapimg'].src = "http://tiger.census.gov/cgi-bin/mapgen?lon=" + lon + "&lat=" + lat + "&iwd=300&iht=250&wid=" + mag + "&ht=" + mag + "&mark=" + lon + "," + lat + ",bluestar";

 }

}

function bodyOnLoad()
{
//  if (window._load) { window._load(); }
  convertText(document.inGPScoord.c.value, true);
}

