google.load('maps','2.x');
var ajax;
var map     = false;
var center;

function init(div,clat,clng,zoom) {
  map     = new google.maps.Map2(document.getElementById(div));
  center  = new GLatLng(clat,clng);
  if (div == 'GMapSmall') map.addControl(new GSmallMapControl());
  else                    map.addControl(new GLargeMapControl());
  map.addControl(new GHierarchicalMapTypeControl());
  map.enableScrollWheelZoom();
  map.setCenter(center,zoom);
  map.addMapType(G_PHYSICAL_MAP);
  map.setMapType(G_PHYSICAL_MAP);
  return true;
}

var m = new Array();
function add_point(lat,lng,zoom,color,chr,locationid) {
  m[locationid] = new GMarker(new GLatLng(lat,lng),new GIcon(G_DEFAULT_ICON,"/images/gicons/gpin_"+color+".png",{ url: "/images/gicons/chr/"+chr+".png", size: new GSize(20,34), anchor: new GPoint(0,0) } ));
  m[locationid].locationid  = locationid;
  GEvent.addListener(m[locationid],"click", function() {
                                  ajax  = new sack();
                                  ajax.requestFile  = "/_inc/getlocationdetails.php?id="+this.locationid;
                                  ajax.onCompletion = function() {
                                                        if (!ajax.response) return;
                                                        m[locationid].openInfoWindow(ajax.response);
                                                      }
                                  ajax.runAJAX();
                                }
                        );
  map.addOverlay(m[locationid]);
}

function show_det(locationid) {
  ajax  = new sack();
  ajax.requestFile  = "/_inc/getlocationdetails.php?id="+locationid;
  ajax.onCompletion = function() {
                        if (!ajax.response) return;
                        m[locationid].openInfoWindow(ajax.response);
                      }
  ajax.runAJAX();
  return false;
}