function Ajax(url, variables, method, returnType) {
	
	this.ajax;
	var returningContent;
	var that = this;
	var onFinish;
	
	//function construct(){
		this.sourceAndDestination = url;		
		this.sendingMethod = method.toLowerCase();		
		
		if(variables == undefined) {
			queryString = null;
		} else {
			this.queryString = variables;
		}
		
		if(returnType == undefined) {
			this.returnType = 'text';
		} else {
			this.returnType = returnType;
		}
		
	//}
	
	this.create = function() {
		if (navegador == "Microsoft Internet Explorer") {
        	objetoHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
        	objetoHttp = new XMLHttpRequest();
		}
		return objetoHttp;		
	}
	
	this.requisition = function(async) {
		if(async == undefined) {
			async = true;	
		}
		
		if(this.sendingMethod == 'get' && this.queryString != null) {
			this.sourceAndDestination += '?' + this.queryString;
		}
		this.ajax = this.create();
		this.ajax.open(this.sendingMethod, this.sourceAndDestination, async);
		
		if(this.sendingMethod == 'post') {
			this.ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		}
		
		this.ajax.send(this.queryString);
		
		this.ajax.onreadystatechange = function() {
			if(that.ajax.readyState == 4) {				
				if(that.ajax.status == 200) {
					switch(that.returnType) {
						case 'text':
							that.returningContent = that.ajax.responseText;
						break;
						case 'xml':
							that.returningContent = that.ajax.responseXML;
						break;						
					}
					
					that.onFinish();
				} else {
					alert("Problema com a requisição");
				}
			}
		}		
	}
	this.getResponseHeader = function(cabecalho) {
		if(cabecalho == undefined) {
			return this.ajax.getAllResponseHeaders();
		} else {
			return this.ajax.getResponseHeader(cabecalho);
		}
	}
}
