function deg(newdegrees)
{
  //Javascript function/object to store a lattitude or longitude in decimal degrees
  //store as radians
  this.decimal = (Math.PI/180.0)*newdegrees;
}
function dms(newdegrees, newminutes, newseconds)
{
  //JavaScript function to store a latitude or longitude
  //convert to decimal degrees from dms and store as radians
  this.decimal=(Math.PI/180.0)*(newdegrees+(newminutes + newseconds/60.0)/60.0);
}
//Earth radius in km
dms.prototype.earthRadius=6378.45;

function point(newlat, newlng)
{
  //a point that consists of a latitude and a longitude
  this.lat=newlat;
  this.lng=newlng;
}

function distance(p1,p2)
{
  //distance between two points when coords given in Lat-Long
  //spherical Earth assumed
  //8-20-2001

  //find angle between the two points
  arg=Math.cos(p1.lat.decimal)*Math.cos(p2.lat.decimal)*Math.cos(p1.lng.decimal-p2.lng.decimal)+
      Math.sin(p1.lat.decimal)*Math.sin(p2.lat.decimal);

  //return the distance between the two points in km
  return dms.prototype.earthRadius*Math.acos(arg);
}

