/* Define Custom Icons */
	var smicon = new GIcon(G_DEFAULT_ICON);
	smicon.image = "images/mapIcons/smgreendot.png";
	smicon.iconSize = new GSize(10, 10);
	smicon.iconAnchor = new GPoint(5, 5);
	smicon.shadow = "";

	var infoIcon = new GIcon(G_DEFAULT_ICON);
	infoIcon.image = "images/mapIcons/infoBlue16.png";
	infoIcon.iconSize = new GSize(16, 16);
	infoIcon.iconAnchor = new GPoint(8, 8);
	infoIcon.shadow = "";

	var warningYellowIcon = new GIcon(G_DEFAULT_ICON);
	warningYellowIcon.image = "images/mapIcons/warningYellow16.png";
	warningYellowIcon.iconSize = new GSize(16, 16);
	warningYellowIcon.iconAnchor = new GPoint(8, 8);
	warningYellowIcon.shadow = "";

	var warningRedIcon = new GIcon(G_DEFAULT_ICON);
	warningRedIcon.image = "images/mapIcons/warningRed16.png";
	warningRedIcon.iconSize = new GSize(16, 16);
	warningRedIcon.iconAnchor = new GPoint(8, 8);
	warningRedIcon.shadow = "";

/* Load Default Map Controls and Listeners*/
function DefaultMapControls() {
	map.addControl(new GSmallMapControl());
	map.addControl(new GScaleControl());
	map.addControl(new GMapTypeControl());
	map.addMapType(G_PHYSICAL_MAP);
	map.setMapType(G_NORMAL_MAP);

	GEvent.addListener(map, "zoomend", function(oldzoom, newzoom) {
		if (oldzoom < newzoom ) {
			/* zooming in */
		  	if (newzoom == 11) {map.setMapType(G_PHYSICAL_MAP);}
		  	if (newzoom == 14) {map.addMapType(C_USGS_TOPO);}

		}else {
			/* zooming out */
			if (newzoom == 10) {map.setMapType(G_NORMAL_MAP);}
			if (newzoom == 13) {map.removeMapType(C_USGS_TOPO);map.setMapType(G_PHYSICAL_MAP);}
		}
		 document.getElementById("zoom").innerHTML = newzoom;
	}); // end map zoomend listener

	GEvent.addListener(map, "singlerightclick", function(point){
		var latlng = map.fromContainerPixelToLatLng(point).toUrlValue(4);
		alert( "You right-clicked at "+latlng+"\n New features coming soon: \n - search for older reports near here \n - center map here \n - share link to this point ");
	});


} /* end loadMap */


function inverseOrder(marker,b) {
        return -GOverlay.getZIndex(marker.getPoint().lat());
}

//Marker Generator - 3rd Generation:
function createMarker3(id, lat, lng, edate, source, title, info, link, P, Z) {
	var alt = title +" | "+ edate +" | "+ source;
	var ll = new GLatLng(lat, lng);
	var zindex = Z;
	//var marker = new GMarker(ll,{title: alt ,icon:smicon, zIndexProcess:zIndexProcess:inverseOrder});
	var marker = new GMarker(ll,{title: alt, icon: smicon});
	marker.value = id;
	allmarkers[id] = marker;
	report_id[id] = ll;
	var info = "<div class='mapInfo'><b>"+title+"</b><br/>"+source+": "+edate+"<span style='float:right;'>"+P+"</span><br/>"+info+"<br/>"+link+"<br><small>Feedback: [Wrong Location] | [Trash]</small></div>";
	GEvent.addListener(marker, "click", function() {
		map.openInfoWindowHtml(ll, info);
		pageTracker._trackPageview('/info/'+id);
	});
	bounds.extend(ll);
	return marker;
}

//Marker Generator - 4rd Generation:
function createMarker4(id, lat, lng, edate, source, title, info, link, P, mid) {
	var alt = title +" | "+ edate +" | "+ source;
	var ll = new GLatLng(lat, lng);
	var marker = new GMarker(ll,{title: alt, icon: smicon});
	marker.value = id;
	allmarkers[id] = marker;
	report_id[id] = ll;
	var info = "<div class='mapInfo'><b>"+title+"</b><br/>"+source+": "+edate+"<span style='float:right;'>"+P+"</span><br/>"+info+"<br/>"+link+"<br><small>Feedback: [<a class='latlngInput' id='move"+id+"' href='#move"+id+"' onclick='moveMarker("+mid+"); return false;'>Move Marker</a>] | [Trash]</small></div>";
	GEvent.addListener(marker, "click", function() {
		map.openInfoWindowHtml(ll, info);
		pageTracker._trackPageview('/info/'+mid);
	});
	bounds.extend(ll);
	return marker;
}

// "<a class='latlngInput' id='$report_id' href='#$report_id' onclick='getLatLng(this.id); return false;'>[Add Marker]</a>"

/*Marker Generator*/
function infoMarker(id, lat, lng, edate, source, title, info, link, P, Z, customIcon) {
	var alt = title +" | "+ edate +" | "+ source;
	var ll = new GLatLng(lat, lng);
	var marker = new GMarker(ll,{title: alt, icon: customIcon});
	infomarkers[id] = marker;
	var info = "<div class='mapInfo'><b>"+title+"</b><br/>"+source+": "+edate+"<span style='float:right;'>"+P+"</span><br/>"+info+"<br/>"+link+"<br></div>";
	GEvent.addListener(marker, "click", function() {
		map.openInfoWindowHtml(ll, info);
		pageTracker._trackPageview('/info/'+id);
	});
	bounds.extend(ll);
	return marker;
}

/*Marker Generator*/
function findMarker(id, lat, lng, edate, source, title, info, link, P, Z, customIcon) {
	var alt = title +" | "+ edate +" | "+ source;
	var ll = new GLatLng(lat, lng);
	var marker = new GMarker(ll,{title: alt, icon: customIcon});
	return marker;
}

