/****************************************************************
 *  Ajax callback to retrieve vehicle ID
 */
 function ajcSelectVehicle(selectedVehicle)
 {
// parameter values to send on http.send()
   var params = "vehicle=" + selectedVehicle;

// file to call for server processing
   var action   = "newMaintenanceForm.php";

   http.open("POST", action, true);

// Send the proper header information along with the request
   http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   http.setRequestHeader("Content-length", params.length);
   http.setRequestHeader("Connection", "close");

   http.onreadystatechange = function () {ajrSelectVehicle()};
   http.send(params);
 } /* end function */

/****************************************************************
 *  Ajax response function
 */
 function ajrSelectVehicle()
 {
   if(http.readyState == 4) {
     if(http.status == 200) {

     // set selectedVehicle DIV with data input form for selected vehicle
        document.getElementById("selectedVehicle").innerHTML = http.responseText;

     } else {
       alert("Error: " + http.statusText);
     }
   }
 } /* end function */

/****************************************************************
 *  Ajax callback to retrieve vehicle ID
 */
 function ajcSelectComponent(selectedComponent)
 {
// parameter values to send on http.send()
   var params = "component=" + selectedComponent;

// file to call for server processing
   var action   = "selectComponent.php";

   http.open("POST", action, true);

// Send the proper header information along with the request
   http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   http.setRequestHeader("Content-length", params.length);
   http.setRequestHeader("Connection", "close");

   http.onreadystatechange = function () {ajrReloadPage()};
   http.send(params);
 } /* end function */

/****************************************************************
 *  Ajax response function
 */
 function ajrReloadPage()
 {
   if(http.readyState == 4) {
     if(http.status == 200) {

     // reload the current page
        window.location.href=window.location.href;

     } else {
       alert("Error: " + http.statusText);
     }
   }
 } /* end function */

/****************************************************************
 *  Ajax callback function that collects info from calling page
 */
 function callAjax(name)
 {
/*** start collecting and pre-processing page info ***/

   var sTime = document.Time.Start.value;
   var nameprefix = name;

/*** end page info ***/

// file to call for server processing
   var action   = "callAjax.php";

// parameter values to send on http.send()
   var params = "begin=" + nameprefix + "&name=Sheedy";

   http.open("POST", action, true);

// Send the proper header information along with the request
   http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   http.setRequestHeader("Content-length", params.length);
   http.setRequestHeader("Connection", "close");

   http.onreadystatechange = function () {setAjaxResponse("JS parameters")};
   http.send(params);
 } /* end function */


/****************************************************************
 *  Ajax response function
 */
 function setAjaxResponse(parameters)
 {
   if(http.readyState == 4) {
     if(http.status == 200) {
       alert("Server Response: " + parameters + " " + http.responseText);
     } else {
       alert("Error: " + http.statusText);
     }
   }
 } /* end function */


/****************************************************************
 *  create a new Ajax Request object
 */
 function newAjaxRequest()
 {
   var request = false;
   if(window.XMLHttpRequest) {
     http = new XMLHttpRequest();
   } else if (window.ActiveXObject) {
     http = new ActiveXObject("Msxml2.XMLHTTP");
     if(!http) {
       http = new ActiveXObject("Microsoft.XMLHTTP");
     }
   }
 } /* end function */



