// Pacote de funções

// função MENU - controla a cotina

function abre_perfil (perf, obj) {
//	alert($("#"+obj).children("div").attr("id"));
	$("#"+obj).children("div").slideToggle("slow");
//		$(".panelg").slideUp("slow");
		$(this).toggleClass("active"); 		
		return false;
}


$(document).ready(function(){
	
	//abrir menu secretarias da prefeitura
	$("#abrir_menu").click(function(){
	$(".cortina_menu").slideToggle("slow");
	$(this).toggleClass("active");
	
	return false;
	
	});
 
	$("#btn-menu1").click(function(){
		$(".panela").slideToggle("slow");
		$(this).toggleClass("active"); 		
		$(".panelb").slideUp("slow");				
		$(".panelc").slideUp("slow");						
		$(".paneld").slideUp("slow");						

		return false;
	});
	
	$("#btn-menu2").click(function(){
		$(".panelb").slideToggle("slow");
		$(this).toggleClass("active"); 		
		$(".panela").slideUp("slow");				
		$(".panelc").slideUp("slow");						
		$(".paneld").slideUp("slow");		
		
		return false;
		
	});
	
	$("#btn-menu3").click(function(){
		$(".panelc").slideToggle("slow");
		$(this).toggleClass("active"); 		
		$(".panelb").slideUp("slow");				
		$(".panela").slideUp("slow");						
		$(".paneld").slideUp("slow");						

		return false;
		
	});

	$("#btn-menu4").click(function(){
		$(".paneld").slideToggle("slow");
		$(this).toggleClass("active"); 		
		$(".panelb").slideUp("slow");				
		$(".panelc").slideUp("slow");						
		$(".panela").slideUp("slow");					

		return false;

	});
	
		$("#btn-menu8").click(function(){
		$(".panelh").slideToggle("slow");
		$(this).toggleClass("active"); 		

		return false;

	});	

/*

	$("#btn-menu_estudante").click(function(){
		$(".panel_estudante").slideToggle("slow");
		$(this).toggleClass("active");
		
		return false;

	});
	
	$("#btn-menu_turista").click(function(){
		$(".panel_turista").slideToggle("slow");
//		$(".panelf").slideUp("slow");
		$(this).toggleClass("active"); 		

		return false;

	});	
	
	$("#btn-menu_empreendedor").click(function(){
		$(".panel_empreendedor").slideToggle("slow");
//		$(".panelg").slideUp("slow");
		$(this).toggleClass("active"); 		

		return false;

	});
	
	$("#btn-menu_cidade").click(function(){
		$(".panel_cidade").slideToggle("slow");
//		$(".panelg").slideUp("slow");
		$(this).toggleClass("active"); 		

		return false;

	});	
	
	$("#btn-menu_cidadao").click(function(){
		$(".panel_cidadao").slideToggle("slow");
//		$(".panelg").slideUp("slow");
		$(this).toggleClass("active"); 		

		return false;

	});	
		$("#btn-menu_servidor").click(function(){
		$(".panel_servidor").slideToggle("slow");
//		$(".panelg").slideUp("slow");
		$(this).toggleClass("active"); 		

		return false;

	});	



*/
		



	// menu secretaria
//	$("#btn-menu9").click(function(){
//		$(".paneli").slideToggle("slow");
//		$(this).toggleClass("active"); 		

//		return false;

//	});

	// menu departamento
//	$("#btn-menu10").click(function(){
//		$(".panelj").slideToggle("slow");
//		$(this).toggleClass("active"); 		

//		return false;

//	});

	// menu empresa
//	$("#btn-menu11").click(function(){
//		$(".panelk").slideToggle("slow");
//		$(this).toggleClass("active"); 		

//		return false;

//	});

	// menu servico
//	$("#btn-menu12").click(function(){
//		$(".panell").slideToggle("slow");
//		$(this).toggleClass("active"); 		

//		return false;

//	});
	
	//abrir menu secretarias da prefeitura
	$("#abrir_menu_secretarias").click(function(){
		$(".panelsecre").slideToggle("slow");
		$(this).toggleClass("active"); 	

		return false;

	});
	
	//abrir menu estudante
	$("#abrir_menu_secretarias_estu").click(function(){
		$(".panelsecre_estu").slideToggle("slow");
		$(this).toggleClass("active"); 	

		return false;

	});		
		
/*
	// datepicker on click	
	$("#datepicker").click(function(){	
		//alert($("#datepicker").datepicker('getDate'));
		alert('aii aiii');
		//$(".selector").datepicker.formatDate('dd-mm-yy', $("#datepicker").datepicker('getDate'))
	});
*/
});


// função CAIXA MÁGICA

	
$(document).ready(function(){	

	//nossos amigos canais externos! :P
	$("#slider1").easySlider({
		prevText: 		'', // aqui vai o caminho das imagens
		nextText: 		'', // aqui vai o caminho das imagens
		auto: false,
		continuous: true
	});

	// METROCLIMA e cia
	$("#slider_redes_sociais").easySlider({ 
		prevText: 		'', // aqui vai o caminho das imagens
		nextText: 		'', // aqui vai o caminho das imagens
		continuous: true,
		nextId: "slidernext",
		prevId: "sliderprev"
	});	

});


// função ACESSIBILIDADE
/*
$('document').ready(function(){
	$('#acessibilidade').ability({ switcherstyles: ['estilo.css', 'estilo_acessivel.css'], defaultcss: 'estilo.css' });
});
*/

//SLIDESHOW - BANNERS

$(document).ready(function() {		
	
	//Execute the slideShow
	slideShow();

});

function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',3500);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	//var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
}


//funçãozinha cretina das abas
//troca as abas da capa (NOTICIAS, SERVICOS, FALECONOIS)
function trocaAba(idaba,idpai, li){
	var aba = document.getElementById(idaba);
	var pai = document.getElementById(idpai);
	var hNodes = pai.getElementsByTagName("div");
	var tempLi;
	link = li.getElementsByTagName("a");
	link = link[0];
	if (navigator.appName.match("Microsoft") != null ) {
		cor_bg = link.currentStyle.backgroundColor;
	}
	else {
		cor_bg = window.getComputedStyle(link, "");
		cor_bg = cor_bg.backgroundColor;
	}
	for(var i=0;i<hNodes.length; i++)
	{
		//esconde todas as abas
	 	tempLi = document.getElementById("chama"+(i+1)).getElementsByTagName("a");
	 	tempLi = tempLi[0];
	 	tempLi.style.borderBottom  = "#fff 2px solid";
		hNodes[i].style.display = 'none';
		hNodes[i].style.zIndex = '2';
		
	}
	//mostra só a aba guerreira seleciona
	link.style.borderBottom = cor_bg+" 2px solid";
	aba.style.display = 'block'	;
	aba.style.zIndex = '20';
}


