Index: main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js
===================================================================
--- main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js	(revision 32770)
+++ main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js	(revision 32771)
@@ -1,2 +1,3 @@
+//var newLat, newLng = 0;
 var _docList = new Array();
 _docList.ids = new Array();
@@ -87,6 +88,10 @@
 		mapTypeId: google.maps.MapTypeId.HYBRID
 	};
-	_map = new google.maps.Map($("#map_canvas")[0], myOptions);
-	google.maps.event.addListener(_map, 'bounds_changed', performSearchForMarkers);
+	var $map_canvas = $("#map_canvas");
+	
+	if ($map_canvas.length > 0) {
+		_map = new google.maps.Map($map_canvas[0], myOptions);
+		google.maps.event.addListener(_map, 'bounds_changed', performSearchForMarkers);
+	}
 }
 
@@ -331,8 +336,31 @@
 function attachClickHandler(marker, nodeID)
 {
+
+	
 	google.maps.event.addListener(marker, 'click', function()
 	{
 		document.location.href = gs.xsltParams.library_name + "?a=d&ed=1&c=" + gs.cgiParams.c + "&d=" + nodeID + "&dt=hierarchy&p.a=b&p.sa=&p.s=ClassifierBrowse";
 	});
+	
+	if (("docEdit" in gs.cgiParams) && (gs.cgiParams['docEdit'])) {
+		google.maps.event.addListener(marker, 'mouseup', function()
+		{
+			var lat = marker.getPosition().lat();
+			var lng = marker.getPosition().lng();
+			var collection = gs.cgiParams.c;;
+			var site_name = gs.xsltParams.site_name;
+			
+			if (nodeID == "") {
+				nodeID = gs.cgiParams.d;
+			}
+			console.log("GPS Click handler in collection:" + collection + " in site: " + site_name + " for Doc: " + nodeID + "(" + lat + "," + lng + ")");
+			
+			var callbackFunction = function(){console.log("Completed saving metadata changes. You must rebuild the collection for the changes to take effect.");};
+	
+			gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Latitude", null, lat, null, "override", function(){callbackFunction();});
+			gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Longitude", null, lng, null, "override", function(){callbackFunction();});
+			
+		});
+	}
 }
 
@@ -367,15 +395,10 @@
 {
 	var pos = new google.maps.LatLng(doc.lat,doc.lng);
+	
+	var docEdit = (("docEdit" in gs.cgiParams) && (gs.cgiParams['docEdit']));
+	var draggable_val = (docEdit) ? true : false;
+	
 	var marker
 	if(mainMarker)
-	{
-		marker = new google.maps.Marker
-		({
-			position: pos,
-			title:doc.title,
-			map:_map
-		});
-	}
-	else
 	{
 		marker = new google.maps.Marker
@@ -384,8 +407,21 @@
 			title:doc.title,
 			map:_map,
-			icon:"interfaces/" + gs.xsltParams.interface_name + "/images/bluemarker.png"
+			draggable: draggable_val
 		});
 	}
-
+	else
+	{
+		marker = new google.maps.Marker
+		({
+			position: pos,
+			title:doc.title,
+			map:_map,
+			icon:"interfaces/" + gs.xsltParams.interface_name + "/images/bluemarker.png",
+			draggable: draggable_val
+		});
+	}
+
+	console.log("doc = " + JSON.stringify(doc));
+	
 	var docElement = gs.jqGet("div" + doc.nodeID);
 	var parent;
@@ -410,4 +446,37 @@
 	doc.marker = marker;
 	attachClickHandler(marker, doc.nodeID);
+
+	////////////////////////////////////////////////////// TEST
+	
+	newLat = marker.getPosition().lat();
+	newLng = marker.getPosition().lng();
+	//console.log("Latitude " + newLat);
+	//console.log("Longitude " + newLng);
+	NewLatLng(newLat, newLng);
+//	// Define the LatLng coordinates for the polygon's path.
+//        var triangleCoords = [
+//          {lat: 18.774, lng: -80.190},
+//          {lat: 18.466, lng: -64.600},
+//          {lat: 32.321, lng: -64.757},
+//          {lat: 32.300, lng: -80.190},
+//		  {lat: 28.300, lng: -90.190}
+//        ];
+//
+//        // Construct the polygon.
+//        var bermudaTriangle = new google.maps.Polygon({
+//          paths: triangleCoords,
+//          strokeColor: '#FF0000',
+//          strokeOpacity: 0.8,
+//          strokeWeight: 2,
+//          fillColor: '#FF0000',
+//          fillOpacity: 0.35
+//        });
+//        bermudaTriangle.setMap(map);
+}
+
+function NewLatLng(lat, lng)
+{
+	console.log("Latitude " + lat);
+	console.log("Longitude " + lng);
 }
 
