// JavaScript Document

function disp(m){
	if(m){
		document.getElementById('codigo').style.display='block';
	}else{
		document.getElementById('codigo').style.display='none';
	}
}
function enviar_ok(f){
	var cor = "FFFFFF";
	f.Primeira_vez[0].style.background = cor;
	f.Primeira_vez[1].style.background = cor;
	f.Leitor[0].style.background = cor;
	f.Leitor[1].style.background = cor;
	f.Assina[0].style.background = cor;
	f.Assina[1].style.background = cor;
	f.codigo.style.background = cor;
	f.Procurando.style.background = cor;
	f.Nome.style.background = cor;
	f.Idade.style.background = cor;
	f.Profissao.style.background = cor;
	f.Mail.style.background = cor;
	f.Cidade.style.background = cor;
	f.Fone.style.background = cor;
	cor = "F36F1F";
	if(!f.Primeira_vez[0].checked && !f.Primeira_vez[1].checked){
		alert("Selecione os campos",null);
		f.Primeira_vez[0].style.background = cor;
		f.Primeira_vez[1].style.background = cor;
		f.Primeira_vez[0].focus();
		return false;
	}
	if(!f.Leitor[0].checked && !f.Leitor[1].checked){
		alert("Selecione os campos");
		f.Leitor[0].style.background = cor;
		f.Leitor[1].style.background = cor;
		f.Leitor[0].focus();
		return false;
	}
	if(!f.Assina[0].checked && !f.Assina[1].checked){
		alert("Selecione os campos");
		f.Assina[0].style.background = cor;
		f.Assina[1].style.background = cor;
		f.Assina[0].focus();
		return false;
	}
	if(f.Assina[0].checked){
		if(f.codigo.value == ""){
			alert("Digite seu Código!");
			f.codigo.style.background = cor;
			f.codigo.focus();
			return false;
		}
	}
	if(f.Procurando.value == ""){
		alert("Digite sua mensagem!");
		f.Procurando.style.background = cor;
		f.Procurando.focus();
		return false;
	}
	if(f.Nome.value == ""){
		alert("Digite seu nome!");
		f.Nome.style.background = cor;
		f.Nome.focus();
		return false;
	}
	if(f.Idade.value == ""){
		alert("Digite a sua idade!");
		f.Idade.style.background = cor;
		f.Idade.focus();
		return false;
	}
	if(f.Profissao.value == ""){
		alert("Digite a sua profissão!");
		f.Profissao.style.background = cor;
		f.Profissao.focus();
		return false;
	}


	//E-MAIL-----------------------------------------------
	if(f.Mail.value == ""){
		alert("Digite seu E-mail!");
		f.Mail.style.background = cor;
		f.Mail.focus();
		return false;
	}
	p1 = f.Mail.value.indexOf("@");
	p2 = f.Mail.value.indexOf(".");
	p3 = f.Mail.value.length;
	if(!(p1 >= 3 && p2 >= 6 && p3 >= 9)){
		alert("O campo E-mail deve conter um endereço válido!");
		f.Mail.focus();
		return false;
	}
	//E-MAIL-----------------------------------------------

	if(f.Cidade.value == "" || f.UF.value == ""){
		alert("Digite sua Cidade e Estado!");
		Cidade.style.background = cor;
		if(f.Cidade.value == ""){
			f.Cidade.focus();
		}else{
			f.UF.focus();
		}
		return false;
	}

	f.Email.value = f.Mail.value;

	return true;
}

function mascara(o,f){
	v_obj=o;
	v_fun=f;
	setTimeout("execmascara()",1);
}
function execmascara(){
	v_obj.value=v_fun(v_obj.value);
}
function telefone(v){
	v=v.replace(/\D/g,"");
	v=v.replace(/^(\d\d)(\d)/g,"($1) $2");
	v=v.replace(/(\d{4})(\d)/,"$1-$2");
	return v;
}