var caminho_a="";

function carrega(caminho){
	caminho_a=caminho;
}

function vaiver(){
	mail=document.getElementById("mails").value;
	resultado=isEmail(mail);
	if (resultado==true) {
		nome_envia=document.getElementById("nome").value;
		a_enviar=caminho_a+"ajax_newsletter.php?tarefa=guarda&email="+mail+"&nome="+nome_envia;
		$.post(a_enviar,"",function(retorno){$("#newletter_box").html(retorno)});
	} 
}

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;
}


function clearText(thefield) {
	if (thefield.defaultValue == thefield.value) 
	thefield.value = "" 
	else thefield.value = thefield.defaultValue 
}