Index: /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 29225)
+++ /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 29226)
@@ -10,4 +10,8 @@
 /* Here you can choose which save buttons you like. Choose from 'save', 'rebuild', 'saveandrebuild' */
 var save_and_rebuild_buttons = ["saveandrebuild"];
+
+var save_button_text = "Save changes";
+var rebuild_button_text = "Rebuild";
+var save_and_rebuild_button_text = "Save and Rebuild";
 
 /* What kind of metadata element selection do we provide?
@@ -1149,5 +1153,5 @@
 	
 	var visibility = (visible ? "" : "none");
-	$("#saveButton, #metadataListLabel, #metadataSetList").css("display", visibility);
+	$("#metadataListLabel, #metadataSetList").css("display", visibility);
 	
 	$(".editMetadataButton").each(function()
@@ -1212,16 +1216,16 @@
 	  if (button_type == "save") {
 	    var saveButton = $("<button>", {"id": "saveButton", "class": "ui-state-default ui-corner-all"});
-	    saveButton.click(saveMetadataChanges);
-	    saveButton.html("Save changes");
+	    saveButton.click(save);
+	    saveButton.html(save_button_text);
 	    editBar.append(saveButton);
 	  } else if(button_type == "rebuild") {
 	    var rebuildButton = $("<button>", {"id": "rebuildButton", "class": "ui-state-default ui-corner-all"});
-	    rebuildButton.click(rebuildCollection);
-	    rebuildButton.html("Rebuild");
+	    rebuildButton.click(rebuildCurrentCollection);
+	    rebuildButton.html(rebuild_button_text);
 	    editBar.append(rebuildButton);
 	  } else if (button_type == "saveandrebuild") {
 	    var saveAndRebuildButton = $("<button>", {"id": "saveAndRebuildButton", "class": "ui-state-default ui-corner-all"});
-	    saveAndRebuildButton.click(save);
-	    saveAndRebuildButton.html("Save and Rebuild");
+	    saveAndRebuildButton.click(saveAndRebuild);
+	    saveAndRebuildButton.html(save_and_rebuild_button_text);
 	    editBar.append(saveAndRebuildButton);
 
@@ -1242,7 +1246,17 @@
 }
 
-
-/* this is a cut down version of save() from documentmaker_scripts_util.js */
-function saveMetadataChanges() {
+// override the one in documentmaker_scripts_util
+// currently not used if other one is present. need to get the js include order right
+function enableSaveButtons(enabled) {
+  if (enabled) {
+    $("#saveButton, #rebuildButton, #saveAndRebuildButton").removeAttr("disabled");
+  } else {
+    $("#saveButton, #rebuildButton, #saveAndRebuildButton").attr("disabled", "disabled");
+  }
+}
+
+/* this is a cut down version of save() from documentmaker_scripts_util.js 
+ going back to using save, will delete this once everything working*/
+function saveMetadataChangesOld() {
 
   console.log("Saving metadata changes");
@@ -1337,13 +1351,4 @@
 
 
-function rebuildCollection() {
-
-  console.log("rebuilding collection");
-  var collection = gs.cgiParams.c;
-
-  var collectionsArray = new Array();
-  collectionsArray.push(collection);
-  buildCollections(collectionsArray);
-}
 
 /***************
Index: /main/trunk/greenstone3/web/interfaces/default/js/documentmaker_scripts_util.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/documentmaker_scripts_util.js	(revision 29225)
+++ /main/trunk/greenstone3/web/interfaces/default/js/documentmaker_scripts_util.js	(revision 29226)
@@ -165,4 +165,15 @@
 }
 
+function enableSaveButtons(enabled) {
+  if (enabled) {
+    $("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
+    $("#saveButton, #quickSaveButton").removeAttr("disabled");
+
+  } else {
+    $("#saveButton, #quickSaveButton").html(gs.text.dse.saving + "...");
+    $("#saveButton, #quickSaveButton").attr("disabled", "disabled");
+   
+  }
+}
 function addCollectionToBuild(collection)
 {
@@ -177,5 +188,20 @@
 }
 
-function save() 
+function save() {
+  saveAndRebuild(false);
+}
+
+function rebuildCurrentCollection() {
+
+  console.log("rebuilding collection");
+  enableSaveButtons(false);
+  var collection = gs.cgiParams.c;
+
+  var collectionsArray = new Array();
+  collectionsArray.push(collection);
+  buildCollections(collectionsArray);
+}
+
+function saveAndRebuild(rebuild) 
 {
 //This works in most cases but will not work when taking a doc from one collection to another, will need to be fixed at some point
@@ -218,6 +244,5 @@
 					alert(gs.text.dse.error_saving);
 				
-					$("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
-					$("#saveButton, #quickSaveButton").removeAttr("disabled");
+					enableSaveButtons(true);
 					
 					if(_statusBar)
@@ -232,5 +257,10 @@
 					_statusBar.removeStatus(statusID);
 				}
-				buildCollections(_collectionsToBuild);
+				if (rebuild) {
+				  buildCollections(_collectionsToBuild);
+				} else {
+				  // reset the save button here
+				  enableSaveButtons(true);
+				}
 			}
 		}
@@ -238,6 +268,5 @@
 		if(_collectionsToBuild.length > 0)
 		{
-			$("#saveButton, #quickSaveButton").html(gs.text.dse.saving + "...");
-			$("#saveButton, #quickSaveButton").attr("disabled", "disabled");
+		  enableSaveButtons(false);
 
 			if(_statusBar)
@@ -369,6 +398,5 @@
 	{
 		console.log(gs.text.dse.empty_collection_list);
-		$("#saveButton, #quickSaveButton").html(gs.text.save_changes);
-		$("#saveButton, #quickSaveButton").removeAttr("disabled");
+		enableSaveButtons(true);
 		return;
 	}
@@ -415,6 +443,5 @@
 						_statusBar.removeStatus(statusID);
 					}
-					$("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
-					$("#saveButton, #quickSaveButton").removeAttr("disabled");
+					enableSaveButtons(true);
 					
 					return;
@@ -444,6 +471,5 @@
 									_statusBar.removeStatus(statusID);
 								}
-								$("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
-								$("#saveButton, #quickSaveButton").removeAttr("disabled");
+								enableSaveButtons(true);
 								
 								return;
@@ -477,6 +503,5 @@
 										_statusBar.removeStatus(statusID);
 									}
-									$("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
-									$("#saveButton, #quickSaveButton").removeAttr("disabled");
+									enableSaveButtons(true);
 								/*
 								});
@@ -523,6 +548,5 @@
 						_statusBar.removeStatus(statusID);
 					}
-					$("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
-					$("#saveButton, #quickSaveButton").removeAttr("disabled");
+					enableSaveButtons(true);
 					
 					return;
@@ -544,6 +568,5 @@
 						_statusBar.removeStatus(statusID);
 					}
-					$("#saveButton, #quickSaveButton").html(gs.text.dse.save_changes);
-					$("#saveButton, #quickSaveButton").removeAttr("disabled");
+					enableSaveButtons(true);
 				}
 				else
@@ -873,5 +896,5 @@
 	var saveButton = document.createElement("BUTTON");
 	saveButton.innerHTML = gs.text.dse.save_changes;
-	saveButton.setAttribute("onclick", "save();");
+	saveButton.setAttribute("onclick", "saveAndRebuild();");
 	saveButton.setAttribute("id", "saveButton");
 	saveCell.appendChild(saveButton);
