function googleMaps() {
	if (GBrowserIsCompatible()) {
		this._map = new GMap2(document.getElementById("map"));
		//this._map.enableScrollWheelZoom();
		this._map.addMapType(G_PHYSICAL_MAP);
		this._map.setMapType(G_PHYSICAL_MAP);
		this.setDefaultCenter();
		this._map.addControl(new GLargeMapControl());
		this._map.addControl(new GMapTypeControl());
//		this._map.addControl(new GOverviewMapControl());
		this._mgr = new MarkerManager(this._map);

		this._markers = {};
		this._markers_backup = [];
		this._markerCount = 0;
		this._bounds = new GLatLngBounds();

		//	this.setListeners();
		//	this.limitZoom();
		//	this.setOverlay();
	}
};

googleMaps.prototype = {
	_map: null,
	_mgr: null,
	_allowedBounds: null,
	_directions: null,
	_markers: null,
	_markerCount: null,
	_bounds: null,
	
	setDefaultCenter: function() {
		this._map.setCenter(new GLatLng(44, -120), 6);
	},
	
	centerOnDestination: function(destination) {
		if (!this._map.getBounds().contains(destination.getGLatLng())) {
			this._map.setCenter(destination.getGLatLng());
		}
	},
	
	plotDestinations: function(_destinations) {
		this.clearMarkers();
		for (var i in _destinations) {
			var marker = this.createMarker(_destinations[i]);
			this._markers[_destinations[i].getId()] = marker;
		}
		this.loadMarkers();
	},

	createMarker: function(destination) {
		var baseIcon = new GIcon();
		var destination = destination;
		var me = this;
		
		var baseIcon = new GIcon();
		//baseIcon.shadow = "images/mapicon_shadow.png";
		baseIcon.iconSize = new GSize(26, 26);
		baseIcon.iconAnchor = new GPoint(13, 13);
		//baseIcon.infoWindowAnchor = new GPoint(13, 13);
		//baseIcon.shadowSize = new GSize(37, 34);
		
		var destIcon = new GIcon(baseIcon);
		destIcon.image = BASE_URL + "/images/mapicon_"+ destination.getCategory() +".png";
		var markerOptions = { 
			icon:destIcon,
			zIndexProcess:function(marker, b) {
				return GOverlay.getZIndex(marker.getPoint().lat()) + ((marker.selected) ? 1000000 : 0);
			}
		};
		
		var marker = new GMarker(destination.getGLatLng(), markerOptions);
		GEvent.addListener(marker, "click", function() {
			destination.select();
			me._mgr.refresh();
		});
		
		GEvent.addListener(marker, "mouseover", function(data) {
			//destination.highlight();
		});

		return marker;
	},
	
	getMarker: function(destination) {
		if (marker = this._markers[destination.getId()]) {
			return marker;
		}
		else {
			var marker = this.createMarker(destination);
			this._markers[destination.getId()] = marker;
			this._mgr.addMarker(marker, 0, 16);
			this._bounds.extend(marker.getPoint());
			return marker;
		}
	},
	
	loadMarkers: function() {
		this._bounds = new GLatLngBounds();
		this._markerCount = 0;
		for (var i in this._markers) {
			var marker = this._markers[i];
			this._bounds.extend(marker.getPoint());
			this._mgr.addMarker(marker, 0, 16);
			this._markerCount++;
		}
		
		// check for locations so maps doesn't go in the middle of the pacific
		if (this._markerCount > 0) {
			this._map.setCenter(this._bounds.getCenter(), this._map.getBoundsZoomLevel(this._bounds));
		}
		else {
			this.setDefaultCenter();
		}
		this._mgr.refresh();
	},
	
	resetMarker: function(destination) {
		var marker = this.getMarker(destination);
		marker.getIcon().image = BASE_URL + "/images/mapicon_"+ destination.getCategory() +".png";
		marker.getIcon().iconSize = new GSize(26, 26);
		marker.getIcon().iconAnchor = new GPoint(13, 13);
		marker.getIcon().shadow = null;
		marker.selected = false;
		this._mgr.refresh();
		return this;
	},
	
	selectMarker: function(destination) {
		var marker = this.getMarker(destination);
		marker.getIcon().image = BASE_URL + "/images/mapicon_"+ destination.getCategory() +"_selected.png";
		marker.getIcon().iconSize = new GSize(33, 45);
		marker.getIcon().iconAnchor = new GPoint(16, 45);
		marker.getIcon().shadow = BASE_URL + "/images/mapicon_shadow.png";
		marker.getIcon().shadowSize = new GSize(56, 45);
		marker.selected = true;
		this._mgr.refresh();
		return this;
	},

	getMarkers: function() {
		var markers = this._markers;
		this.clearMarkers();
		return markers;
	},
	
	restoreMarkers: function(markers) {
		this.clearMarkers();
		this._markers = markers;
		this.loadMarkers();
		return this;
	},

	clearMarkers: function() {
		if (typeof(destinations) != 'undefined') {
			destinations.resetSelectedDestination();
		}
		this._markers = {};
		this._mgr.clearMarkers();
		if (this._directions) {
			this._directions.clear();
		}
		return this;
	},
	
	setListeners: function() {
		var me = this;
		GEvent.addListener(this._map, "move", function() {
			me.checkBounds();
		});
		
		this._allowedBounds = new GLatLngBounds(new GLatLng(41.97115309077533, -124.97791528701782), new GLatLng(46.72506514149809, -115.70536851882933));		
	},
	
	limitZoom: function() {
		var minMapScale = 6;
		var maxMapScale = 16;
		var mapTypes = this._map.getMapTypes();
		for (var i=0; i<mapTypes.length; i++) {
			mapTypes[i].getMinimumResolution = function() { return minMapScale; }
			mapTypes[i].getMaximumResolution = function() { return maxMapScale; }
		}
	},
	
	setOverlay: function() {
		var overlayBounds = new GLatLngBounds(new GLatLng(37.125286284966776, -130.78125), new GLatLng(51.20688339486559, -108.80859375));		
		this._map.addOverlay(new GGroundOverlay(BASE_URL + "/images/map_overlay.png", overlayBounds));
	},
	
	checkBounds: function() {
		if (this._allowedBounds.contains(this._map.getCenter())) {
			return;
		}

		var center = this._map.getCenter();
		var x = center.lng();
		var y = center.lat();
		
		var maxX = this._allowedBounds.getNorthEast().lng();
		var maxY = this._allowedBounds.getNorthEast().lat();
		var minX = this._allowedBounds.getSouthWest().lng();
		var minY = this._allowedBounds.getSouthWest().lat();
		
		if (x < minX) { x = minX; }
		if (x > maxX) { x = maxX; }
		if (y < minY) { y = minY; }
		if (y > maxY) { y = maxY; }

		this._map.setCenter(new GLatLng(y, x));
	},
	
	directions: function(destinations, startingPoint, directionsContainer) {
		var me = this;
		this.clearMarkers();
		if (!this._directions) {
			this._directions = new GDirections(this._map, directionsContainer);
			GEvent.addListener(this._directions, "load", function() {
				$('#tripDetailsContainer').show();
				$('#tripDistance').html(me._directions.getDistance().html);
				$('#tripDuration').html(me._directions.getDuration().html);
			});
		}
		var tmp = [];
		if (startingPoint && destinations.length > 0) {
			tmp[0] = startingPoint;
			destinations = tmp.concat(destinations);
			destinations.push(startingPoint);
		}
		this._directions.loadFromWaypoints(destinations);
	},
	
	setType: function(type) {
		this._map.setMapType(type);
		return this;
	}	
}
