/** XHForms - Submits forms via XMLHTTP. - brad@xkr.us - v0.2 - 2004-10-20   **
    Code licensed under Creative Commons Attribution-ShareAlike License
 ** http://creativecommons.org/licenses/by-sa/2.0/                           **/

/* This is where you put the code to run after the form has been submitted. */
function fnAfterSubmit(oResponse)
{
  clearTimeout(tError); // successful, so stop timeout error

  /*...*/
  var responseText = oResponse.responseText;
  var command = 'hideView';
  //if we receive a command to hide the 'xh-container' div then do so
  if (command == responseText.substring(0, command.length)){
  	hideview('xh-container');
  	responseText = responseText.substring(command.length, responseText.length);
  }
  document.getElementById("out").innerHTML = responseText;
}

/* (Optional) Put code here that will execute before the submission */
function fnBeforeSubmit() {
  document.getElementById("out").innerHTML = "<img src='/time1.gif'>";
}

/* Put error-handling code here (if the connection times out). */
function fnOnError(oForm)
{
  if (confirm("An timeout occured. Retry?"))
  {
    oForm.onsubmit = null; // remove the XHForm handler
    oForm.submit(); // submit the form normally
  }
}

/* include necessary library functions (do not edit) */
include("/FormCollect.js");
include("/XHConn.js");
include("/XHForms-core.js");
include("/script.js");

