﻿$(document).ready(function(){
	//## Acessibilidade ##					   
	// Reset Font Size
	var originalFontSize = $('html').css('font-size');
	
	$(".fontNormal").click(function(){
		$('html').css('font-size', originalFontSize);
	});
		
	//Aumentar o tamanho da fonte
	$(".fontMais").click(function(){
		var currentFontSize = $('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*1.2;
		$('html').css('font-size', newFontSize);
		return false;
	});

	//Diminuir o tamanho da fonte
	$(".fontMenos").click(function(){
		var currentFontSize = $('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*0.8;
		$('html').css('font-size', newFontSize);
		return false;
	});
	
	//## Acessibilidade - Funções para troca de estilo ##
	$('.styleswitch').click(function(){
		switchStylestyle(this.getAttribute("rel"));
		return false;
	});
	var c = readCookie('style');
	if (c) switchStylestyle(c);
	//##Fim Acessibilidade - Funções para troca de estilo ##
	
	$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 20000, true);
    $("a.zoom").fancybox();
    
    $("a.zoom1").fancybox({
        'overlayOpacity'	:	'0.7',
		'titleShow'		: true,
		'titlePosition'		: 	'inside'
	})

    $("a.zoom2").fancybox({
        'zoomSpeedIn'		:	'500',
        'zoomSpeedOut'		:	'500',
        'overlayShow'		:	false,
		'titlePosition'		: 	'inside'
    });
	
});

function ap_stopAll(player_id)
{
	$('.audio').each(function(){
		if($(this).attr('href') != player_id)
		{
			$(this).find('object')[0].SetVariable("closePlayer", 1);
		}
		else 
		{
			$(this).find('object')[0].SetVariable("closePlayer", 0);
		}
	});
}

function playerAudio() {
    $('.audio').each(function() {
        var audio_file = $(this).attr('href');
        $(this).flash(
            {
                swf : 'flash/audioplayer.swf',
                flashvars:{
                    soundFile : audio_file,
                    playerID: "'" + audio_file + "'"
                    
                }
            }
        );
    });
}

//## Acessibilidade - Funções para troca de estilo ##
function switchStylestyle(styleName){
	$('link[@rel*=style][title]').each(function(i) {
		this.disabled = true;
		if (this.getAttribute('title') == styleName) this.disabled = false;
	});
	createCookie('style', styleName, 365);
}
//##Fim Acessibilidade - Funções para troca de estilo ##

//## Acessibilidade - Funções para troca de estilo ##
/*(function($){
	$(document).ready(function() {
		$('.styleswitch').click(function(){
			switchStylestyle(this.getAttribute("rel"));
			return false;
		});
		var c = readCookie('style');
		if (c) switchStylestyle(c);
	});

	function switchStylestyle(styleName){
		$('link[@rel*=style][title]').each(function(i) {
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
		createCookie('style', styleName, 365);
	}
})(jQuery);*/

// cookie functions
function createCookie(name,value,days)
{
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name){
	createCookie(name,"",-1);
}
//cookie functions

/*Get URL Parameters (QueryStrings)*/
function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}
/* uso: getQuerystring('idEditoria')
 * url = ?idEditoria=4001 retorna o id da editoria 
 * Fim Get URL Parameters (QueryStrings)*/

//Combos de Filtros
function comboNoticias(mes){
	var ano = $("#comboAno").val();
	var idEditoria = getQuerystring('idEditoria');
    $.ajax({
        type: "POST",
        url: "filtroJquery.php",
        data: "idEditoria="+idEditoria+"&ano="+ano+"&mes="+mes+"&filtro=ok",
        beforeSend: function() {
        	$('#resultadoFiltro').html('Processando, por favor aguarde... <img src="./img/ajax-loader.gif">'); // ...mensagem de espera
        	document.body.style.cursor='wait';	        
        	$('#noticias').remove();
    		},
    	success: function(txt) { 
			document.body.style.cursor='auto';
			$('#resultadoFiltro').html(txt);
    		},
    	error: function(txt) {
    		alert('Desculpe, houve um erro interno.');
    		}
    	});
}

function buscaAudio(ano, mes) {
	$('#noticias').html('Processando, por favor aguarde... <img src="./img/ajax-loader.gif">'); // ...mensagem de espera
   	document.body.style.cursor='wait';
	$.post('filtroAudio.php',
	{
		"ano" : ano,
		"mes" : mes
	},
	function(data) {
		$('#noticias').html(data);
		playerAudio();
		document.body.style.cursor='auto';
	});
}

function buscaNotas(ano, mes, editoria) {
	$('#notas').html('Processando, por favor aguarde... <img src="./img/ajax-loader.gif">'); // ...mensagem de espera
   	document.body.style.cursor='wait';
	$.post('filtroNotas.php',
	{
		"ano" : ano,
		"mes" : mes,
		"editoria" : editoria
	},
	function(data) {
		$('#notas').html(data);
		playerAudio();
		document.body.style.cursor='auto';
	});
}

