// from http://www.lokkju.com
GMap.prototype.addOverlays=function(a) {
  for (var i=0;i<a.length;i++) {
    try {
      this.overlays.push(a[i]);
      a[i].initialize(this);
      a[i].redraw(true);
      }
    catch(ex) { alert('err: ' + i + ', ' + ex.toString()); }
    }
  this.reOrderOverlays();
  }


function createMarker(point, html) {
  var marker = new GMarker(point);
  GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(html);
      });
  return marker;
  }


// 'drawPolygon()' from Joe Murphy - http://www.mailbag.com/users/joe_/
var d2r = Math.PI/180; // degrees to radians
var r2d = 180/Math.PI; // radians to degrees

function drawPolygon(lng, lat, PGsides, PGradius, PGcolor, PGwidth, PGtrans) {
/* parameters:
  'PGsides' - number of sides of polygon (use 36 for circle)
  'PGradius' - radius in miles of polygon vertices
  'PGcolor' - polygon color, hex
  'PGwidth' - line width in pixels
  'PGtrans' - transparency 0..1
*/
  var PGstart = (PGsides%2 == 1) ? 2/PGsides : 1/PGsides;
  PGstart = (0.5 - PGstart) * Math.PI;
  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));
    }
  var poly = new GPolyline(PGpoints, "#" + PGcolor, PGwidth, PGtrans);
  map.addOverlay(poly);
  return poly;
  }

