// JavaScript Document

// Send AHAH request (GET)
function callahah(url, pageElement, loadingmsg,whichaction) {
     if (loadingmsg!='') document.getElementById(pageElement).innerHTML = loadingmsg;
     try {
     req = new XMLHttpRequest(); 
     /* e.g. Firefox */
     } catch(e) {
       try {
       req = new ActiveXObject("Msxml2.XMLHTTP");  
       /* some versions IE */
       } catch (e) {
         try {
         req = new ActiveXObject("Microsoft.XMLHTTP");  
         /* some versions IE */
         } catch (E) {
          req = false;
         } 
       } 
     }
	 //* Create Anti_cachingNumber *//
	 url = url + "&" + Math.floor(Math.random()*99999999);
     req.onreadystatechange = function() {responseahah(pageElement,whichaction);};
     req.open("GET",url,true);
     req.send(null);
  }
  
  
 // SEND AHAH REQUEST POST
function postahah(url,parameters, pageElement, loadingmsg,whichaction) {
     if (loadingmsg!='') document.getElementById(pageElement).innerHTML = loadingmsg;
     try {
     req = new XMLHttpRequest(); 
     /* e.g. Firefox */
     } catch(e) {
       try {
       req = new ActiveXObject("Msxml2.XMLHTTP");  
       /* some versions IE */
       } catch (e) {
         try {
         req = new ActiveXObject("Microsoft.XMLHTTP");  
         /* some versions IE */
         } catch (E) {
          req = false;
         } 
       } 
     }
	 //* Create Anti_cachingNumber *//
	 url = url + "?" + Math.floor(Math.random()*99999999);
     req.onreadystatechange   = function() {responseahah(pageElement,whichaction);};
	 req.open('POST', url, true);
	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	req.setRequestHeader("Content-length", parameters.length);
	req.setRequestHeader("Connection", "close");
	req.send(parameters);	
  }


// EVAL AHAH RESPONSE
function responseahah(pageElement,whichaction) {
	
   if(req.readyState == 4) {
      if(req.status == 200) {
       output = req.responseText;
	   	// if (whichaction=='exec') // Do Nothing
	   	if (whichaction=='alert') alert(output);
		if (whichaction=='eval') eval (output);
		if (whichaction=='set') document.getElementById(pageElement).innerHTML = output;
		if (whichaction=='add') document.getElementById(pageElement).innerHTML = document.getElementById(pageElement).innerHTML + output;
         } 
      }
  }
  

