/*
*  License Information:
*  -------------------------------------------------------
*  Author: Jay Hargis (2005)
*
*  This program is free software; you can redistribute it and/or modify it under
*  the terms of the GNU General Public License as published by the Free Software
*  Foundation; either version 2 of the License, or (at your option) any later
*  version.
*
*  This program is distributed in the hope that it will be useful, but WITHOUT
*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
*  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License along with
*  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
*  Place, Suite 330, Boston, MA 02111-1307 USA
*/
  // Build a param string and issue callback -----------------------------------------------------+>
  function prepareCallback(param) {
    // Use date/time to create unique url calls to avoid caches across page loads
    d = new Date(); now = d.getTime();
    performCallback('_components/results/ajax_server.php?catid=' + param + '&r=' + now);
  }
  // What to do when a callback is in progress and another callback is issued --------------------+>
  function callbackBusyAction() {
    alert("Loading...Just a moment");
  }
  // What to do if callback times out ------------------------------------------------------------+>
  function timeoutAction () {
    //alert('A request was timed out. Taking too long');
    document.cats.catid.disabled = false;
    document.cats.subcatid.disabled = true;
    document.cats.submit();
  }
  // Perform any operations just prior to callback is issued -------------------------------------+>
  function performOnCallback() {
    document.cats.subcatid.length = 0;
    document.cats.subcatid.disabled = false;
    var loadtxt = "Loading...Please Wait";
    var myNewOption = new Option(loadtxt, "0");
    document.cats.subcatid.options[0] = myNewOption;
    document.cats.catid.disabled = true;
  }
  // Perform any operations just prior to deserialization ----------------------------------------+>
  function peformOnDeserialize() {
    document.cats.subcatid.disabled = true;
  }
  // Handle the returned data in global array (arr) ----------------------------------------------+>
  function parseReturnData() {
    document.cats.subcatid.length = 0;
    var x = 0;
    for (var key in arr) {
      var subname = arr[key];
      var myNewOption = new Option(subname, key);
      document.cats.subcatid.options[x] = myNewOption;
      x++;
    }
    document.cats.catid.disabled = false;
    document.cats.subcatid.disabled = false;
    if (document.cats.catid.options[0].value == '') { document.cats.catid.options[0] = null; }
  }
