Index: main/trunk/greenstone2/web/script/gsajaxapi.js
===================================================================
--- main/trunk/greenstone2/web/script/gsajaxapi.js	(revision 23806)
+++ main/trunk/greenstone2/web/script/gsajaxapi.js	(revision 24072)
@@ -37,4 +37,9 @@
     }
 
+	this.buildserverURL = function()
+    {
+        return this.apiURL("build-server.pl");
+    }
+	
     this.explodeserverURL = function()
     {
@@ -148,6 +153,4 @@
         url += "&metavalue=" + metavalue;
 
-	//alert("url = " + url);
-
         this.urlGetSync(url);
     }
@@ -165,15 +168,32 @@
         }
         params += "&metavalue=" + metavalue;
-	if (metamode!=null) {
+		if (metamode!=null) {
             params += "&metamode=" + metamode;
-	}
-	// alert("params = " + params);
-	
-	//alert(mdserver + "?" + params);
-
+		}
+	
         this.urlGetSync(mdserver + "?" + params);
         //this.urlPostSync(mdserver,params);
     }
     
+	
+	this._setDocumentArrayMetadata = function(mode,docArray,metamode) 
+	{
+	    docArrayJSON = JSON.stringify(docArray);
+  
+		var mdserver = this.metadataserverURL();
+    
+        var params = "a=set" + mode + "-metadata-array";
+        params += "&c="+collect_;
+		params += "&json="+docArrayJSON;
+	
+		if (metamode!=null) {
+            params += "&metamode=" + metamode;
+		}
+		
+		this.urlGetSync(mdserver + "?" + params);
+   
+	}
+	
+	
     this.setDocumentMetadata = function(docid,metaname,metapos,metavalue)
     {
@@ -183,19 +203,28 @@
 	    metavalue = metapos;
 	    metapos = null;
-	}
-	
-	this._setMetadata("",docid,metaname,metapos,metavalue);
-	this._setMetadata("-archives",docid,metaname,metapos,metavalue,"override");
-    }
-
+		}
+	
+		this._setMetadata("",docid,metaname,metapos,metavalue);
+		this._setMetadata("-archives",docid,metaname,metapos,metavalue,"override");
+	
+    }
+
+	this.setDocumentArrayMetadata = function(docArray,metamode) 
+	{
+	    //showDialog('Greenstone Javascript API','This sequence of changes has been commited into the system.','success', 2);
+	
+		this._setDocumentArrayMetadata("",docArray,metamode);
+		this._setDocumentArrayMetadata("-archives",docArray,metamode);
+	}
+	
     this.setNewDocumentMetadata = function(docid,metaname,metavalue)
     {
-	this._setMetadata("",docid,metaname,null,metavalue);
-	this._setMetadata("-archives",docid,metaname,null,metavalue,"accumulate");
+		this._setMetadata("",docid,metaname,null,metavalue);
+		this._setMetadata("-archives",docid,metaname,null,metavalue,"accumulate");
     }
 	
     this.setImportMetadata = function(docid,metaname,metapos,metavalue)
     {
-	this._setMetadata("-import",docid,metaname,metapos,metavalue,"override");
+		this._setMetadata("-import",docid,metaname,metapos,metavalue,"override");
     }
 	
@@ -205,13 +234,38 @@
         var exserver = this.explodeserverURL();
 
-        var url = exserver + "?a=explode";
+        var url = exserver + "?a=explode-document";
         url += "&c="+collect_;
         url += "&d="+docid;
-
-	// alert("url = " + url);
-	
-        this.urlGetSync(url);
-    }
-
+	
+        this.urlGetSync(url);
+    }
+
+	 this.deleteDocument = function(docid,onlyAdd)
+    {
+        var exserver = this.explodeserverURL();
+
+        var url = exserver + "?a=delete-document";
+        url += "&c="+collect_;
+		params += "&onlyadd="+onlyAdd;
+        url += "&d="+docid;
+	
+        this.urlGetSync(url);
+    }
+
+	this.deleteDocumentArray = function(docArray,onlyAdd) 
+	{
+	    docArrayJSON = JSON.stringify(docArray);
+  
+		var exserver = this.explodeserverURL();
+    
+        var params = "a=delete-document-array";
+        params += "&c="+collect_;
+		params += "&onlyadd="+onlyAdd;
+		params += "&json="+docArrayJSON;
+		
+		this.urlGetSync(exserver + "?" + params);
+   
+	}
+	
 
     this.cloneDocument = function(docid,toCollect)
@@ -223,6 +277,4 @@
         url += "&d="+docid;
         url += "&toCollect="+toCollect;
-
-	// alert("url = " + url);
 	
         this.urlGetSync(url);
@@ -238,6 +290,4 @@
         url += "&d="+docid;
 
-	// alert("url = " + url);
-    
         this.urlGetSync(url);
     }
@@ -247,6 +297,6 @@
     {
         if (mode==null) {
-	    mode = "incremental";
-	}
+			mode = "incremental";
+		}
 
         var idserver = this.indexserverURL();
@@ -254,6 +304,4 @@
         var url = idserver + "?a=" + mode + "-rebuild";
         url += "&c="+collect_;
-
-	// alert("url = " + url);
     
         this.urlGetAsync(url,callback);
@@ -261,4 +309,45 @@
     
 
+	this.buildByManifestGeneral = function(hashargs) 
+	{
+        var idserver = this.buildserverURL();
+    
+        var url = idserver + "?a=build-by-manifest";
+        url += "&c="+collect_;
+		
+		if (hashargs["index-files"] != undefined) {
+			url += "&index-files=" +  JSON.stringify(hashargs["index-files"]);
+		}
+		
+		if (hashargs["reindex-files"] != undefined) {
+			url += "&reindex-files=" +  JSON.stringify(hashargs["reindex-files"]);
+		}
+		if (hashargs["delete-OIDs"] != undefined) {
+			url += "&delete-OIDs=" +  JSON.stringify(hashargs["delete-OIDs"]);
+		}
+	
+        this.urlGetSync(url);
+	}
+	
+	this.indexByManifest = function(docidArray) 
+	{
+		var hashargs = {};
+		hashargs["index-files"] = docidArray;
+		this.buildByManifestGeneral(hashargs);
+	}
+	
+	this.reindexByManifest = function(docidArray) 
+	{
+		var hashargs = {};
+		hashargs["reindex-files"] = docidArray;
+		this.buildByManifestGeneral(hashargs);
+	}
+	this.deleteByManifest = function(docidArray) 
+	{
+		var hashargs = {};
+		hashargs["delete-OIDs"] = docidArray;
+		this.buildByManifestGeneral(hashargs);
+	}
+	
     this.getLiveMetadata = function(id,metaname)
     {
@@ -270,10 +359,6 @@
         url += "&metaname=" + metaname;
 
-	//alert("url = " + url);    
-
         var metavalue = this.urlGetSync(url);
-    
-        //alert("metavalue = " + metavalue);
-
+  
         return metavalue;
     }
@@ -293,7 +378,4 @@
         return this.urlGetSync(url);
     }
-
-
-
     
     this.removeLiveMetadata = function(id,metaname)
@@ -306,9 +388,6 @@
         url += "&metaname=" + metaname;
 
-	//alert("url = " + url);
-
-        this.urlGetSync(url);
-    }
-    
+        this.urlGetSync(url);
+    }
     
     this.removeDocumentMetadata = function(docid,metaname,metapos)
@@ -324,9 +403,6 @@
         }
 
-	//alert("url = " + url);
-    
-        this.urlGetSync(url);
-    }
-
+        this.urlGetSync(url);
+    }
 
     return true;
