$(document).ready( function() {

   /*** CLICK NA DIV LOGO NO TOPO DAS PAGINAS ***/
   $("div#logo").click( function() {
      location.href = "index.php";
   });


   /**** COOKIE PARA CONTROLE DO ACESSO DE USUARIOS ****/
   // Quando o usuario se logar, o valor sera alterado para true em login.js
   // w3cookies.create("logado", false, 0);


   /****  P A R A   A   A G E N D A  ****/
   $(".pormes").live("click",function(e) {
      e.preventDefault();
      var v=$(this).attr("id");
      $("#calAguarde").show();
      $("#cabecainterna").load("_calendario_home.php?retorno="+v, function() {
          $("#calAguarde").hide(); //on complete
      });
   })

   $(".preto").live("click",function(e) {
      e.preventDefault();
      var v=$(this).attr("id");
      if (location.href.indexOf(".br")>0) {
         //--:::>location.href='/site2010/agenda/'+v;
         location.href='/agenda/'+v;
      } else {
         location.href='/agenda/'+v;
      }
      //alert(v);
   })

   $(".branco").live("click",function(e) {
      e.preventDefault();
      var v=$(this).attr("id");
      if (location.href.indexOf(".br")>0) {
         //--:::>location.href='/site2010/agenda/'+v;
         location.href='/agenda/'+v;
      } else {
         location.href='/agenda/'+v;
      }
   })

   $(".vermelho").live("click",function(e) {
      e.preventDefault();
      var v=$(this).attr("id");
      if (location.href.indexOf(".br")>0) {
         //--:::>location.href='/site2010/agenda/'+v;
         location.href='/agenda/'+v;
      } else {
         location.href='/agenda/'+v;
      }
      // alert(v);
   })

   $(".mostrar").toggle(

      function(e) {
         $('.abrir_noticia').hide('slow');
         e.preventDefault();
         var caminho=$(this).attr("rel");
         $("#"+caminho).toggle("slow");
         // $(this).html('Ocultar Detalhes');
      },

      function() {
         var caminho=$(this).attr("rel");
         $('.abrir_noticia').hide('slow');
         $("#"+caminho).hide('slow');
      }
   );



   //ocultar e exibi editor do forum
   $('.tyne').hide();
   $(".img").toggle(

      function(e) {
         $('.tyne').hide('slow');
         e.preventDefault();
         var caminho=$(this).attr("id");
         $("#img_"+caminho).toggle("slow");
         // $(this).html('Ocultar Detalhes');
      },

      function() {
         var caminho=$(this).attr("id");
         $('.tyne').hide('slow');
         $("#img_"+caminho).hide('slow');
      }

   );





if ( location.href.indexOf("noticias_interna.php")>=0 ) {
   $('a[rel*=facebox]').facebox();
};

$("#btnIndique").live("click",function(e) {
e.preventDefault();


var campo1=$("#nomeindicar").val();
var campo2=$("#nomeamigo").val();
var campo3=$("#emailamigo").val();

if(campo1=="") {

 alert("Escreva seu nome");
 return false;
}
if(campo2=="") {

 alert("Escreva o nome do seu amigo");
 return false;
}


var retorno = campo3.split("@");

if(typeof(retorno[1]) === "undefined") {
     alert("Escreva um email valido");
     return false;
     }

 $.ajax({
   type: "POST",
   url: "retorno_indicar_amigo.php",
   data:$("#formIndique").serialize(),
   success: function(msg){
   $("#amigo").html(msg);
     alert( "Mensagem Enviada" );
   }
 });



 })

 $('.imprimir').live("click",function(e) {
e.preventDefault();
$("#vitrineesq").hide("slow");
$("#miolodireita").hide("slow");
$("#cabecalho").hide("slow");
$("#topo").hide("slow");
$("#menuum").hide("slow");
$("#menuum ul").hide("slow");
$("#rodape").hide("slow");





   })

});





$(document).ready(function(){

   //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   //  PARA PAGINA DE PERGUNTAS FREQUENTES
   //  Jorge Rodrigues - Maio/2010
   //  (veio de Telos)
	function accordion(){
		$('.PerguntaFreq-SubTit li h3').click(function() {

			if($(this).next().is('.aberto')){
				return false;
			}else{

				$('.PerguntaFreq-SubTit li h3').next().hide('slow').removeAttr('class');
				$(this).next().toggle('slow').attr('class','aberto');
			}
			return false;
		}).next().hide()
	}

	function start(){
		accordion();
	}

	start();
   //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



   //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   //  LIMPA OS CAMPOS DOS FORMULARIOS QUE EXIBEM TEXTO INDICATIVOS
   //  Jorge Rodrigues - Maio/2010

   //  para o formulario de busca no site do topo e rodape
   $(".termoBusca").bind("click",function() {
      if($(this).attr("value")=="Faça sua busca") {
         $(this).attr("value","");
      }
   });
   $(".termoBusca").bind("blur",function() {
      if($(this).attr("value")=="") {
         $(this).attr("value","Faça sua busca");
      }
   });

   // para o furmulario do quadro Cadastre-se na coluna esquerda
   $("#formCadastreColEsq > input#nome").bind("click", function() {
      if($(this).attr("value").toUpperCase()=="NOME") {
         $(this).attr("value","");
      }
   });
   $("#formCadastreColEsq #nome").bind("blur", function() {
      if($(this).attr("value")=="") {
         $(this).attr("value","Nome");
      }
   });

   $("#formCadastreColEsq > input#email").bind("click", function() {
      if($(this).attr("value").toUpperCase()=="E-MAIL") {
         $(this).attr("value","");
      }
   });
   $("#formCadastreColEsq #email").bind("blur", function() {
      if($(this).attr("value")=="") {
         $(this).attr("value","E-mail");
      }
   });
   //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

});



//------------------------------------------------------
//    Controle de acesso ao simulador de incentivo
//    Autor: Jorge Rodrigues - Agosto/2010
//
$(document).ready( function() {

   logado = w3cookies.read('LOGADO');

   if(logado=="" || logado==null) {
      $((".simulaIncentivo")).addClass("cboxelement");
      $((".simulaIncentivo")).attr("href","_login.php");
   } else {
      $(".simulaIncentivo").removeClass("cboxelement");
      $((".simulaIncentivo")).attr("href","simulador-de-incentivo.php");
   }
});


$(".simulaIncentivo").live("click", function(e) {

   logado = w3cookies.read('LOGADO');

   if(logado=="" || logado==null) {
      //e.preventDefault();
      $(this).addClass("cboxelement");
      $(this).attr("href","_login.php");
      alert("É necessário estar logado para acessar esta página.");
   } else {
      $(this).removeClass("simulaIncentivo");
      $(this).removeClass("cboxelement");
      $(this).removeClass("simulaIncentivo cboxelement");
   }


});
//------------------------------------------------------

