    /**************************************************
     *****               AJAX / WS                *****
     **************************************************/

    // The following [ws-call-name] routines setup the AJAX
    // transaction and make the request to the web services. Given
    // certain JavaScript security restrictions and the overhead 
    // associated with SOAP, we call local (to the web server) PHP 
    // WS wrappers.

    // Global sUrl base specific to where the user is browsing.
    var sUrlBase = 'http://' + document.location['hostname'];

//                 + '/spruce-portal';

    function addUserToToken(token, real_name, email, identity, sh, fh) {
      var sUrl = sUrlBase + '/ws/addUserToToken.php';
      var callback = {
        success: sh,
        failure: fh
      }

      var post_data = 'token='      + encodeURIComponent(token)
                    + '&real_name=' + encodeURIComponent(real_name)
                    + '&email='     + encodeURIComponent(email)
                    + '&identity='  + encodeURIComponent(identity);

      var transaction =
          YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, post_data);

      return transaction;
    }

   
    function addReservation(resource, nodes, start, duration, token, sh, fh) {
	var sUrl = sUrlBase + '/ws/addReservation.php';
 	var callback = {
	   success: sh,
	   failure: fh
	}

	var post_data = 'token='  	+ encodeURIComponent(token)
		      	+ '&hostname=' 	+ encodeURIComponent(resource)
			+ '&nodes='	+ encodeURIComponent(nodes)
			+ '&timestamp='	+ encodeURIComponent(start)
			+ '&duration='	+ encodeURIComponent(duration);

	var transaction =
	    YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, post_data);

	return transaction;
    }

    function removeUserFromToken(token, identity, sh, fh) {
      var sUrl = sUrlBase + '/ws/removeUserFromToken.php';
      var callback = {
        success: sh,
        failure: fh
      }

      var post_data = 'token='     + encodeURIComponent(token)
                    + '&identity=' + encodeURIComponent(identity);

      var transaction =
          YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, post_data);

      return transaction;
    }
    
    function activateToken(token, comment, sh, fh) {
      var sUrl = sUrlBase + '/ws/activateToken.php'
      var callback = {
        success: sh,
        failure: fh
      }

      var post_data = 'token=' + encodeURIComponent(token)
                    + '&comment=' + encodeURIComponent(comment);

      var transaction =
          YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, post_data);

      return transaction;
    }

    function getTokenInfo(token, sh, fh) {
      sUrl = sUrlBase + '/ws/getTokenInfo.php?token=' + encodeURIComponent(token);
      var callback = {
        success: sh,
        failure: fh
      }

      var transaction =
        YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
  
      return transaction;
    }

    function getUserInfo(email, identity, sh, fh) {
      var sUrl = sUrlBase + '/ws/getUserInfo.php?'
               + 'email=' + encodeURIComponent(email)
               + '&identity=' + encodeURIComponent(identity);

      var callback = {
        success: sh,
        failure: fh
      }

      var transaction =
        YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
  
      return transaction;
    }


    function checkTokenTime(token, sh, fh) {
      var sUrl = sUrlBase + '/ws/checkTokenTime.php?token='
               + encodeURIComponent(token);

      var callback = {
        success: sh,
        failure: fh
      }

      var transaction =
          YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
  
      return transaction;
    }

