// JavaScript Document

function gE(ID){
	return document.getElementById(ID);	
}

function trocaFoto(img){
	var fotoG = gE("fotoG")
	var aux = img.src;
	var caminho = "";
	
	var teste = img.src.split('/');
	var total = teste.length;	
	for (var i = 0; i < (total-1); i++){
		caminho += teste[i] + "/";
	}	
	var teste2 = teste[total-1].split("_p");	
	var fP = teste[total-1];
	var fG = teste2[0] + teste2[1];
	
	// -----------------------------------------
	
	var gg = fotoG.src.split('/');
	var total = gg.length;
	var gg2 = gg[total-1].split('.');	
	
	fotoG.src = caminho + fG;
	img.src = caminho + gg2[0]+'_p.'+gg2[1];	
}

/* validações */

	// Função que valida o e-mail informado
	function validaEmail(email){
		return email.search(/(\w[\w\.\+]+)@(.+)\.(\w+)$/)==0;
	}
	
	// função para validar o formulario de trabalhe conosco
	function ValidaForm(){
		var nome = gE('infNome');
		var email = gE('infEmail');
		
		if (nome.value == '' || nome.value == null){
			alert("Campo Nome em branco.");
			nome.focus();
			return false;
		}
		
		if (email.value == '' || email.value == null){
			alert("Campo E-mail em branco.");
			email.focus();
			return false;
		}
		
		var verificaEmail = validaEmail(email.value);
		
		if (verificaEmail == false){
			alert("E-mail inválido");		
			email.focus();
			return false;
		}
		
		return true;
	}
	
	// função para validar o formulário de atendimento
	function validaFrmAtentimento(){
		var nome = gE('ip_nome');
		var tel = gE('ip_fone');
		var email = gE('ip_email');
		
		if (nome.value == '' || nome.value == null){
			alert("Campo Nome em branco.");
			nome.focus();
			return false;
		}
		
		if (tel.value == '' || tel.value == null){
			alert("Campo Fone/Fax em branco.");
			tel.focus();
			return false;
		}
		
		if (email.value == '' || email.value == null){
			alert("Campo E-mailem branco.");
			email.focus();
			return false;
		}
		
		var verificaEmail = validaEmail(email.value);
		
		if (verificaEmail == false){
			alert("E-mail inválido");		
			email.focus();
			return false;
		}
		
		return true;
	}
	
// fim da função da validação do formulario de trabalhe conosco
