function mudaImagem(){
	args = arguments;
	document.getElementById("recebeAvatar").innerHTML = "<img src='caretas/img"+args[0]+".gif' alt='Seu Avatar' id='avatar' />";
	document.getElementById("hImgAvatar").value = "img"+args[0];
}
function abrirNovaJanela(url){
	window.open(url);
}
function validaTorpedo() 
{
	if (document.getElementById("de").value == "")
	{
		alert("É necessário o preenchimento do seu nome!");
		document.getElementById("de").focus();
		return false;
	}
	if (document.getElementById("para").value == "")
	{
		alert("É necessário o preenchimento do nome da pessoa que receberá o Torpedo!");
		document.getElementById("para").focus();
		return false;
	}
	if (document.getElementById("mensagem").value == "")
	{
		alert("É necessário o preenchimento da Mensagem!");
		document.getElementById("mensagem").focus();
		return false;
	}
	if (document.getElementById("email")!="")
	{
		qtdArroba = document.getElementById("email").value.split('@');
		if (document.getElementById("email").value.search("@") == -1 || document.getElementById("email").value.search("[.]") == -1 || document.getElementById("email").value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == ".")
		{
			alert("O preenchimento do E-MAIL está incorreto!");
			document.getElementById("email").focus();
			return false;
		}
	} else {
		alert("É necessário o preenchimento do seu E-MAIL!");
		document.getElementeById("email").focus();
		return false;
	}
	for (i=1; i<=20; i++){
		if(document.getElementById("ico"+i).checked){
			document.getElementById("hImagem").value = document.getElementById("ico"+i).value
			break;
		}
	}
	document.getElementById("formTorpedo").submit();
	return true;
}
function limpaFormPerguntaPsicologa(){
	document.getElementById("txtNome").value="";
	document.getElementById("txtEmail").value="";
	document.getElementById("txtDuvida").value="";
	document.getElementById("txtNome").focus();
}
function abreResultado(idEnquete){
	window.location.replace("emquete.asp?idEnquete="+idEnquete);
}
function validaCadastroSite(){
	if(document.getElementById("txtTitulo").value==""){
		alert("O campo Título do Anúncio precisa ser preenchido");
		document.getElementById("txtTitulo").focus();
		return false;
	}
	if (document.getElementById("txtTitulo").value.length < 5){
		alert("O campo Título do Anúncio precisa ter 5 caracteres no mínimo.");
		document.getElementById("txtTítulo").focus();
		return false;
	}
	if (document.getElementById("txtTitulo").value.length > 40){
		alert("O campo Título do Anúncio precisa ter 40 caracteres no máximo.");
		document.getElementById("txtTítulo").focus();
		return false;
	}
	if(document.getElementById("txtEndereco").value==""){
		alert("O campo Endereço precisa ser preenchido.");
		document.getElementById("txtEndereco").focus();
		return false;
	}
	if(document.getElementById("txtEndereco").value.length < 10){
		alert("O campo Endereço precisa ter 10 caracteres no mínimo.");
		document.getElementById("txtEndereco").focus();
		return false;
	}
	if(document.getElementById("txtEndereco").value.search(/http:\/\//i)>0){
		alert("O campo Endereço precisa ter no seu início \"http:\/\/\".");
		document.getElementById("txtEndereco").focus();
		return false;
	}
	if(document.getElementById("txtEndereco").value.search(/http:\/\//i)==-1){
		alert("O campo Endereço precisa ter no seu início \"http:\/\/\".");
		document.getElementById("txtEndereco").value = "http://"+document.getElementById("txtEndereco").value
		document.getElementById("txtEndereco").focus();
		return false;
	}
	if (document.getElementById("txtPais").value=="") {
		alert("O campo País precisa ser preenchido.");
		document.getElementById("txtPais").focus();
		return false;
	}
	if (document.getElementById("txtPais").value.length < 3) {
		alert("O campo Pais precisa ter no mínimo 3 caracteres.");
		document.getElementById("txtPais").focus();
		return false;
	}
	if (document.getElementById("txtNome").value=="") {
		alert("O campo Nome precisa ser preenchido.");
		document.getElementById("txtNome").focus();
		return false;
	}
	if (document.getElementById("txtNome").value.length < 5) {
		alert("O campo Nome precisa ter no mínimo 5 caracteres.");
		document.getElementById("txtNome").focus();
		return false;
	}
	if (document.getElementById("txtEmail").value=="") {
		alert("O campo E-Mail precisa ser preenchido.");
		document.getElementById("txtEmail").focus();
		return false;
	}
	qtdArroba = document.getElementById("txtEmail").value.split('@');
	if (document.getElementById("txtEmail").value.search("@") == -1 || document.getElementById("txtEmail").value.search("[.]") == -1 || document.getElementById("txtEmail").value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == "."){ 
		alert("O preenchimento do campo E-MAIL está incorreto!"); 
		document.getElementById("txtEmail").focus(); 
		return false; 
	}
	if (document.getElementById("txtTelefone").value=="") {
		alert("O campo Telefone precisa ser preenchido.");
		document.getElementById("txtTelefone").focus();
		return false;
	}
	if (document.getElementById("txtTelefone").value.length < 5) {
		alert("O campo Telefone precisa ter 5 caracteres no mínimo.");
		document.getElementById("txtTelefone").focus();
		return false;
	}
	var checkOK = "0123456789-()";
	var checkStr = document.getElementById("txtTelefone").value;
	var allValid = true;
	var validGroups = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++){
			if (ch == checkOK.charAt(j)){
				break;
			}
			if (j == checkOK.length){
				allValid = false;
				break;
			}
		}
		if (!allValid){
			alert("Digite somente dígito caracteres no campo Telefone.");
			document.getElementById("txtTelefone").focus();
			return false;
		}
	}
	if (document.getElementById("txtSenha1").value=="") {
		alert("O campo Senha precisa ser preenchido.");
		document.getElementById("txtSenha1").focus();
		return false;
	}
	if (document.getElementById("txtSenha1").value.length < 4) {
		alert("O campo Senha deve ter no mínimo 4 caracteres.");
		document.getElementById("txtSenha1").focus();
		return false;
	}
	if (document.getElementById("txtSenha1").value.length > 20) {
		alert("o campo Senha deve ter no máximo 20 caracteres");
		document.getElementById("txtSenha1").focus();
		return false;
	}
	if (document.getElementById("txtSenha2").value=="") {
		alert("O campo Senha precisa ser preenchido.");
		document.getElementById("txtSenha2").focus();
		return false;
	}
	if (document.getElementById("txtSenha2").value.length < 4) {
		alert("O campo Senha deve ter no mínimo 4 caracteres.");
		document.getElementById("txtSenha2").focus();
		return false;
	}
	if (document.getElementById("txtSenha2").value.length > 20) {
		alert("o campo Senha deve ter no máximo 20 caracteres");
		document.getElementById("txtSenha2").focus();
		return false;
	}
	if (document.getElementById("txtSenha1").value!=document.getElementById("txtSenha2").value) {
		alert("As senhas não estão iguais.");
		document.getElementById("txtSenha1").focus();
		return false;
	}
	if (document.getElementById("txtComentario1").value == "") {
		alert("O campo Palavras Chaves precisa ser preenchido.");
		document.getElementById("txtComentario1").focus();
		return false;
	}
	if (document.getElementById("txtComentario2").value == "") {
		alert("O campo Comentario Sobre o Site precisa ser preenchido.");
		document.getElementById("txtComentario2").focus();
		return false;
	}
	document.getElementById("formCadastre").submit();
	return true;
}
function validaCupido(){
	if (document.getElementById("optMeuSexo").value=="naoinformado"){
		alert("Por favor, informe o seu sexo.");
		document.getElementById("optMeuSexo").focus();
		return false;
	}
	if (document.getElementById("txtNome").value==""){
		alert("Por favor, informe o seu nome.");
		document.getElementById("txtNome").focus();
		return false;
	}
	if (document.getElementById("txtNome").value.length > 200){
		alert("O campo Seu Nome está com um tamanho maior que o permitido!\nMáx: 200 caracteres.");
		document.getElementById("txtNome").focus();
		return false;
	}
	if (document.getElementById("txtEmail").value==""){
		alert("Por favor, informe o seu email.");
		document.getElementById("txtEmail").focus();
		return false;
	}
	qtdArroba = document.getElementById("txtEmail").value.split('@');
	if (document.getElementById("txtEmail").value.search("@") == -1 || document.getElementById("txtEmail").value.search("[.]") == -1 || document.getElementById("txtEmail").value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == "."){ 
		alert("O preenchimento do campo E-MAIL está incorreto!"); 
		document.getElementById("txtEmail").focus(); 
		return false; 
	}
	if (document.getElementById("txtEmail").value.length > 50){
		alert("O campo Seu Email está com um tamanho maior que o permitido!\nMáx: 50 caracteres.");
		document.getElementById("txtEmail").focus();
		return false;
	}
	if (document.getElementById("optEstadoCivil").value=="naoinformado"){
		alert("Por favor, informe o seu estado civil.");
		document.getElementById("optEstadoCivil").focus();
		return false;
	}
	if (document.getElementById("optDeQualEstado").value=="naoinformado"){
		alert("Por favor, informe o seu estado em que você mora.");
		document.getElementById("optDeQualEstado").focus();
		return false;
	}
	if (document.getElementById("txtCidade").value==""){
		alert("Por favor, informe a sua cidade.");
		document.getElementById("txtCidade").focus();
		return false;
	}
	if (document.getElementById("txtCidade").value.length > 50){
		alert("O campo Cidade Onde Mora está com um tamanho maior que o permitido!\nMáx: 50 caracteres.");
		document.getElementById("txtCidade").focus();
		return false;
	}
	if (document.getElementById("txtSenha").value==""){
		alert("Por favor, informe a sua senha.");
		document.getElementById("txtSenha").focus();
		return false;
	}
	if (document.getElementById("txtSenha").value.length < 4 || document.getElementById("txtSenha").value.length > 20){
		alert("A sua senha senha deve ter entre 4 a 20 caracteres.");
		document.getElementById("txtSenha").focus();
		return false;
	}
	if (document.getElementById("txtRecado").value==""){
		alert("Por favor, escreva alguma coisa sobre você.");
		document.getElementById("txtRecado").focus();
		return false;
	}
	if (document.getElementById("txtRecado").value.length > 255){
		alert("O campo recado está com um tamanho maior que o permitido!\nMáx: 255 caracteres.");
		document.getElementById("txtRecado").focus();
		return false;
	}
	document.getElementById("formCupido").submit();
	return true;
}
function exibeDetalhes(){
	var args = arguments;
	window.open("exibeDetalhes.asp?id="+args[0],null,"scrollbars=yes, null, null, width=440, height=280, left="+(window.screen.width-440)/2+", top="+(window.screen.height-280)/2);	
	
}
function validaCupidoMsg(){
	
	if (document.getElementById("txtNome").value==""){
		alert("Por favor, informe o seu nome.");
		document.getElementById("txtNome").focus();
		return false;
	}
	if (document.getElementById("txtEmail").value==""){
		alert("Por favor, informe o seu email.");
		document.getElementById("txtEmail").focus();
		return false;
	}
	qtdArroba = document.getElementById("txtEmail").value.split('@');
	if (document.getElementById("txtEmail").value.search("@") == -1 || document.getElementById("txtEmail").value.search("[.]") == -1 || document.getElementById("txtEmail").value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == "."){ 
		alert("O preenchimento do campo E-MAIL está incorreto!"); 
		document.getElementById("txtEmail").focus(); 
		return false; 
	}
	if (document.getElementById("txtMensagem").value==""){
		alert("Escreva uma mensagem!"); 
		document.getElementById("txtMensagem").focus(); 
		return false;
	}
	document.getElementById("formEnviaMsg").submit();
	return true;
}
