﻿
// JScript File
var req;
function ajaxRequest(p_submitMethod,p_parameters,p_url,p_targetDiv) {
    document.getElementById(p_targetDiv).innerHTML = 'loading data...';
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {ajaxResponse(p_targetDiv);};
      
      if(p_submitMethod=="POST") {
       req.open("POST", p_url, true);
       req.send(p_parameters);
      }
      else {
        req.open("GET", p_url, true);
        req.send(null);
        }
        
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {ajaxResponse(p_targetDiv);};
            
       if(p_submitMethod=="POST") {
       req.open("POST", p_url, true);
       req.send(p_parameters);
      }
      else {
          req.open("GET", p_url, true);
          req.send();
        }
        
          
        }
    }
} 


function ajaxResponse(p_targetDiv) {
   // only if req is "loaded"
   if (req.readyState == 4) {
       // only if "OK"
       if (req.status == 200 || req.status == 304) {
           results = req.responseText;
           //alert(results);
           document.getElementById(p_targetDiv).innerHTML = results;
           
       } else {
           document.getElementById(p_targetDiv).innerHTML="Please Try Again:\n" +
               req.statusText;
       }
   }
}


// Creates a timestamp for querystring.
	function createTimestamp()
	{
	    return "timestamp=" + new Date().getTime().toString();
	}
	
	



