var map;
var geocoder;
var gc_title;
var bounds = new GLatLngBounds(); 
var points = Array();

points[0] = new PVGeoMarker( 'Cape Eleuthera', 'Cape Eleuthera', '<br/>Resort: (242) 422-9977<br>Marina: (242) 359-7208', -76.322021,24.796707 );

function PVGeoMarker(title, address, info, lon, lat) {
		this.title = title;
	this.info = info;
	this.address = address;
	this.lat = lat;
	this.lon = lon;
	this.coords = new GLatLng(this.lat,this.lon);
	this.marker = null;
	this.infohtml = '<b>' + this.title + '</b><br/>' + this.info + '</span>';
}	

PVGeoMarker.prototype.createMarker = function() {
	this.marker = new GMarker(this.coords);
	this.marker.bindInfoWindowHtml( this.infohtml );
	return this.marker;	
}

PVGeoMarker.prototype.show = function() {
	map.clearOverlays();
	this.createMarker();
	map.setCenter( this.coords, 14 );
	map.addOverlay(this.marker);
	this.marker.openInfoWindowHtml(this.infohtml);
}

function AddressCache() {
	GGeocodeCache.apply(this);
}

AddressCache.prototype = new GGeocodeCache();

function createMap( elementid ) {
    map = new GMap2(document.getElementById( elementid ));
    map.enableScrollWheelZoom();
    map.enableContinuousZoom();
    map.addControl(new GSmallMapControl());
    
    var point = new GLatLng(0, 0);
	map.setCenter( point , 14 );
	
    geocoder = new GClientGeocoder();
    geocoder.setCache(new AddressCache());
/*     GEvent.addListener(map, "moveend", function() {
	var center = map.getCenter();
	document.getElementById("message").innerHTML = center.toString();
    }); */
}

function loadMarkersLayer() { 
	map.clearOverlays();   	
	
	/* for (var i = 0; i < points.length; i++) {
		var pt = points[i];
		if(pt != null) {
			map.addOverlay(pt.createMarker());
			bounds.extend(pt.coords);
		}
	}
	if (!bounds.isEmpty()) {
		map.setCenter(bounds.getCenter(),
		map.getBoundsZoomLevel(bounds));
	} */

	map.addOverlay(points[0].createMarker());
	points[0].marker.openInfoWindowHtml(points[0].infohtml);
	map.setCenter( new GLatLng(24.896402266558724,-78.3544921875) , 6 );

}

function loadGoogleMap() {
  if (GBrowserIsCompatible()) {
  	createMap( 'map' );
  	loadMarkersLayer();
  }
}

Event.observe(window, 'load', loadGoogleMap, false);
Event.observe(window, 'unload', GUnload, false);

