/* ------------------------------------------------------------------------ */
/* ----------- Neon Monster Google Maps Integration Javascript ------------ */
/* ------------------------------------------------------------------------ */


// Neon Monster Location
$(document).ready(function(){
function CreateAllLocs() {
	new nmLocation(
    37.754538, -122.434323,
    "Neon Monster",
    "901 Castro St, San Francisco, California.",
    "0"
  );
}


// Map Setup
if (GBrowserIsCompatible()) {
	var g_map = new GMap2(document.getElementById("map_canvas"));
	g_map.setCenter(new GLatLng(37.755838,-122.434323), 15);
	var mapControl = new GLargeMapControl();
	g_map.addControl(mapControl);
};

// Create our custom icon:
var Icon = new GIcon();
Icon.image = "site/images/map_icon_shadow.png";
Icon.iconSize = new GSize(125, 114);
Icon.iconAnchor = new GPoint(26, 114);
Icon.infoWindowAnchor = new GPoint(45, 40);

// The array of "Locations" objects:
g_locs = [];

// The Location object constructor:
function nmLocation(lat, lng, loc_name, address, idnum) {
	this.idnum = idnum;
	this.loc_name = loc_name;
	this.address = address;
	this.lat_lng = new GLatLng(lat, lng);
	this.gmarker = new GMarker(this.lat_lng, {icon: Icon,
	  title: loc_name + " (" + address + ")"});
	this.number = idnum;
	this.list_id = "loc_" + this.number;

	g_map.addOverlay(this.gmarker);
	GEvent.addListener(this.gmarker, "click", function() {
					g_locs[idnum].select(false);
					});
	g_locs[idnum] = this;
}

// Select the location.
nmLocation.prototype.select = function() {
	var info_win = '<h4>' +
			this.loc_name +
			'</h4><div class="marker_address">' +
			this.address;

	info_win += '</div>';
	
	this.gmarker.openInfoWindowHtml(info_win);
	g_map.panTo(this.lat_lng);
}

// Create all the locations specified above:
CreateAllLocs();

}); // end document ready function
