// JavaScript Document

$(document).ready(function(){
	$('.imgs').cycle({
		fx: 'fade', 
		speed: 1000,
		timeout: 13000,
		before: timeB,
		after: timeA,
		pager: '.nave',
		activePagerClass:'active',
		pagerAnchorBuilder: pagerFactory		
	});	
	function pagerFactory(idx, slide) {
		return '<li>'+(idx+1)+'</li>';
	};
	function timeB(currSlideElement, nextSlideElement, opts, forwardFlag) {
		/*$('.imgs li > div').hide();*/
		$('.imgs li').removeClass('ativo');
		$(this).addClass('ativo');
		$('.imgs li.ativo > div').width(0);
		
		$('.temp div').stop();
		$('.temp div').css('width','0px');
	};
	function timeA(currSlideElement, nextSlideElement, opts, forwardFlag) {
		/*$('.imgs li > div').show();*/
		$('.imgs li.ativo > div').width(0);
		$('.imgs li.ativo > div').animate({ width: 431},1000);
		$('.temp div').stop(false, false).animate({ width: 100 + '%'},opts.timeout -1000 ,function(){$('.temp div').css('width','0px');});
	};
});
