// define global variables for drawPolygon

   var PGradius = 1;          // radius in miles of polygon vertices
   var PGcolor = '#0000ff';   // polygon color blue
   var PGwidth = 3;           // width pixels
   var PGtrans = 0.5;         // transparency 0 - 1
   var d2r = Math.PI/180;     // degrees to radians
   var r2d = 180/Math.PI;     // radians to degrees
   var PGsides = 36;          // number of sides of polygon
                              // (use 36 for circle)
   var PGstart = 0;

function drawPolygon(lng,lat,PGsides) {

   if (PGsides%2 == 1) {
     PGstart = (0.5 - 2/PGsides) * Math.PI;
   } else {
     PGstart = -Math.PI/PGsides;
   };
   var PGlat = (PGradius/3963)*r2d;     // using 3963 miles
                                        // as earth's radius
   var PGlng = PGlat/Math.cos(lat*d2r);
   var PGpoints = [];
   for (var i=-1; i < PGsides; i++) {
      var theta = 2*i*Math.PI/PGsides + PGstart;
      PGx = lng + (PGlng * Math.cos(theta));
      PGy = lat + (PGlat * Math.sin(theta));
      PGpoints.push(new GPoint(PGx,PGy));
   };
   map.addOverlay(new GPolyline(PGpoints,PGcolor,PGwidth,PGtrans));

} 

