﻿function HttpRequest(){
	var xmlHttp;
	var respXml;
	var respText;
	
	this.getRespXml=function(){
	    return respXml;
	}
	this.getRespText=function(){
	    return respText;
	}
	this.createXmlHttpRequest=function(){
	
		if(window.ActiveXObject){
		
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 }else if(window.XMLHttpRequest){
		 
			xmlHttp=new XMLHttpRequest();
		 }
	}
	
	this.startRequest=function(uri,method,sendMode,sendValue){
		
		var sm=sendMode;
		
		if(sm==null){
		
		     sm="GET";
			 sendValue=null;
		}

	    var index = uri.indexOf("?");
			if (index == -1) {
				uri += "?";
			} else {
				uri += "&";
			}
			uri += "time=" + new Date().getTime();
		this.createXmlHttpRequest();
		
		xmlHttp.onreadystatechange=readyStateChange;
		xmlHttp.open(sm,uri,true);
		xmlHttp.send(sendValue);
		function readyStateChange(){
			
			if(xmlHttp.readyState==4){
			    //if(xmlHttp.status == 200){
			        var xmlDoc=xmlHttp.responseXML;
				    var textDoc=xmlHttp.responseText;
    			
				    if(method!=null&&method!=""){
				        eval(method+"(textDoc)");
				    }
			    //}
			}
		}
			
	}
}
//var httpRequest=new HttpRequest(); 
