function tiraEspaco(texto){
	while(texto.indexOf(" ") != -1){
	  texto = texto.replace(" ","");
	}
    return texto;
}


function sonumeros(numero){
	//verifica o enter (13), o delete (46), o backspace (8), o end (35), o home (36) e as setas (37,38,39,40)
	if ((numero.keyCode >= 35 && numero.keyCode <= 40) || (numero.keyCode == 46) ||
		(numero.keyCode == 8) || (numero.keyCode == 13) || (numero.keyCode == 9) ||
		(numero.keyCode >= 48 && numero.keyCode <= 57) || (numero.keyCode >= 96 && numero.keyCode <= 105)){
		return true;
	}else{
		return false;
	}
}

function submeterContato(){
	if(tiraEspaco(document.getElementById('nome').value) == ""){
		alert("Informe o nome.");
		document.getElementById('nome').focus();
		return;
	}
	if(document.getElementById('email').value == ""){
		alert("Informe o e-mail.");
		document.getElementById('email').focus();
		return;
	}else{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email').value))){
			alert("Formato de email incorreto.");
	        document.getElementById('email').focus();
	   	    return;
	    }
	}
	
	if(tiraEspaco(document.getElementById('mensagem').value) == ""){
		alert("Qual a mensagem.");
		document.getElementById('mensagem').focus();
		return;
	}
	setarCamposContato();
	 enviaRequisicao('contato','fazerContato.php?'+campos,'Carregando...');
}
function setarCamposContato(){
	campos = "nome="+encodeURI(document.getElementById('nome').value);
	campos += "&email="+encodeURI(document.getElementById('email').value);
    campos +="&fone="+encodeURI(document.getElementById('fone').value);
	campos +="&mensagem="+encodeURI(document.getElementById('mensagem').value);
}

function submeterLogin(){
	if(document.getElementById("login").value == ""){
		document.getElementById("login").focus();
		alert("Informe o login");
		return;
	}
	if(document.getElementById("senha").value == ""){
		document.getElementById("senha").focus();
		alert("Informe a senha");
		return;
	}
	document.getElementById("formLogin").submit();
}

function deslogarCliente(){
    location.href='index.php?endS=true';

}
