/* ajax CLASS 
=================================
url - target url
callback - function that is triggered for each ready state 
exinfo   - not mandatory
*/
function AJAXInteraction(url, callback,exinfo)
{   var extrainfo=exinfo;
    var req = init();     
    this.processind_status=0;   
    req.onreadystatechange = processRequest;
    function init() 
    {
       	var xmlhttp;
    	 if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
    	 {
      		try {
     				 xmlhttp = new XMLHttpRequest();
				 if (xmlhttp.overrideMimeType){
	  				 xmlhttp.overrideMimeType("text/xml"); 
				 }
    			} catch (e) {xmlhttp = false;}
  		}
  		else
  		{
  				try 
  				{
      				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    			} 
    			catch (e) 
    			{
      					try 
      					{
        				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      					} catch (E) {xmlhttp = false;}
  				}
		}
		return xmlhttp;
    }

  function processRequest () 
  {        	
    try
     { 
      if (req.readyState == 4) 
      {
         var responseValues=new Array();
      
         if (req.status == 200) 
         {           
          		responseValues['xml']=req.responseXML;
          		responseValues['txt']=req.responseText;
          		responseValues['status']=req.status;
          		responseValues['txtStatus']=req.statusText;
          		responseValues['extra']=extrainfo;
          		
         	

          if (callback) callback(responseValues); //req.responseXML,exinfo,req.responseText
         }        
       }
      
      }	catch(e){}
    }

    this.doGet = function() {
      req.open("GET", url, true);
      req.send(null);
  							};

    this.doPost = function(body) {
      req.open("POST", url, true);
      req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      req.setRequestHeader("Content-length", body.length);
      req.send(body);
    	};

}

function AJAXJsonInteraction(url, callback) { 
    var req = init();     
    this.processind_status=0;   
    req.onreadystatechange = processRequest;
    function init() {
       	var xmlhttp;
    	 if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
      		try {
			xmlhttp = new XMLHttpRequest();
			if (xmlhttp.overrideMimeType){
			  xmlhttp.overrideMimeType("text/plain"); 
			}
		} catch (e) {xmlhttp = false;}
	 } else {
		 try {
			 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
			 try {
				 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			 } catch (E) {xmlhttp = false;}
		 }
	 }
	 return xmlhttp;
    }

    function processRequest () {        	
	    try { 
		    if (req.readyState == 4) {
			    if (req.status == 200) {           
				    if (callback) {
					    var data = eval('('+req.responseText + ')');
					    callback(data); 
				    }
			    }        
		    }
	    }	catch(e){}
    }

    this.doGet = function() {
      req.open("GET", url, true);
      req.send(null);
    };

    this.doPost = function(body) {
	    req.open("POST", url, true);
	    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    req.setRequestHeader("Content-length", body.length);
	    req.send(body);
    };

}


/* ajax CLASS end*/
/****************  AJAX initalisation   ************************/
function getHTTPObject(){
  var xmlhttp;
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
      if (xmlhttp.overrideMimeType){
	  xmlhttp.overrideMimeType("text/xml"); 
      }
    } catch (e) {
      xmlhttp = false;
    }
  }
  else
  {
  	try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
  }
}
return xmlhttp;
}

