// JavaScript Document
  function loading(id) {
    $('#'+id).html("<span class='loadAjax'><img src='imagens/ajax-loader.gif' style='position:absolute; top:150px; left:50%;' /></span>");
  }

  function logar() {
      var login1 = $("#login").val();
      var senha1 = $("#senha").val();
      $.ajax({
          type:"POST",
          url:"adm/aacc.php",
          data : ({login : login1, senha : senha1}),
          success : function(msg) {
            if (msg=="") {
                window.open("adm/inicial.php", "AACC", "");
            }
            else {
                alert(msg);
            }
          }
      });
  }

  function atualiza_calendario(url) {
	loading("calendario");
	$("#calendario").load(url);
  }

  function detalhe_agenda(data) {
	loading("lista_eventos");
	$("#lista_eventos").load("adm/detalhamento_agenda.php?data="+data,"",function(){
           $("#lista_eventos").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
  }
  
  function mostrar_noticia_detalhe(id) {
	$('#corpo').load("zcms/noticias/busca_noticias.php?id="+id);  
  }


  function programas() {
	loading("corpo");
	$("#corpo").load("documentos.php?tipo=3","",function(){
           $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
        
  }
  function projetos() {
	loading("corpo");
	$("#corpo").load("documentos.php?tipo=4","",function(){
           $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
  } 
  function clipping() {
	loading("corpo");
	$("#corpo").load("documentos.php?tipo=6","",function(){
           $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
        window.setTimeout(function(){
            $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        }, 3000);
        window.setTimeout(function(){
            $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        }, 6000);
  } 
  function prestacao() {
	loading("corpo");
	$("#corpo").load("documentos.php?tipo=5","",function(){
           $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
  }  
  function area() {
	loading("corpo");
	$("#corpo").load("adm/index.php");
  } 
  function equipe() {
	loading("corpo");
	$("#corpo").load("equipe.php","",function(){
           $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
  }
  function escritorios() {
	loading("corpo");
	$("#corpo").load("escritorios.php");
  }
  function parcerias() {
	loading("corpo");
	$("#corpo").load("parcerias.php","",function(){
           $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
        window.setTimeout(function(){
            $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        }, 500);
  }
  function editais() {
	loading("corpo");
	$("#corpo").load("documentos.php?tipo=2","",function(){
           $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
  }
   function boletim() {
	loading("corpo");
	$("#corpo").load("boletim.php");
  }
  function instituicao() {
	loading("corpo");
	$("#corpo").load("instituicao.php","",function(){
           $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
  }
  function noticias() {
	loading("corpo");
	$("#corpo").load("noticias.php");
  }
   function agenda() {
	loading("corpo");
	$("#corpo").load("adm/agenda.php");
  }
   function biblioteca() {
	loading("corpo");
	$("#corpo").load("documentos.php?tipo=1","",function(){
           $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
        });
  }
  function fale() {
	loading("corpo");
	$("#corpo").load("contato.php");
  }
  


  function limpar_mensagem() {
	$('#nome').val("");
	$('#email').val("");
	$('#fone').val("");
	$('#cidade').val("");
	$('#uf').val("");
	$('#mensagem').val("");
  }

  function enviar_mensagem() {
	loading("resposta");
	$.ajax({
		type : "GET",
		url : "enviar_contato.php",
		data : ({
			nome : $('#nome').val(),
			fone : $('#fone').val(),
			cidade : $('#cidade').val(),
			uf : $('#uf').val(),
			email : $('#email').val(),
			mensagem : $('#mensagem').val()
		}),
		success : function(msg) {
			$('#resposta').html(msg);
			if ($('#resposta').val().indexOf("Erro")!=-1) {
				$('#nome').val("");
				$('#email').val("");
				$('#fone').val("");
				$('#cidade').val("");
				$('#uf').val("");
				$('#mensagem').val("");
			}
		}
	});
  }
  
  
  ///////////////////////////////////// GALERIA ///////////////////////////////////////////////
  
  function galeria(id) {
	if (id==0)  {
		loading("corpo");
		$("#corpo").load("galerias.php","",function () {
                    $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
                });
                window.setTimeout(function(){
                    $("#conteudo_texto").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
                }, 5000);
	}
	else {
	$("#corpo").load("galerias_fotos.php?galeria="+id,"",function() {
                $('#g1 a').lightBox({
			overlayBgColor: '#FFF',
			overlayOpacity: 0.6,
			imageLoading: 'imagens/ajax-loader.gif',
			imageBtnClose: 'imagens/Stop.png',
			imageBtnPrev: 'imagens/Symbol_Back.png',
			imageBtnNext: 'imagens/Symbol_Right.png',
			imageBlank:	  'imagens/lightbox-blank.gif',
			containerResizeSpeed: 350,
			txtImage: 'Imagem',
			txtOf: 'de'
		});
                $("#g1").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
                window.setTimeout(function(){
                    $("#g1").jScrollPane({showArrows:true, scrollbarWidth: 17, arrowSize: 17});
                }, 5000);
	  });
    }
  }
/*//////////////////////////////newsletter/////////////////////////////////////////////////////////////////////*/



    var tempo = 2500;
    var email = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/;

    function Cadastrar_Email() {
      if (email.test($('#email_newsletter').val())) {
        $.ajax({
          type: "POST",
          url: "zcms/newsletter/post_newsletter.php?newsletter=cad_email",
          data: ({
            email_newsletter: $('#email_newsletter').val()
          }),
          cache: false,
          success: function(msg){
            //alert(msg);
            var intervalo = window.setTimeout(function() { $('#msg').dialog('destroy') },tempo);
            $('#msg').html(msg).css({'background-color':'#ffffff','color':'#006600'}).dialog({closeOnEscape:false,width:290,minHeight:70,modal:true,title:'Mensagem!',buttons:{'OK':function(){$(this).dialog('destroy'); window.clearInterval(intervalo); }}});
			$('#email_newsletter').val("");
            return false;
          }
        });
      }
      else {
        if ($('#email_newsletter').val() != "") {
          //alert(+$('#email_newsletter').val()+' N&atilde;o &eacute; um Email V&aacute;lido!');
          var intervalo = window.setTimeout(function() { $('#msg').dialog('destroy') },tempo);
          $('#msg').html('<span class="ui-icon ui-icon-alert" style="float:left; margin:-2px 7px 20px 0;"></span>'+$('#email_newsletter').val()+' N&atilde;o &eacute; um Email V&aacute;lido!').css({'background-color':'#ffffff','color':'#006600'}).dialog({closeOnEscape:false,width:290,minHeight:70,modal:true,title:'Mensagem!',buttons:{'OK':function(){$(this).dialog('destroy'); window.clearInterval(intervalo); }}});
          return false;
        }
        else {
          //alert('&Eacute; Necess&aacute;rio Preencher um E-mail V&aacute;lido!');
          var intervalo = window.setTimeout(function() { $('#msg').dialog('destroy') },tempo);
          $('#msg').html('<span class="ui-icon ui-icon-alert" style="float:left; margin:-2px 7px 20px 0;"></span>&Eacute; Necess&aacute;rio Preencher um E-mail V&aacute;lido!').css({'background-color':'#ffffff','color':'#006600'}).dialog({closeOnEscape:false,width:290,minHeight:70,modal:true,title:'Mensagem!',buttons:{'OK':function(){$(this).dialog('destroy'); window.clearInterval(intervalo); }}});
          return false;
        }
      }
      return false;
    };
	
	/*******************************************************************************************************/////////////////////////*************/