function ajax() {
};
ajax.prototype.iniciar = function() {

	try{
		this.xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				this.xmlhttp = false;
			}
		}
	}
	return true;
}

ajax.prototype.ocupado = function() {
	estadoAtual = this.xmlhttp.readyState;
	return (estadoAtual && (estadoAtual < 4));
}

ajax.prototype.processa = function() {
	if (this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200) {
		return true;
	}
}

ajax.prototype.enviar = function(url, metodo, modo) {
	if (!this.xmlhttp) {
		this.iniciar();
	}
	if (!this.ocupado()) {
		if(metodo == "GET") {
			this.xmlhttp.open("GET", url, modo);
			this.xmlhttp.send(null);
		} else {
			this.xmlhttp.open("POST", url, modo);
			this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
			this.xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
			this.xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
			this.xmlhttp.setRequestHeader("Pragma", "no-cache");
			this.xmlhttp.send(url);
		}

		if (this.processa) {
			return unescape(this.xmlhttp.responseText.replace(/\+/g," "));
		}
	}
	return false;
}

function envia(url, metodo, modo){
	var login = document.getElementById('frmPromoter').login.value;
	remoto  = new ajax();
	xmlhttp = remoto.enviar(url + "?login=" + login, metodo, modo);

	if(xmlhttp) {
		document.getElementById('login').className = 'erro';
		document.getElementById('alerta').className = 'alerta2';
		document.getElementById('login').className = 'alerta3';
		document.getElementById("alerta").innerHTML = '<img src="/img/icone_deletar.gif" border="0" align="absmiddle" /> Esse nome de usuário já está cadastrado!';
		document.getElementById("Enviar").disabled = true;
	} else {
		document.getElementById('login').className = 'texto';
		document.getElementById("Enviar").disabled = false;
		document.getElementById('alerta').className = 'alerta4';
		document.getElementById("alerta").innerHTML = '<img src="/img/icone_conf_pag.gif" border="0" align="absmiddle" /> Nome de usuário ok!';
		document.getElementById("pagina").innerHTML = login;
	}
}


