Index: trunk/zoo-project/zoo-client/lib/js/wps-client/zoo.js
===================================================================
--- trunk/zoo-project/zoo-client/lib/js/wps-client/zoo.js	(revision 517)
+++ trunk/zoo-project/zoo-client/lib/js/wps-client/zoo.js	(revision 719)
@@ -73,4 +73,10 @@
          * @access public
 	 * @memberof ZooProcess#
+	 * @var version {String} The WPS version
+	 */
+        this.version = params.version?params.version:"1.0.0";
+        /**
+         * @access public
+	 * @memberof ZooProcess#
 	 * @var language {String} The language to be used to request the WPS Server
 	 * @default "en-US"
@@ -137,5 +143,5 @@
                 request: 'GetCapabilities',
                 service: 'WPS',
-                version: '1.0.0',
+                version: (params.hasOwnProperty('version')?params.version:closure.version),
             }
 
@@ -170,5 +176,5 @@
                 request: 'DescribeProcess',
                 service: 'WPS',
-                version: '1.0.0',
+                version: (params.hasOwnProperty('version')?params.version:closure.version),
             }
 
@@ -198,5 +204,5 @@
                 request: 'Execute',
                 service: 'WPS',
-                version: '1.0.0',
+                version: (params.hasOwnProperty('version')?params.version:closure.version),
                 Identifier: params.identifier,
                 DataInputs: params.dataInputs ? params.dataInputs : '',
@@ -204,7 +210,11 @@
             }
 
+	    console.log(zoo_request_params);
 
             if (params.hasOwnProperty('responseDocument')) {
                 zoo_request_params.ResponseDocument = params.responseDocument;
+            }
+            if (params.hasOwnProperty('mode')) {
+                zoo_request_params.mode = params.mode;
             }
             if (params.hasOwnProperty('storeExecuteResponse') &&  params.storeExecuteResponse) {
@@ -257,4 +267,5 @@
                     console.log("======== POST PAYLOAD ========");
                     console.log(payload);
+		    console.log(params);
 		}
 
@@ -367,13 +378,25 @@
 			}
 			var launched;
-			
-			if (params.storeExecuteResponse == 'true' && params.status == 'true') {
-			    launched = closure.parseStatusLocation(data);            
-			    closure.statusLocation[launched.sid] = launched.statusLocation;
-			    
-			    if ( launched.hasOwnProperty('sid') && 
-				 !closure.launched.hasOwnProperty(launched.sid)) {
-				closure.launched[launched.sid] = launched.statusLocation;
+			var version=(params.version?params.version:closure.version);
+			if(version=="1.0.0"){
+			    if (params.storeExecuteResponse == 'true' && params.status == 'true') {
+				launched = closure.parseStatusLocation(data);            
+				closure.statusLocation[launched.sid] = launched.statusLocation;
+				
+				if ( launched.hasOwnProperty('sid') && 
+				     !closure.launched.hasOwnProperty(launched.sid)) {
+				    closure.launched[launched.sid] = launched.statusLocation;
+				}
 			    }
+			}
+			else{
+			    if (params.mode == 'async') {
+				launched = closure.parseJobID(data);
+				closure.statusLocation[launched.sid] = closure.url+"?request=GetStatus&service=WPS&version=2.0.0&JobID="+launched.jobid;
+				if ( launched.hasOwnProperty('sid') && 
+				     !closure.launched.hasOwnProperty(launched.sid)) {
+				    closure.launched[launched.sid] = launched.jobid;
+				}
+			    }	    
 			}
 
@@ -446,4 +469,77 @@
 		}
 
+		if(data.StatusInfo || data.Result){
+		    if (data.Result) {
+
+			var ret = {
+                            sid: sid,
+                            text: "",
+                            result: data
+			};
+
+			if (handlers.onProcessSucceeded instanceof Function) {
+                            handlers.onProcessSucceeded(ret);
+			}
+
+			return;
+		    }
+		    if (data.StatusInfo.Status == "Running") {
+			if(closure.debug){
+			    console.log("#### ProcessStarted");
+			}
+			
+			var message="";
+			for(index=0;index<data._origin.childNodes[0].childNodes.length;index++){
+			    if(data._origin.childNodes[0].childNodes[index].nodeType==8){
+				message=data._origin.childNodes[0].childNodes[index].textContent;
+			    }
+			}
+			var ret = {
+                            sid: sid,
+                            percentCompleted: (data.StatusInfo.PercentCompleted?data.StatusInfo.PercentCompleted:0),
+                            text: message,
+                            creationTime: "",
+			};
+
+			if (handlers.onPercentCompleted instanceof Function) {
+                            handlers.onPercentCompleted(ret);
+			}
+                    }
+                    else if (data.StatusInfo.Status == "Succeeded") {
+			if(closure.debug){
+			    console.log("#### ProcessSucceeded");
+			}
+
+			var text = "";
+			closure.terminated[sid] = true;
+
+			ret = {
+                            sid: sid,
+                            text: text,
+                            result: data
+			};
+			
+			closure.getResult(sid, onSuccess, onError);
+                    }
+                    else {
+			if(closure.debug){
+			    console.log("#### UNHANDLED EXCEPTION");
+			}
+			closure.terminated[sid] = true;
+			ret = {
+                            sid: sid,
+                            code: 'BAD',
+                            text: 'UNHANDLED EXCEPTION'
+			};
+			
+			//closure.emit('exception', ret);
+			if (handlers.onError instanceof Function) {
+                            handlers.onError(ret);
+			}
+                    }
+
+		    return
+		}
+
 		if (data.ExecuteResponse.Status.ProcessAccepted) {
                     var ret = {
@@ -529,4 +625,5 @@
                     console.log("PING: "+sid);
 		}
+
                 closure.getStatus(sid, onSuccess, onError);
                 if (closure.terminated[sid]) {
@@ -613,4 +710,53 @@
 		    });
         };
+
+	/**
+	 * The getResult method is used by {@link ZooProcess#watch} to get the
+	 * final result of services called asynchronously.
+	 * 
+	 * @method getResult
+	 * @memberof ZooProcess#
+	 * @param {Integer} sid Service Identifier
+	 * @param {Function} onSuccess callback 
+	 * @param {Function} onError callback 
+	 */
+        this.getResult = function(sid, onSuccess, onError) {
+            var closure = this;
+	    if(closure.debug){
+		console.log("GET STATUS: "+sid);
+		console.log(closure.statusLocation[sid].replace(/GetStatus/g,"GetResult"));
+	    }
+            $.ajax({
+		url: closure.statusLocation[sid].replace(/GetStatus/g,"GetResult")
+	    })
+		.fail(
+                    function(jqXHR, textStatus, errorThrown) {
+			if(closure.debug){
+			    console.log("======== ERROR ========");
+			}
+			var robj=_x2js.xml2json( jqXHR.responseXML );
+			if(closure.debug){
+			    console.log(robj);
+			}
+			if(onError)
+			    onError(robj);
+                    }
+		)
+		.done(
+                    function(data, textStatus, jqXHR) {
+			if(closure.debug){
+			    console.log("======== SUCCESS ========2");
+			    console.log(data);
+			}
+			var ctype=jqXHR.getResponseHeader("Content-Type").split(";")[0];
+			if( ctype=="text/xml" ){
+			    var tmpD=data;
+			    data = _x2js.xml2json( data );
+			    data._origin=tmpD;
+			}
+			if(onSuccess)
+			    onSuccess(data);
+		    });
+        };
         
 	/**
@@ -791,4 +937,63 @@
             }
         };        
+
+	/**
+	 * The parseJobID method parse the JobID and return an
+	 * object with sid and the JobID attributes which contains
+	 * respectively: a unique identifier named sid and the JobID
+	 * value returned by the WPS server.
+	 * 
+	 * @method parseJobID
+	 * @memberof ZooProcess#
+	 * @param {Object} data The XML response parsed by x2js.xml2json
+	 * @returns {Object} The result is an object with sid and jobID
+	 */
+        this.parseJobID = function(data) {
+            var closure = this;
+
+            if (jobID = data.StatusInfo.JobID) {
+
+		var lsid=0;
+		for(i in closure.statusLocation)
+		    lsid++;
+		
+                return {sid: lsid, jobid: jobID};
+            }
+        }; 
+
+	/**
+	 * The dismiss method run the Dismiss request by calling {@link ZooProcess#request}.
+	 * 
+	 * @method dismiss
+	 * @memberof ZooProcess#
+	 * @param {Object} params 
+	 * @example
+	 * // Log x2js representation of all available services in console
+	 * myZooObject.dismiss({
+	 *     type: 'POST',
+	 *     jobid: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
+	 *     success: function(data){
+	 *         console.log(data);
+	 *     }
+	 * });
+	 */
+        this.dismiss = function(params) {
+            var closure = this;
+
+            if (!params.hasOwnProperty('type')) {
+                params.type = 'GET';
+            }
+
+            var zoo_request_params = {
+                Identifier: params.identifier,
+                request: 'Dismiss',
+                service: 'WPS',
+		jobid: params.jobid,
+                version: "2.0.0",
+            }
+
+            this.request(zoo_request_params, params.success, params.error, params.type);
+        };
+
     };
     
