//#### Feito por Leandro Lopes de Oliveira #### Todos direitos Reservados #### leandro@w3vision.com.br
/*function valblog() {
   
   if ( document.blog.nome.value == "" ) {
		alert("Por favor, informe o Nome completo");
		document.blog.nome.focus();
		return false;
	}
	else if ( document.blog.comentario.value == "" ) {
		alert("Por favor, informe a Comentário");
		document.blog.comentario.focus();
		return false;
	}
	else if ( document.blog.private_key.value == "" ) {
		alert("Por favor, informe os dados da imagem de segurança");
		document.blog.private_key.focus();
		return false;
	}
	
  return true;
}*/
function valcontato () {
	
	if ( document.contato.nome.value == "" ) {
		alert("Por favor, informe o seu Nome");
		document.contato.nome.focus();
		return false;
	}
	else if ( !valida_mail(document.contato.email.value) ) {
		alert("Por favor, digite seu e-mail corretamente");
		document.contato.email.focus();
		return false;
	}
	else if ( document.contato.telefone.value == "" ) {
		alert("Por favor, informe o seu Telefone");
		document.contato.telefone.focus();
		return false;
	}
		
	else if ( document.contato.assunto.value == "" ) {
		alert("Por favor, informe o Assunto");
		document.contato.assunto.focus();
		return false;
	}
	
	else if ( document.contato.estado.value == "" ) {
		alert("Por favor, informe o Estado");
		document.contato.estado.focus();
		return false;
	}
	
	else if ( document.contato.cidade.value == "" ) {
		alert("Por favor, informe a Cidade");
		document.contato.cidade.focus();
		return false;
	}
	
	else if ( document.contato.mensagem.value == "" ) {
		alert("Por favor, informe a Mensagem");
		document.contato.mensagem.focus();
		return false;
	}
	return true;
}

function valida_mail(valor) {
	prim = valor.indexOf("@")
	if(prim < 2) return false;
	if(valor.indexOf("@",prim + 1) != -1) return false
	if(valor.indexOf(".") < 1) return false;
	if(valor.indexOf(".@") > 0) return false;
	if(valor.indexOf("@.") > 0) return false;
	if(valor.indexOf(".com.br.") > 0) return false;
	if(valor.indexOf("/") > 0) return false;
	if(valor.indexOf("[") > 0) return false;
	if(valor.indexOf("]") > 0) return false;
	if(valor.indexOf("(") > 0) return false;
	if(valor.indexOf(")") > 0) return false;
	if(valor.indexOf("..") > 0) return false;
	if(valor.indexOf(",") > 0) return false;
	return true;
		
}
// Conta caracteres
function ContaCaracteres(){
   intCaracteres = 300 - document.blog.comentario.value.length;
   if (intCaracteres > 0){
      document.blog.caracteres.value = intCaracteres;
      return true;
   }
   else {
      document.blog.caracteres.value = 0;
      document.blog.comentario.value = document.blog.comentario.value.substr(0,300)
      return false;
   }
  }
function validaenq(qo) {
		
	 if ( !validaop(qo) ) {
		
		alert("Por favor, selecione uma opcao para seu voto.");
		document.vot.R1[0].focus();
		return false;
	}
	
	return true;
	
}
function validaop(qo)
	{
		var r=document.vot.R1
		
			for (i = 0;i < qo ;i++)
				{
					if( (r[i].checked))
						{
							return true;
						}
					
				}
		return false;	
				
	}

function votar(qtdop) {
		
		if (validaenq(qtdop))
			{
				document.vot.action = "enquete_vota.php";
				document.vot.method = "post";
				document.vot.submit();	
			}

		
	}
function resultadoenq() {
				
				document.res.action = "index.php?idenq=resultado#enquete";
				document.res.method = "post";
				document.res.submit();	
			
	}
function numerico(field) {

				  expr = field.value;
  
				  if (isNaN(expr)) {
						 //alert('Campo '+ field.name +'aceita somente Números.');
						 field.value = '';
						 field.focus();
						 return false;
					} 
				  else {
						 return true;
					}
}
/*function tempo(lnk) {
		
				document.tempo.action = "enquete_vota.php";
				document.tempo.method = "post";
				document.tempo.
				document.tempo.submit();	
			}

		
	}*/

function ContaCaracteres(){
   intCaracteres = 300 - document.mural.comentario.value.length;
   if (intCaracteres > 0){
      document.mural.caracteres.value = intCaracteres;
      return true;
   }
   else {
      document.mural.caracteres.value = 0;
      document.mural.comentario.value = document.mural.comentario.value.substr(0,300)
      return false;
   }
}
function valrecado () {

	
	if ( document.mural.de.value == "" ) {
		alert("Por favor, informe o seu Nome");
		document.mural.de.focus();
		return false;
	}
	else if ( document.mural.para.value == "" ) {
		alert("Por favor, informe o Destinatário");
		document.mural.para.focus();
		return false;
	}
	else if ( document.mural.mensagem.value == "" ) {
		alert("Por favor, informe a Mensagem");
		document.mural.mensagem.focus();
		return false;
	}
	else if ( document.mural.private_key.value == "" ) {
		alert("Por favor, Digite o Código de Verificação da Imagem ao lado.");
		document.private_key.mensagem.focus();
		return false;
	}
	return true;
}
