	var shipWreckArray = Array();
	var diveSiteArray = Array();
	var diveArray = Array();
	var map;
	var centerPoint = new GLatLng(40.078071,-101.689453);
	var bounds = new GLatLngBounds();
	var count = 0;

	function doLoad() {
		if( GBrowserIsCompatible() ) {
			map = new GMap2(document.getElementById("map"));
			map.setCenter(centerPoint, 7);
			map.addControl(new GSmallMapControl());
		}
	}

	/*
	 * This method will bound the wreck area
	 */
	function addShipWreckMarkers() {
		if( shipWreckArray.length > 0 ) {
//			var bounds = new GLatLngBounds();
			for( n = 0; n < shipWreckArray.length ; n++ ) {
				var mData = shipWreckArray[n].split(';');
				var point = new GLatLng( mData[0], mData[1] );
				bounds.extend(point);

				// createWreckMarker( point, lowerDepth, upperDepth, vesselName, id, latlonType ) {
				var marker = createWreckMarker( point, mData[2], mData[3], mData[4], mData[5], mData[6] );
				map.addOverlay(marker);
				count++;
			}
			map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); 
		}
	}

	function addSingleShipWreckMarker() {
		if( shipWreckArray.length > 0 ) {
			for( n = 0; n < shipWreckArray.length ; n++ ) {
				var mData = shipWreckArray[n].split(';');
				var point = new GLatLng( mData[0], mData[1] );
				map.setCenter(point, 7 );

				// createWreckMarker( point, lowerDepth, upperDepth, vesselName, id, latlonType ) {
				var marker = createWreckMarker( point, mData[2], mData[3], mData[4], mData[5], mData[6] );
				map.addOverlay(marker);
			}
		}
	}

	/*
	 * This method will bound the wreck area
	 */
	function addDiveSiteMarkers() {
		if( diveSiteArray.length > 0 ) {
//			var bounds = new GLatLngBounds();
			for( n = 0; n < diveSiteArray.length; n++ ) {
				var mData = diveSiteArray[n].split(';');
				var point = new GLatLng( mData[0], mData[1] );
				bounds.extend(point);
				//					  name	    id
				var marker = createDiveSiteMarker( point, mData[2], mData[3] );
				map.addOverlay(marker);
				count++;
			}
			map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); 
		}
	}

	function addSingleDiveSiteMarker() {
		if( diveSiteArray.length > 0 ) {
			for( n = 0; n < diveSiteArray.length; n++ ) {
				var mData = diveSiteArray[n].split(';');
				var point = new GLatLng( mData[0], mData[1] );
				map.setCenter(point, 7 );
				bounds.extend(point);
				//					  name	    id
				var marker = createDiveSiteMarker( point, mData[2], mData[3] );
				map.addOverlay(marker);
				count++;
			}
		}
	}

	/*
	 * Since we're more interested in the wrecks, we don't bound any of the shops
	 */
	function addDiveShopMarkersOLD() {
		if( diveArray.length > 0 ) {
//			var bounds = new GLatLngBounds();
			for( n = 0; n < diveArray.length ; n++ ) {
				var mData = diveArray[n].split(';');
				var point = new GLatLng( mData[0], mData[1] );
				bounds.extend(point);

				//					   name     charter     id        phone     addr1     city
				var marker = createDiveShopMarker( point, mData[2], mData[3], mData[4], mData[5], mData[6], mData[7] );
				map.addOverlay(marker);
			}
			map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); 
		}
	}

	function addDiveShopMarkers() {
		if( diveArray.length > 0 ) {
//			var bounds = new GLatLngBounds();
			for( n = 0; n < diveArray.length ; n++ ) {
				var mData = diveArray[n].split(';');
				var point = new GLatLng( mData[0], mData[1] );
				bounds.extend(point);

				//					   name     charter     id        phone     addr1     city
				var marker = createDiveShopMarker( point, mData[2], mData[3], mData[4], mData[5], mData[6], mData[7] );
				map.addOverlay(marker);
			}
			// only center on the dive shops if there is nothing else to center on
			if( count == 0 ) {
				map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); 
			}
		}
	}

	function addSingleDiveShopMarker() {
		if( diveArray.length > 0 ) {
			for( n = 0; n < diveArray.length ; n++ ) {
				var mData = diveArray[n].split(';');
				var point = new GLatLng( mData[0], mData[1] );
				map.setCenter(point, 7 );

				//					   name     charter     id        phone     addr1     city
				var marker = createDiveShopMarker( point, mData[2], mData[3], mData[4], mData[5], mData[6], mData[7] );
				map.addOverlay(marker);
			}
		}
	}

	function createDiveSiteMarker( point, name, id ) {
		var icon = new GIcon();

		icon.image = "../images/black.png";

		icon.iconSize = new GSize( 12, 20 );
		icon.iconAnchor = new GPoint( 6, 20 );
		icon.infoWindowAnchor = new GPoint( 6, 20 );

		var latlng = new GLatLng( point.y, point.x );

		var marker = new GMarker(point,{title:name,icon:icon});
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml('<div style="width:250px;">' + name + '<hr><br />' + 
				'Site Info:<a href="http://www.divetheunitedstates.com/search/diveSite.php?id=' + id + '">Click Here!</a></div>');
		});
		return marker;
	}

	function createDiveShopMarker( point, name, diveOperator, id, phone, addr1, city ) {
		var icon = new GIcon();

		if( diveOperator == 't' ) {
			// Dive Operators
			icon.image = "../images/purple.png";
		} else {
			// Dive Shops
			icon.image = "../images/white.png";
		}

		icon.iconSize = new GSize( 12, 20 );
		icon.iconAnchor = new GPoint( 6, 20 );
		icon.infoWindowAnchor = new GPoint( 6, 20 );

		var latlng = new GLatLng( point.y, point.x );

		var marker = new GMarker(point,{title:name,icon:icon});
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml('<div style="width:250px;">' + name + '<hr><br />' + 
				phone + '<br />' + addr1 + '<br />' + city + '<br /><br />' + 
				'Shop Info:<a href="http://www.divetheunitedstates.com/search/diveShop.php?id=' + id + 
				'">Click Here!</a></div>');
		});
		return marker;
	}

	function createWreckMarker( point, lowerDepth, upperDepth, vesselName, id, divable ) {
		var icon = new GIcon();

		if( divable == "s" ) {
			icon.image = "../images/red.png";
		} else if( divable == "p" ) {
			icon.image = "../images/brown.png";
		} else {
			if( upperDepth > 0 || lowerDepth > 0 ) {
				if( ( upperDepth < 130 && upperDepth >= 0) || 
				    ( lowerDepth < 130 && lowerDepth >= 0)  ) {
		       			icon.image = "../images/green.png";
		  		} else {
		       			icon.image = "../images/blue.png";
		    		}
			} else {
				icon.image = "../images/yellow.png";
			}
		}

		icon.iconSize = new GSize( 12, 20 );
		icon.iconAnchor = new GPoint( 6, 20 );
		icon.infoWindowAnchor = new GPoint( 6, 20 );

		var latlng = new GLatLng( point.y, point.x );

		var marker = new GMarker(point,{title:vesselName,icon:icon});
		GEvent.addListener(marker, "click", function() {
			if( lowerDepth == -1 ) { lowerDepth = "Unknown"; }
			if( upperDepth == -1 ) { upperDepth = "Unknown"; }
			marker.openInfoWindowHtml('<div style="width:250px;">' + vesselName + '<hr>Lower Depth: ' + 
				lowerDepth + '<br />Upper Depth: ' + upperDepth + '<br /><br />' + 
				'Wreck Info:<a href="http://www.divetheunitedstates.com/search/wreckDive.php?id=' + id + 
				'">Click Here!</a></div>');
		});
		return marker;
	}
