var ajax=new JQuery();



function JQuery()
{
	var xmlHttp=InitXmlHttpRequest();
	
	var broser=getBroser();
	
	var callbackfunc;
	
	this.Load=function(method,url,callback,loading)
	{
	   callbackfunc=callback;
	   if(!xmlHttp){  
	      alert("创建对象出错！");
	   }else{	     	     
	      if(url.indexOf('?')=='-1'){
	          url=url+"?time="+Date();
	      }else{
	          url=url+"&time="+Date();
	      }	   
		  xmlHttp.open(method,url,false);	
		  if(broser=="Firefox"){
		     xmlHttp.onreadystatechange=LoadStatusChange();		  
		  }else{	
		     xmlHttp.onreadystatechange=LoadStatusChange;             
         }
         if(broser=="Firefox"){
            xmlHttp.send(true);  
            xmlHttp.onreadystatechange=QueryStatusChange();    
         }
         else
         {
            xmlHttp.send();  
         }  
	   }
	};	
	
	this.Query=function(method,url,callback)
	{	
	   callbackfunc=callback;
	   if(!xmlHttp){  
	      alert("创建XmlHttpRequest对象出错！");
	   }else{
	      if(url.indexOf('?')=='-1'){
	          url=url+"?time="+Date();
	      }else{
	          url=url+"&time="+Date();
	      }	   	 	          
		  xmlHttp.open(method,url,false);	
		 
		  if(broser=="Firefox"){
		     xmlHttp.onreadystatechange=QueryStatusChange();		  
		  }else{			  
		     xmlHttp.onreadystatechange=QueryStatusChange;        	 
          }     
          if(broser=="Firefox"){
            xmlHttp.send(true);  
            xmlHttp.onreadystatechange=QueryStatusChange();    
         }
         else
         {
            xmlHttp.send();  
         }
                               	
	   }
	};	
	
	
    function QueryStatusChange()
    {	
       if(xmlHttp.readyState==4)
       {             
            if(xmlHttp.status==200)
            {    
                 callbackfunc(xmlHttp.responseText);  
            }     
       } 
	}	
	
	function LoadStatusChange()
    {	
	   if(xmlHttp.readyState==4)
       {             
            var obj= document.getElementById(loading);
            if(obj)
                obj.style.display="";    
            if(xmlHttp.status==200)
            {    
               callback(xmlHttp.responseText);                
               if(obj)
                 obj.style.display="none";                                             
            }  
       } 
	}		
	
	function InitXmlHttpRequest()
	{
	    //非IE浏览器创建XmlHttpRequest对象
	    var xmlHttp=null;
	    
	    try{	    
	       xmlHttp=new XMLHttpRequest();	    
	    }catch(ex){
	   
	        var xmlHttpStr=['Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];       
            for (var i = 0; i < xmlHttpStr.length; i++) {   
                try {   
                    xmlHttp=new ActiveXObject(xmlHttpStr[i]);   
                    break;
                } catch (e) {   
                    // ignore   
                }   
            }            
	   }	    
	  
       return xmlHttp;
	}
	
	
	function getBroser()   
    {   
        var OsObject = "";   
        if(navigator.userAgent.indexOf("MSIE")>0){   
             return "MSIE";       //
        }else if(navigator.userAgent.indexOf("Firefox")>0){   
             return "Firefox";     //Firefox
        }else if(navigator.userAgent.indexOf("Safari")>0){   
             return "Safari";      //Safan
        }else if(navigator.userAgent.indexOf("Camino")>0){   
             return "Camino";   //Camino
        }else if(navigator.userAgent.indexOf("Gecko")>0){   
             return "Gecko";    //Gecko
        }   
    } 
		
}

