function Ajax(){
	this.assincr = false;
	this.method = "GET";
	this.val = "";
	this.xmlhttp = null;
	
	try{
		this.xmlhttp =  new ActiveXObject("Microsoft.XMLHTTP");
	}catch(e){
		try{
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(ex){
			try{
				this.xmlhttp = new XMLHttpRequest();
			}catch(exc){
				alert("Esse browser não tem recursos para uso do Ajax");
				this.xmlhttp = null;
			}
		}
	}
	
	this.urlRand = function(uri){
		var dt = new Date();
		if(uri.indexOf("?")>=0){
			return uri+"&"+encodeURI(Math.random()+"_"+dt.getTime());
		}else{
			return uri+"?"+encodeURI(Math.random()+"_"+dt.getTime());
		}
	}

	//carrega o conteudo de uma ajax em uma var
	this.loadResult = function(url){
		if(this.xmlhttp) {
			this.xmlhttp.open(this.method, this.urlRand(url) , this.assincr);
			//headers, vulnerável
			this.xmlhttp.setRequestHeader("Cache-Control", "no-cache");
        	this.xmlhttp.setRequestHeader("Pragma", "no-cache");
			//
			if(this.method == 'GET'){
				this.xmlhttp.send(null);
			}else if(this.method == 'POST'){
				this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
				try{
					this.xmlhttp.send(url.split("?")[1]);
				}catch(e){}
			}
			//
			if(this.assincr){
				this.xmlhttp.onreadystatechange = function(){
					if(ajax.xmlhttp.readyState == 4){
						if(ajax.xmlhttp.status == 200){
							ajax.val = ajax.xmlhttp.responseText;
						}else{
							alert(ajax.xmlhttp.statusText);
						}
					}
				}
			}else{
				ajax.val = ajax.xmlhttp.responseText;
			}
		}
		return this.val;
	}
	
	this.loadContent = function(url, div_name){
		if(this.xmlhttp) {
			this.xmlhttp.open(this.method, this.urlRand(url) , this.assincr);
			//headers, vulnerável
			this.xmlhttp.setRequestHeader("Cache-Control", "no-cache");
        	this.xmlhttp.setRequestHeader("Pragma", "no-cache");
			//
			if(this.method == 'GET'){
				this.xmlhttp.send(null);
			}else if(this.method == 'POST'){
				this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
				try{
					this.xmlhttp.send(url.split("?")[1]);
				}catch(e){}
			}
			//
			if(this.assincr){
				this.xmlhttp.onreadystatechange = function(){
					if(ajax.xmlhttp.readyState == 4){
						if(ajax.xmlhttp.status == 200){
							ajax.val = ajax.xmlhttp.responseText;
						}else{
							alert(ajax.xmlhttp.statusText);
						}
					}
				}
			}else{
				ajax.val = ajax.xmlhttp.responseText;
			}
			
			try{
				$(div_name).innerHTML = ajax.val;
			}catch(e){}
		}
	}
	
}

var ajax = new Ajax();
ajax.assincr = false;
ajax.method = "GET";