var map;
var geocoder;
var gc_title;
var bounds = new GLatLngBounds(); 
var points = Array();
/*
points[0] = new PVGeoMarker( 'Mariner&#39;s Resort Villas &amp; Marina, Key Largo', '25.073471,-80.463181', '<br>General Manager - Laurie Sprague<br>Main: 305-853-1111 <br>Fax: 305-853-1135<br><br>Email: lauries@keyscaribbean.com<br/>', -80.463181,25.073471 );
points[1] = new PVGeoMarker( 'Angler&#39;s Reef Resort Villas &amp; Marina, Islamorada', '24.949955,-80.594048', '<br>Toniya Rounds, Resort Rental Manager, Middle Keys<br>Main: 305.289.5397<br>Fax: 305.328.9334<br><br>email: tonyia@keyscaribbean.com<br/>', -80.594048,24.949955 );
points[2] = new PVGeoMarker( 'Village at Hawks Cay Villas, Duck Key / Marathon', '24.773214,-80.913567', '<br>Sam Schorr, Managing Director, Middle Keys<br>Main: 305.289.5397<br>Fax: 305.328.9334<br><br>email: sam@keyscaribbean.com<br/>', -80.913567,24.773214 );
points[3] = new PVGeoMarker( 'Coral Hammock Resort Villas, Key West', '24.573130,-81.738548', '<br>General Manager - Walt Lee<br>Main: 305-295-1271 <br>Fax: 305-295-1283<br><br>Email: walt@keyscaribbean.com<br/>', -81.738548,24.573130 );
points[4] = new PVGeoMarker( 'Oceanside Condominiums &amp; Marina, Key West', '24.564610,-81.729507', '<br>General Manager - Walt Lee<br>Main: 305-295-1271 <br>Fax: 305-295-1283<br><br>Email: walt@keyscaribbean.com<br/>', -81.729507,24.564610 );
points[5] = new PVGeoMarker( 'Trumax Annex Home, Key West', '24.553135,-81.806145', '<br>General Manager - Walt Lee<br>Main: 305-295-1271 <br>Fax: 305-295-1283<br><br>Email: walt@keyscaribbean.com<br/>', -81.806145,24.553135 );
points[6] = new PVGeoMarker( 'Indigo Reef Resort Villas &amp; Marina', '24.73419,-81.03288', '<br>General Manager - Pete Policastro<br>Main: 305-396-3002 <br>Fax: 305-207-3333<br><br>Email: policastro_pj@yahoo.com<br/>', -81.03288,24.73419 );
points[7] = new PVGeoMarker( 'Coral Lagoon Resort Villas & Marina', '24.730036, -81.024056', '<br>General Manager - Pete Policastro<br>Main: 305-396-3002 <br>Fax: 305-207-3333<br><br>Email: policastro_pj@yahoo.com<br/>', -81.024056,24.730036 );
*/
points[0] = new PVGeoMarker( 'Mariner&#39;s Resort Villas &amp; Marina, Key Largo', '25.073471,-80.463181', '<br />General Manager - Laurie Sprague<br />Phone: 305-853-1111<br />Fax: 305-853-1135<br />Email: lauries@keyscaribbean.com<br />', -80.463181, 25.073471 );
points[1] = new PVGeoMarker( 'Historic Tavernier Inn Hotel, Tavernier', '25.00893,-80.5169', '<br />General Manager - Laurie Sprague<br />Phone: 305-853-5015<br />Fax: 305-853-1135<br />Email: lauries@keyscaribbean.com<br />', -80.5169, 25.00893 );
points[2] = new PVGeoMarker( 'Village at Hawks Cay Villas, Duck Key', '24.773214,-80.913567', '<br />Sam Schorr, Managing Director, Middle Keys<br />Phone: 305.289.5397<br />Fax: 305.328.9334<br />Email: sam@keyscaribbean.com<br />', -80.913567, 24.773214 );
points[3] = new PVGeoMarker( 'Indigo Reef Resort, Marathon', '24.73418,-81.03287', '<br />General Manager - Pete Policastro<br />Phone: 305-396-3002<br>Fax: 305-207-3333<br />Email: policastro_pj@yahoo.com<br />', -81.03287, 24.73418 );
points[4] = new PVGeoMarker( 'Coral Lagoon, Marathon', '24.73111,-81.02494', '<br />General Manager - Pete Policastro<br />Phone: 305-396-3002<br>Fax: 305-207-3333<br />Email: policastro_pj@yahoo.com<br />', -81.02494, 24.73111 );
points[5] = new PVGeoMarker( 'Coral Hammock Resort Villas, Key West', '24.57313,-81.738548', '<br />General Manager - Pete Policastro<br />Phone: 305-396-3002<br>Fax: 305-207-3333<br />Email: policastro_pj@yahoo.com<br />', -81.738548, 24.57313 );
points[6] = new PVGeoMarker( 'Oceanside Condominiums &amp; Marina, Key West', '24.56481,-81.72805', '<br />General Manager - Walt Lee<br />Phone: 305-295-1271<br />Fax: 305-295-1283<br />Email: walt@keyscaribbean.com<br />', -81.72805, 24.56481 );
points[7] = new PVGeoMarker( 'Sunset Key, Key West', '24.55803,-81.80688', '<br />General Manager - Gina Kennedy<br />Phone: 305-295-1271<br />Fax: 305-295-1283<br />Email: ginamkennedy@hotmail.com<br />', -81.80688, 24.55803 );
points[8] = new PVGeoMarker( 'Old Town Banyan Court, Key West', '24.55686,-81.8048', '<br />General Manager - Gina Kennedy<br />Phone: 305-295-1271<br />Fax: 305-295-1283<br />Email: ginamkennedy@hotmail.com<br />', -81.8048, 24.55686 );

 
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 + '<div align="right"><a style="color: #000;"target="_blank" href="http://maps.google.com/maps?f=d&geocode=&daddr='+escape(this.address)+'&z=16">Get Driving Directions</a></div></span>';
}	

PVGeoMarker.prototype.createMarker = function() {
	this.marker = new GMarker(this.coords);
	this.marker.bindInfoWindowHtml( this.infohtml );
	return this.marker;	
}

PVGeoMarker.prototype.popup = function() {
	this.marker.openInfoWindowHtml(this.infohtml);
}

PVGeoMarker.prototype.show = function() {
	map.clearOverlays();
	this.createMarker();
	map.setCenter( this.coords, 17 );
	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());
    map.addControl(new GLargeMapControl());
    var point = new GLatLng(0, 0);
	map.setCenter( point , 4 );
	
    geocoder = new GClientGeocoder();
    geocoder.setCache(new AddressCache());	
}

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(points.length == 1) {
		map.setCenter(points[0].coords, 11);
		points[0].popup();
	}
	else if (!bounds.isEmpty()) {
		map.setCenter(bounds.getCenter(),
		map.getBoundsZoomLevel(bounds));
	}
}

function loadGoogleMap() {
  if (GBrowserIsCompatible()) {
  	createMap( 'googlemap' );
  	loadMarkersLayer();
  }
}

Event.observe(window, 'load', loadGoogleMap, false);
Event.observe(window, 'unload', GUnload, false);

