$(document).ready(function(){
								   
		// links com target blank
		$('a[class*=blank]').click( function() {
			window.open(this.href);
			return false;
		});
		
		//cantos arrendondados
		var fields = '';
		if ($(fields)[0]){$(fields).corner("8px")}
		
		//Menu
		$('#menutopopalmeiras ul li section').animate({opacity: 0.90}, 0)
		$('#menutopopalmeiras ul li a').not('section a').mouseenter(function(){
			$(this).addClass('activemenupalmeiras');
			$(this).parent('li').children('section').fadeIn('fast');
		});
		$('#menutopopalmeiras ul li').mouseleave(function(){
			$(this).children('section').fadeOut('fast');
			$(this).children('a').removeClass('activemenupalmeiras');	
		});	
		
		//Destaque
		$('#box-destaques .control li, #destaque_jogo a strong').animate({opacity: 0.8}, 0);
		$('#destaques article header').animate({opacity: 0.9}, 0);
		$('#box-destaques .control li a').mouseenter(function(){
			$(this).parent('li').children('div').fadeIn('fast');
		}).mouseleave(function(){
			$(this).parent('li').children('div').fadeOut('fast');
		});
		
		//destaque_drop
		$('#destaque_drop section.drop').not('.start').children('.content_drop').animate({opacity: 0}, 0);
		$('#destaque_drop section.drop header').click(function() {
			$('#destaque_drop section.drop .content_drop').animate({opacity: 0}, 0);
			$('section.drop').animate({width: 34}, 200);
			$('section.drop header').removeClass('active');
			$(this).parent('section.drop').animate({width: 626}, 200, function(){$(this).children('header').addClass('active')});
			$(this).parent('section.drop').children('.content_drop').animate({opacity: 1}, 200);
		})
		
		//bts next/prev
		$('#elenco a.bt_next, #box_jogos header .bt_next, #agenda p a.bt_next').mouseenter(function(){
			$(this).animate({right: '-=2'}, 100);
		}).mouseleave(function(){
			$(this).animate({right: '+=2'}, 100);
		});
		$('#elenco a.bt_prev, #box_jogos header .bt_prev, #agenda p a.bt_prev').mouseenter(function(){
			$(this).animate({left: '-=2'}, 100);
		}).mouseleave(function(){
			$(this).animate({left: '+=2'}, 100);
		});
		
		//elenco
		$('#elenco ul li a').mouseenter(function () {
			$(this).parent('li').addClass('hover');
		}).mouseleave(function () {
			$(this).parent('li').removeClass('hover');
		});
		
		
		function elenco_next () {
			var right = $('#elenco ul').attr('style');
			right = right.replace('left: ', '');
			right = right.replace('px', '');
			right = parseInt(right);
			if (right > -5698) {
				$('#elenco ul').animate({left: '-=814'}, 1300);
			} else {
				$('#elenco ul').animate({left: '0'}, 700);
			};
		}
		function elenco_prev () {
			var left = $('#elenco ul').attr('style');
			left = left.replace('left: ', '');
			left = left.replace('px', '');
			left = parseInt(left);
			if (left < 0) {
				$('#elenco ul').animate({left: '+=814'}, 1300);
			} else {
				$('#elenco ul').animate({left: '0'}, 200);
			};
		}
		function loop_next () {
			if( $('#elenco ul').length > 0){
				elenco_next();
				var time = setTimeout(loop_next, 5000);
			}
		}
		loop_next();
		$('#elenco .bt_next').click(function () {
			var right = $('#elenco ul').attr('style');
			right = right.replace('left: ', '');
			right = right.replace('px', '');
			right = parseInt(right);
			if (right > -5698) {
				$('#elenco ul').animate({left: '-=814'}, 1300);
			} else {
				$('#elenco ul').animate({left: '0'}, 700);
			};
		});
		$('#elenco .bt_prev').click(function () {
			var left = $('#elenco ul').attr('style');
			left = left.replace('left: ', '');
			left = left.replace('px', '');
			left = parseInt(left);
			if (left < 0) {
				$('#elenco ul').animate({left: '+=814'}, 1300);
			} else {
				$('#elenco ul').animate({left: '0'}, 200);
			};
		});
		
		
		
		
		//linha do tempo
		if ($('#time-line')[0]) {
			$('#time-line').cycle({ 
				speed:   500, 
				timeout: 6000, 
				pause:   1,
				pagerEvent: 'click',
				pager:   '#control-time-line',
				pauseOnPagerHover: true,
				pagerAnchorBuilder: function(index, DOMelement) { 
					return '#control-time-line li:eq(' + index + ') a'; 
				}
			});
		}
		/*
		$.fn.cycle.transitions.SlideZoom = function($cont, $slides, opts) { 				
			opts.before.push(function(curr, next, opts, fwd) {
				var element = null;
				var w = 584;
				var h = 386;
				if ($(curr).attr('id') == $(next).attr('id')) {
					element = '#' + $(curr).attr('id') + ' figure a img';
				} else {
					element = '#' + $(next).attr('id') + ' figure a img';
				}
				$(element).css({'width': w+'px','height': h+'px'});

				$(element).animate({
					height: h + Math.round((h*2)/100),
					width: w + Math.round((w*2)/100)
				}, 
				opts.timeout, function() {
					//$(element).css("width","584px");
					//$(element).css("height","386px");
				}
			);
			$.fn.cycle.commonReset(curr,next,opts);
		});
		};
		if ($('#destaques')[0]) {
			$('#destaques').cycle({
				fx: 'SlideZoom',  
				speed:   500, 
				timeout: 6000,
				pause:   1,
				pagerEvent: 'click',
				pager:   '.control',
				after:   onAfterDestaques,
				pauseOnPagerHover: true,
				pagerAnchorBuilder: function(index, DOMelement) {
					return '.control li:eq(' + index + ') a'; 
				}
			});
		}
		
		*/
		
		if ($('#destaques')[0]) {
			$('#destaques').cycle({
				fx: 'fade',  
				speed:   1500, 
				timeout: 5000,
				pause:   1,
				pagerEvent: 'click',
				pager:   '.control',
				after:   onAfterDestaques,
				pauseOnPagerHover: true,
				pagerAnchorBuilder: function(index, DOMelement) {
					return '.control li:eq(' + index + ') a'; 
				}
			});
		}
		
		/*$('#destaques').cycle({ 
				fx:      'fade', 
				speed:    1500, 
				timeout:  5000
			});	*/	
				
});


function onAfterDestaques(){
/*$(".Zoom").animate(
{'width':'+=5%','height':'+=5%'},
{'queue':false,'duration':4000}
)*/
}


