function link_banner() {
	var $b1 = $('.link_b1');
	var $b2 = $('.link_b2');
	var $b3 = $('.link_b3');
	var $b4 = $('.link_b4');
	
	
	$b1.click(function() {
		window.open("http://www.youtube.com/watch?v=DHg6ZFidwDU");
	});
	
	$b2.click(function() {
		window.location = "http://www.borgesalimentos.com.br/produtos/aromaticos";
	});
	
	$b3.click(function() {
		window.location = "http://www.borgesalimentos.com.br/produtos/vinagres";
	});
	
	$b4.click(function() {
		window.location = "http://www.borgesalimentos.com.br/public/files/apostila.pdf";
	});
}

function banner_effect(){
	var $next = $('a.seta.frente');
	var $prev = $('a.seta.volta');
	var $movie = $('a.seta');
	var $banner = $('.banner .mask, .banner a.seta');
	
	$movie.css({opacity: 0.8});
	
	$next.mouseenter(function(){
		$(this).css({opacity: 1});
	}).mouseout(function(){
		$(this).css({opacity: 0.8});
	});
	
	$prev.mouseenter(function(){
		$(this).css({opacity: 1});
	}).mouseout(function(){
		$(this).css({opacity: 0.8});
	});
	
	$banner.mouseenter(function(){
		$movie.css({display: 'block'});
	}).mouseout(function(){
		$movie.css({display: 'none'});
	});
}

function banner(){	
	$('#content').cycle({
		fx: 'growY', 
		speed: 700,
		timeout: 5000,
		pager: '#nav-banner',
		activePagerClass:'active',
		pagerAnchorBuilder: pagerFactory			
	});	
	function pagerFactory(idx, slide) {
		return '<li><a class="position'+(idx+1)+'" href="#" title="' + (idx+1) + '">' + (idx+1) + '</a></li>';
	};
	
	$('.banner > .frente').click(function(){
		var indice = $('.activeSlide').parent().prevAll().size();
		if(indice == $('#nav-banner li').size() - 1){
			indice = -1;
		}
		$('.banner #content').cycle(indice + 1);
	});
	$('.banner > .volta').click(function(){
		var indice = $('.activeSlide').parent().prevAll().size();
		if(indice == 0){
			indice = $('#nav-banner li').size();
		}
		$('.banner #content').cycle(indice - 1);
	});
}


var hoverAnim = {
	 init: function() {
		 var project = $('#list-produtos li');
		 var projectTxt = project.children('.hover');
		 
		project.css({
			display: 'block',
			height: 231 +'px',
			width: 215 +'px'
		});
		
		 project.children('.hover').css({left: '0px'})
		 project.children().children('.hover-bg').fadeTo(1, 0.0)
		 project.children().children('.hover-content').css({left: '237px'})
		
		 project.hover(
			 function () {
				// $('.hover-bg').css({left: 0, top: 0, position: 'absolute'});
				 $(this).children().children('.hover-content').css({left: '237px'});
				 $(this).children('.hover-bg').stop().fadeTo(600, 0.8);
				 $(this).children().children('.hover-content').stop().animate({left: '0px'} , { queue: false, duration: 450, easing: 'easeOutQuint' });
			 },
			 function () {
				 $('.hover-bg').css({left: 0, top: 0, position: 'absolute'});
				 $(this).children('.hover-bg').stop().fadeTo(800 , 0.0);
				 $(this).children().children('.hover-content').stop().animate({left: '-237px'} , { queue: false, duration: 300, easing: 'easeOutQuint' });
			 }
		 );
	
	 }
};


$(function(){

	//link_banner();
	banner();
	banner_effect();
	jQuery('#list-produtos').jcarousel();
	hoverAnim.init(); 
	
});
