    /**************************************************
     *****           Button Routines              *****
     **************************************************/

    // The following methods are called by event listeners attached
    // to the buttons.

    function activate_token() {
      // Get the token value and attempt to activate it.
      token_value = document.getElementById("token_input").value;
      comment_value = document.getElementById("comment").value;

      activateToken(token_value, comment_value,
                    activateTokenSuccess, failureHandler);
    }
    
    function cancel_activate() {
      var html = '<p><em class="orange">Cancelled activating token.</em></p>';
      document.getElementById('announce_field').innerHTML= html;

      YAHOO.util.Event.removeListener('activate_button', 'click', activate_token);
      YAHOO.util.Event.addListener('activate_button', 'click', show_comment_form);
    }

    function add_user() {
      // Get the arguments and attempt to add the user.
      token_value = document.getElementById("token_input").value;
      real_name = document.getElementById("real_name").value;
      email = document.getElementById("email").value;
      identity = document.getElementById("identity").value;

      // Validate fields before calling WS.
      var err = '';
      if (token_value.length == 0) {
        err = 'Malformed token string';
      } else if (real_name.length == 0) {
        err = 'You must provide a name.';
      } else if (email.length == 0) {
        err = 'You must provide an email address.';
      } else if (identity.length == 0) {
        err = 'You must provide an identity.';
      }
      
      if ( err.length != 0 ) {
        alert(err);
      } else {
        addUserToToken(token_value, real_name, email, identity,
                       addUserToTokenSuccess, failureHandler);
      }
    }

    function add_reserv() {
	//Get the arguments and attempt to make reservation.
	//do some error checking
	//call webservice to spruce harc and get values back
	//for now
	//token_value = document.getElementById("token_input").value;
	token_value = 'X44Q-5WNH-75YT-6XEM';
	res1 = document.getElementById("res1").value;
	nodes1 = document.getElementById("nodes1").value;
	start = document.getElementById("start").value;
	duration = document.getElementById("duration").value;

	//Validate fields before calling WS.
	var err= '';
	if (token_value.length == 0) {
 	  err = 'Malformed token string';
	} else if (res1.length == 0) {
	  err = 'You must provide Resource name';
	} else if (nodes1.length == 0) {
	  err = 'You must provide number of nodes';
	} else if (start.length == 0) {
	  err = 'You must provide a start time';
	} else if (duration.length == 0) {
	  err = 'You must provide a reservation duration';
	}

	if ( err.length != 0 ) {
        alert(err);
	} else {
	//these will be active if we are changing the listener on the event, that is commented out for now
	//YAHOO.util.Event.removeListener('reservation', 'click', add_reserv);
	//YAHOO.util.Event.addListener('reservation', 'click', show_reserv_form);
	show_token_string(token_value);
	addReservation(res1, nodes1, start, duration, token_value, addReservationSuccess, failureHandler);
	}
}	


  function cancel_reserv() {
      var html = '<p><em class="orange">Cancelled making reservation.</em></p>';
      document.getElementById('announce_field').innerHTML= html;
  
	YAHOO.util.Event.removeListener('reservation', 'click', add_reserv);
        YAHOO.util.Event.addListener('reservation', 'click', show_reserv_form);
  }


    function cancel_user() {
      var html = '<p><em class="orange">Cancelled adding user.</em></p>';
      document.getElementById('announce_field').innerHTML= html;

      YAHOO.util.Event.removeListener('add_button', 'click', add_user);
      YAHOO.util.Event.addListener('add_button', 'click', show_user_form);
    }

    function check_token() {
      // Get the token and attempt to check the remaining time.
      token_value = document.getElementById("token_input").value;

      show_token_string(token_value);
      checkTokenTime(token_value, checkTokenTimeSuccess, failureHandler);
    }

    function get_token() {
      // Clear errors and announcements.
	
      // Get the token and attempt to get its information.
      token_value = document.getElementById("token_input").value;
      show_token_string(token_value);
      
      getTokenInfo(token_value, getTokenInfoSuccess, failureHandler);
    }

    function get_user() {
      email    = document.getElementById("email").value;
      identity = document.getElementById("identity").value;
      show_user_string(email, identity);

      getUserInfo(email, identity, getUserInfoSuccess, failureHandler);
    }

    function remove_user(id) {
      // Get the arguments and attempt to remove the user from the token.
      token_value = document.getElementById("token_input").value;
      identity = document.getElementById(id).value;
      
      removeUserFromToken(token_value, identity,
                          removeUserFromTokenSuccess, failureHandler);
    }
