// JavaScript Document

    $(document).ready(function() {
        $("#container-lateral-enquete-link").toggle(function() {
            $("#mostra_resultado").show('fast');
            }, function() {
            $("#mostra_resultado").hide('fast');
        });
    });
	function abre_comentario(id)
	{  
		$("#form-comentario").attr("action","cad_comentario.php?id="+id);
		$("#comentario").show('blind',500);			   
	}
	function fecha_comentario()
	{  
		$("#comentario").hide('blind',500);						   
	} 
	function validaCampos()
	{
	
		var nome = document.getElementById("nome_comentario");	
		var msn = document.getElementById("texto_comentario");	
		var form = document.getElementById("form-comentario");
		
		if (nome.value == "" || nome.value == "Nome")
			alert('Campo nome obrigatório');
		else if (msn.value=="" || msn.value == "Seu comentário")
			alert('Campo mensagem obrigatório');
		else
			form.submit();
		
	}
	function checkMail(mail){
			var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
			if(typeof(mail) == "string"){
				if(er.test(mail)){ return true; }
			}else if(typeof(mail) == "object"){
				if(er.test(mail.value)){ 
							return true; 
						}
			}else{ 
				return false;
				}
	}
	function validaCampos2()
	{
	
		var busca = document.getElementById("busca");	
		var form = document.getElementById("form_busca");
		
		if (busca.value == "" || busca.value == "Digite aqui um tema de interesse!"){
			alert('O campo de busca é de preenchimento obrigatório');
		}
		else
			form.submit();
		
	}
	 
		function ler_comentario(id)
		{
			var div = "#container-interna-esquerda-comentario"+id;
			var img = "#ler-comentarios-"+id;	
			var js = "fecha_ler("+id+")";
			$(div).show('fast');
			//$(img).attr("src","../imgs/cursos-btnfechar.png");
			//$(img).attr("alt","Fechar");
			$(img).attr("onClick",js); 
			
           
		}
		function fecha_ler(id) 
		{
			var div = "#container-interna-esquerda-comentario"+id;
			var img = "#ler-comentarios-"+id;	
			var js = "ler_comentario("+id+")";
			$(div).css({ display: "none"});
			//$(img).attr("src","../imgs/cursos-btnvejamais.png");
			//$(img).attr("alt","Veja Mais");
			$(img).attr("onClick",js); 
		}
		
    	function validaCampos3()
		{
			var nome = document.getElementById("nomec");	
			var email = document.getElementById("emailc");
			var profissao = document.getElementById("profissao");
			var msn = document.getElementById("msn");	
			var form = document.getElementById("form_envia");
			
			if (nome.value == "")
				alert('Campo nome obrigatório');
			else if (!checkMail(email.value))
				alert('Campo e-mail inválido');
			else if (profissao.value=="")
				alert('Campo profissão obrigatório');
			else if (msn.value=="")
				alert('Campo mensagem obrigatório');
			else
				form.submit();
		}
		
		function validaCampos5()
		{
			var nome = document.getElementById("nome");	
			var email = document.getElementById("email");	
			var form = document.getElementById("form_news");
			
			if (nome.value == "" || nome.value == "Nome")
				alert('Campo nome obrigatório');
			else if (!checkMail(email.value))
				alert('Campo e-mail inválido');
			else
				form.submit();
		}
		
		function validaCampos4()
		{
			var nome = document.getElementById("nomei");	
			var email = document.getElementById("emaili");
			var emaild = document.getElementById("emaild");
			var form = document.getElementById("form_indique");
			
			if (nome.value == "")
				alert('Campo nome obrigatório');
			else if (!checkMail(email.value))
				alert('Campo e-mail inválido');
			else if (!checkMail(emaild.value))
				alert('Campo e-mail destinatário inválido');
			else
				form.submit();
		}