/*
function comboSaudeInfo(mes){
	var ano = $("#comboAno").val();
    $.ajax({
        type: "POST",
        url: "filtroSaudeInfo.php",
        data: "ano="+ano+"&mes="+mes+"&filtro=ok",
        beforeSend: function() {
        	$('#resultadoFiltro').html('Processando, por favor aguarde... <img src="./img/ajax-loader.gif">'); // ...mensagem de espera
        	document.body.style.cursor='wait';	        
        	$('#filtroSaudeInfo').remove();
        	$('#materia_completa').remove();        	
    		},
    	success: function(txt) { 
			document.body.style.cursor='auto';
			$('#resultadoFiltro').html(txt);
    		},
    	error: function(txt) {
    		alert('Desculpe, houve um erro interno.');
    		}
    	});
}

function comboArtigos(mes){
	var ano = $("#comboAno").val();
    $.ajax({
        type: "POST",
        url: "filtroArtigos.php",
        data: "ano="+ano+"&mes="+mes+"&filtro=ok",
        beforeSend: function() {
        	$('#resultadoFiltro').html('Processando, por favor aguarde... <img src="./img/ajax-loader.gif">'); // ...mensagem de espera
        	document.body.style.cursor='wait';	        
        	$('#filtroArtigos').remove();
        	$('#materia_completa').remove();        	
    		},
    	success: function(txt) { 
			document.body.style.cursor='auto';
			$('#resultadoFiltro').html(txt);
    		},
    	error: function(txt) {
    		alert('Desculpe, houve um erro interno.');
    		}
    	});
}

function comboBoletins(mes){
	var ano = $("#comboAno").val();
    $.ajax({
        type: "POST",
        url: "filtroBoletins.php",
        data: "ano="+ano+"&mes="+mes+"&filtro=ok",
        beforeSend: function() {
        	$('#resultadoFiltro').html('Processando, por favor aguarde... <img src="./img/ajax-loader.gif">'); // ...mensagem de espera
        	document.body.style.cursor='wait';	        
        	$('#filtroBoletins').remove();
        	$('#materia_completa').remove();        	
    		},
    	success: function(txt) { 
			document.body.style.cursor='auto';
			$('#resultadoFiltro').html(txt);
    		},
    	error: function(txt) {
    		alert('Desculpe, houve um erro interno.');
    		}
    	});
}

function comboEventos(mes){
	var ano = $("#comboAno").val();
    $.ajax({
        type: "POST",
        url : "filtroEventos.php",
        data: "ano="+ano+"&mes="+mes+"&filtro=ok",
        	beforeSend: function() {
        		$('#resultadoFiltro').html('Processando, por favor aguarde... <img src="./img/ajax-loader.gif">'); // ...mensagem de espera
        		document.body.style.cursor='wait';	        
        		$('#filtroEventos').remove();
    		},
			success: function(txt) { 
				document.body.style.cursor='auto';
				$('#resultadoFiltro').html(txt);
			},
			error: function(txt) {
				alert('Desculpe, houve um erro interno.');
			}
    	});
}

function comboProcessoSeletivo(mes){
	var ano = $("#comboAno").val();
    $.ajax({
        type: "POST",
        url : "filtroProcessoSeletivo.php",
        data: "ano="+ano+"&mes="+mes+"&filtro=ok",
        	beforeSend: function() {
        		$('#resultadoFiltro').html('Processando, por favor aguarde... <img src="./img/ajax-loader.gif">'); // ...mensagem de espera
        		document.body.style.cursor='wait';
        		$('#processoSeletivo').remove();
    		},
			success: function(txt) { 
				document.body.style.cursor='auto';
				$('#resultadoFiltro').html(txt);
			},
			error: function(txt) {
				alert('Desculpe, houve um erro interno.');
			}
    	});
}

function comboFotosJornalismo(mes){
	var ano = $("#comboAno").val();
    $.ajax({
        type: "POST",
        url : "filtroFotosJornalismo.php",
        data: "ano="+ano+"&mes="+mes+"&filtro=ok",
        	beforeSend: function() {
        		$('#resultadoFiltro').html('Processando, por favor aguarde... <img src="./img/ajax-loader.gif">'); // ...mensagem de espera
        		document.body.style.cursor='wait';	        
        		$('#filtroFotosJornalismo').remove();
    		},
			success: function(txt) { 
				document.body.style.cursor='auto';
				$('#resultadoFiltro').html(txt);
			},
			error: function(txt) {
				alert('Desculpe, houve um erro interno.');
			}
    	});
}*/
//Fim Combos de Filtros

//Impressão de texto
$(function(){ 
	$( "a.print" )
		.attr("href", "javascript:void(0)")
		.click(function(){
			$(".printArea").print();
 			return( false );
			}
		);
 }); 

<!--  onLoad="MM_preloadImages('../img/biblioteca/a_hover.gif')" -->
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
