﻿/****************************************************
 * @author Anderson Juhasc - Desenvolvedor FrontEnd *
 * e-mail: anderson.juhasc@gmail.com				*
 *													*
 * Data do Projeto: 05/2010							*
 ****************************************************/

jQuery(function($) {
	
	// NAVEGAÇÃO GLOBAL	
		$('header nav li.linkDrop').hover( function() {
			$(this).find('a.drop').addClass('active-2');
			$('ul.dropList', this).show();
		}, function() {
			$(this).find('a.drop').removeClass('active-2');
			$('ul.dropList', this).hide();
		});
		
		
		// var cont armazena o numero de elementos li.linkDrop
		var cont = $('header nav li.linkDrop').length;
		
		$('header nav li.linkDrop').each(function () {
			$(this).css('zIndex',cont);
			cont --;
		});
	// END NAVEGAÇÃO GLOBAL
	
	// FORM BUSCA
		$('#search #busca').attr('value','Busca');
		$('#search #busca').click(function(){
			$(this).attr('value','');
		});
		$('#search #busca').blur(function(){
			if ( $(this).attr('value') === '') {
				$(this).attr('value','Busca');
			}
		});
	// END FORM BUSCA
	
	// TABLE ARTICLE
		$('#tableArticle tr:even').addClass('bgEven');
		$('.tablePublic tr:even').addClass('bgEven');
	// END TABLE ARTICLE
	
	// PAGINATION
		$('#pagination a.num:last-child').addClass('marginRZero');
	// END PAGINATION
	
	// SLIDESHOW
		// PLUGIN CYCLE
			$('.slide').cycle('fade');
		
		// PLUGIN JCAROUSEL
			$('.galeria').jcarousel({ dispItems: 4 });
			hoverOpacity('.jcarousel-skin-tango .jcarousel-prev-horizontal');
			hoverOpacity('.jcarousel-skin-tango .jcarousel-next-horizontal');
	// END SLIDESHOW
	
	// LINK'S EXTERNOS
		linkExterno($('a[href$=.pdf]'));
		linkExterno($('a[rel|=external]'));
	// END LINK'S EXTERNOS
	
	$('a.impressao').click(function() {
		window.print();
		return false;
	});
});

function ShowEvents(ano){
	$.ajax({
		url: '../functions.asp?function=getEventosByYear&ano='+ano,
		success: function(data) {
		$('#resultOldEvents').html(data);
		}
	});
}

var linkExterno = function (link) {
	link.attr('target','_blank');
}

var hoverOpacity = function(elem) {
	$(elem).hover(function() {
		$(this).css('opacity','.5');
	}, function() {
		$(this).css('opacity','1');
	});
}
