var caminho_a="";
var erro_pass2="";


function carrega(caminho,txt_erro_pass2){
	caminho_a=caminho;
	erro_pass2=txt_erro_pass2;
}

function forgot_password(){
	mail=document.getElementById("email").value;
	
	resultado=isEmail(mail);
	if (resultado==true) {
			a_enviar=caminho_a+"ajax_forgot_password.php?email="+mail;
			$.post(a_enviar,"",function(retorno){$("#forgot_password_box").html(retorno)});
	}else {
		document.getElementById("erro").innerHTML=erro_pass2;
	}
}

function isEmail(text){
   var 	arroba = "@",
		ponto = ".",
		posponto = 0,
		posarroba = 0;
	
	 if (text =="") return false;
	
	 for (var indice = 0; indice < text.length; indice++){
		if (text.charAt(indice) == arroba) {
			posarroba = indice;
			break;
		 }
	 }
	
	for (var indice = posarroba; indice < text.length; indice++){
		if (text.charAt(indice) == ponto) {
			posponto = indice;
			break;
		}
	}
	if (posponto == 0 || posarroba == 0) return false;
	if (posponto == (posarroba + 1)) return false;
	if ((posponto + 1) == text.length) return false;
	return true;
}

