function Ajax () {
   var t=this 
   t.URL=""
   t.method="GET"
   t.POSTData=null
   t.successCB=null
   t.errCB=null
   t.headers=new Array()
   t.async=true
   
   t._xhr=null
}

//------------------------------------------------------------------------------------
function AjaxSend()
{
   var t=this
   t._xhr=_getXHR()
   
   t._xhr.open(t.method, t.URL, t.async);
   for (var i=0; i<t.headers.length; i++)
    { 
      t._xhr.setRequestHeader( t.headers[i].name, t.headers[i].value );
    }
   t._xhr.send(t.POSTData);
   t._xhr.onreadystatechange = function()
    {
      if (t._xhr.readyState == 4) 
        {
          if (t._xhr.status >= 200 && t._xhr.status < 300) 
            {
              if (t.successCB) 
                {
                  t.successCB(t._xhr);
                }
            }
          else 
            {
              if (t.errCB)
                {
                  t.errCB(t._xhr);
                }
            }
         t._xhr=null
      }
   }
}


//------------------------------------------------------------------------------------
function _getXHR(){
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   try { return new XMLHttpRequest(); } catch(e) {}
   alert ("XMLHttpRequest not supported")
   return null
}


//============================================================================
// Prototype setup
//============================================================================
Ajax.prototype=new Ajax()

p=Ajax.prototype
p.constructor=Ajax

//--- Public Interface ----------
p.setURL=function(url){this.URL=url}
p.setMethod=function(method){this.method=method}
p.setPOSTData=function(data){this.POSTData=data}
p.setSuccessCallback=function(cb){this.successCB=cb}
p.setErrorCallback=function(cb){this.errCB=cb}
p.setReqHeader=function(name,value){var o = new Object(); o.name=name; o.value=value; this.headers.push(o)}
p.setAsync=function(bAsync){this.async=bAsync}
p.send=AjaxSend
// Renders the style run to the specified buffer
	
p.getXHRObj=_getXHR			
p=null


			

