/**
 * Escopo jQuery para compatibilidade com outros frameworks de JS
 */
(function($) {
	$(document).ready(function() {
		/**
		 * Insere o link (seta) nos widgets de links da lateral
		 */
		var seta = $('<a></a>').attr('href', '#').addClass('novo__seta');
		$('#widgets > ul > li.widget_links').addClass('novo__menu-pai').addClass('novo__seta-fechado').prepend(seta);
		
		// Bloco que aparece aberto
		$('#linkcat-627:has(ul)').removeClass('novo__seta-fechado novo').addClass('novo__seta-aberto').children('ul').show();
		
		/**
		 * Efeito de collapse nos widgets de links da lateral
		 */
		$('#widgets > ul > li.widget_links > h2, #widgets > ul > li.widget_links > a.novo__seta').click(function(e) {
			e.preventDefault();
			$('ul.blogroll:not(:animated)', $(this).parent()).slideToggle(400, function() {
				$($(this).parent()).toggleClass('novo__seta-fechado');
				$($(this).parent()).toggleClass('novo__seta-aberto');
			});
		});
		
		/**
		 * Coloca o target _blank nos widgets de imagens
		 */
		$("#widgets > ul > li.widget_image > a[title='II Conferência Nacional de Cultura']:has(img)").attr('target', '_blank');
		$("#widgets > ul > li.widget_image > a[title='Blog da II Conferência Nacional de Cultura']:has(img)").attr('target', '_blank');
		

		/**
		 * Insere o link (seta) nos links da lateral de instituicional
		 */
		var seta = $('<a></a>').attr('href', '#').addClass('novo__setinha');
		$('#links-institucionais li:has(ul)').addClass('novo__menu-pai').addClass('novo__setinha-fechado').prepend(seta);
		
		$('#links-institucionais li ul').each(function() {
			//$(this).height($(this).innerHeight() - 30);
		});
		
		/**
		 * Efeito de collapse dos links da lateral de instituicional
		 */
		$('#links-institucionais li:has(ul) a.novo__setinha').click(function(e) {
			e.preventDefault();
			var ul = $(this).parent().children('ul:not(:animated)');
			ul.slideToggle(400, function() {
				$($(this).parent()).toggleClass('novo__setinha-fechado');
				$($(this).parent()).toggleClass('novo__setinha-aberto');
			});
		});
		
		/**
		 * Redimensiona os LIs dos submenus do menu superior (largura do maior LI)
		 */

         /*Modificação para funcionar no IE6 */
   /*		$('#menu-principal li').each(function() {
			var maior = 0;
			$('ul li a', $(this)).each(function() {
				var largura = $(this).innerWidth();
				if (largura > maior) maior = largura;
			});
			if ($(this).children('ul').children('li').size() > 1) {
				var largura = ((maior + 25) * 2);
			} else {
				var largura = (maior + 25);
			}
			largura = Math.max(largura, $(this).outerWidth());
			$(this).children('ul').width(largura + 'px');
			$(this).children('ul').children('li').width(maior + 'px');
		}); */
		
		/**
		 * Efeito de hover no streaming
		 */
		/*
		$('#content-streaming #streaming-items li').each(function() {
			var color = $('a:first', $(this)).css('color');
			$(this).hover(function() {
				$('div.text a, div.time', $(this)).css('color', '#FFFFFF');
				$('div.text a', $(this)).css('text-decoration', 'underline');
				$(this).css({
					'background': color,
					'cursor': 'pointer'
				});
			}, function() {
				$('div.text a, div.time', $(this)).css('color', '');
				$('div.text a', $(this)).css('text-decoration', '');
				$(this).css({
					'background': '',
					'cursor': 'default'
				});
			});

			$(this).click(function() {
				window.location = $('a:first', $(this)).attr('href');
			});				
		});
		*/
	});
})(jQuery);