function Majax(){
	function Construct(){
		this.XMLhttp = null;
		this.url="";	
		this.tipo="";
		this.parameters="";
		this.funcao="";
		this.debug="0";
	}
	var ctr = new Construct(); // Cria uma instancia para o metodo de acesso as variaveis
	this.createObject = function(){
					var ocx=["MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP.2.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
					for(cont=0;cont<ocx.length;cont++){ /* alert(objeto[cont]); */
						try{    ctr.XMLhttp=new ActiveXObject(ocx[cont]); break;
						}catch(exception1){
							if(cont==(ocx.length-1)){/* alert("XMLHttpRequest()"); */
								try{ ctr.XMLhttp = new XMLHttpRequest(); }catch(exception2){alert("Seu navegador não suporta o uso de Ajax");}
							}	
						}
					}
	}
	this.createObject(); //cria o objeto XMLhttp
	this.verifyMethod = function(){ 
					if(ctr.url.indexOf("?")!=-1){
					  	 	parameters = ctr.url.split("?");
					  	 	ctr.parameters = parameters[1];
							ctr.url = parameters[0];
							if(ctr.tipo=="debug"){
								alert(ctr.url + "?" + ctr.parameters)
								window.location = (ctr.url + "?" + ctr.parameters)	;
								return
							}
							//ctr.XMLhttp.open("get",ctr.url,true);
							ctr.XMLhttp.open("post",ctr.url,true);
							ctr.XMLhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
							ctr.XMLhttp.setRequestHeader("Cache-Control","no-store, no-cache, must-revalidate");
							ctr.XMLhttp.setRequestHeader("Cache-Control","post-check=0, pre-check=0");
							ctr.XMLhttp.setRequestHeader("Pragma", "no-cache");

							ctr.XMLhttp.onreadystatechange = function(){
										if(ctr.XMLhttp.readyState==1){}
										if(ctr.XMLhttp.readyState==4){
											if(ctr.XMLhttp.status==200){	
												if(ctr.tipo=="txt"){	
												response = ctr.XMLhttp.responseText;
													if(ctr.debug=="1"){
														alert("debug: "+response);	
													}
												ctr.funcao(response);													
												}else if(ctr.tipo=="xml"){
													response = ctr.XMLhttp.responseXML;
													ctr.funcao(response);
												}
											}else if(ctr.XMLhttp.status==404){
												alert("404 - Página nao encontrada: "+ ctr.url);
											}else if(ctr.XMLhttp.status==405){
												alert("405 - Servidor não suporta esse método");
											}else if(ctr.XMLhttp.status==500){
												alert("500 - Erro interno do servidor");
											}else{
												alert("Error: "+ctr.XMLhttp.status);
											}
										}
									}
							ctr.XMLhttp.send(ctr.parameters);								
						}else{
							alert("Método passado errado na url (ayz.htm?xxx=yyy)");
						}
	}
	this.responseText = function(url,funcao){
		ctr.funcao = funcao; // Funcao que vai ser executada depois do response
		ctr.tipo = "txt"; 
		ctr.url = url;
		alert("OO");
		this.verifyMethod();
	}
	this.responseXML = function(url,funcao, debug){
		ctr.funcao = funcao;
		ctr.debug = debug;
		if(debug=="1"){
			ctr.tipo = "txt";
		}else if(debug=="2"){
			ctr.tipo = "debug";
		}else{
			ctr.tipo = "xml";
		}
		ctr.url = url;
		this.verifyMethod();
	}
}

// Utilizacao
// var x = new Ajax();
// x.responseXML("url.asp?a=1",funcao de retorno); OU
// x.responseText("url.asp?a=1",funcao de retorno);
// funcao de retorno(xml){
//		var xmlDc = xml.getElementsByTagName();
// etc...
//}









