$(document).ready(function() {

	
	$('.menuConheca, .menuProdutos').hover(function(){	
		$(this).find('div').stop().animate({"height": "264px"}, "fast");

	}, 
	function(){
		$(this).find('div').stop().animate({"height": "0px"}, "fast");

  	});
  	/*
  	$('.accordionContent').accordion({ autoHeight: true });
	*/
	
	///////////ACCORDION////////////////
	
	$('.acc_container').hide(); //Hide/close all containers
	$('.acc_trigger:first').addClass('active').next().show();
	
	
	//On Click
	$('.acc_trigger').click(function(){
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
			$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
		}
		return false; //Prevent the browser jump to the link anchor
	});
	
	/////////////////////////////////////
	
	$('.bkgArea').css('height', function(){
		var tamanho = $(document).height();
		return tamanho;
	});
	$(window).resize(function() {
	 	 $('.bkgArea').css('height', function(){
			var tamanho = $(document).height();
			return tamanho;
		});
	});
	$('.bkgAreaProduto').css('max-height', '1100px');
	
	$(".icnFeatures").tipTip({
		maxWidth		: 	"auto",
		edgeOffset		:	3,
		delay			:	0
	});

	$('.pordutosDownload').hover(function(){
		$(this).find('div').css('display','block');
		$(this).css('margin','-10px');
		$(this).css('padding','-10px');
		$(this).find('img').css('border','3px solid #F35C21');
	}, 
	function(){
		$(this).find('div').css('display','none' );
		$(this).css('margin','0' );
		$(this).find('img').css('border','2px solid white');

  	});
  	
  	$(".videoProdutoThumb").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'centerOnScroll'	: 'true',
			'width'			: 640,
			'height'		: 385,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'				: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

		return false;
	});
  	
  	
	$('.bannerProdutos').find('div').after('<div id="nav" class="navCycle">').cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    timeout: 6000, 
	    pager:  '#nav'	
	});
	
	$('.bgBannerHome div').cycle({ 
	    fx:		'fade',
	    speed:  'slow',
	   	next:   '#nextBannerHome', 
    	prev:   '#prevBannerHome',
	   	timeoutFn: calculateTimeout, 
	   	pagerEvent: 'mouseover', 
    	pauseOnPagerHover: true, 
	    pager:  '#nav',
    	pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
         return '#nav li:eq(' + (idx) + ') div';
    	}  
	});
	
	$("a[rel=example_group]").fancybox({
				'centerOnScroll'	: 'true',
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
	});
	
	$(".tabelaTamanhos, .produtoDetalhes").fancybox({
        	'centerOnScroll'	: 'true',
        	'autoDimensions'	: 'false',
        	'autoScale'			: 'false',
			'width'         	: 960,
			'height'        	: 400,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade'
		}
	);
	
	
	$(".btn360").fancybox({
        	'centerOnScroll'	: 'true',
        	'padding'           : 0,
			'width'         	: 920,
			'height'        	: 520,
			'type'				: 'iframe',
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'scrolling'			: 'no'
		}
	);
	
	
	
	
	
	// SLIDER
	$(document).ready(function(){
	  $("#content-slider").slider({
		change: handleSlider,
		slide: handleSlider,
		orientation: 'horizontal',
		handle: ".ui-slider-handle"
	  });
	  
	  $("#content-slider2").slider({
		change: handleSlider,
		slide: handleSlider,
		orientation: 'horizontal',
		handle: ".ui-slider-handle"
	  });
	});		
	sliderAutoWidth();
	
	
$("#aplicaZoom").click(function(){
		ativaZoom();
	});

});


var ativo = 0;

function ativaZoom(){
	if(ativo == 1){
		$('.jqzoom').unbind();
		$('.jqzoom').css("cursor","default");
		$('.produtoZoom').css("backgroundPosition","0 0");
		ativo = 0;
	} else {
		
	     ativo = 1;
		$(".jqzoom").jqueryzoom({
	
			xzoom: 270,
			yzoom: 544,
			position: "left",
	        preload: 1,
			lens:1
		});
		$('.jqzoom').css("cursor","move");
		$('.produtoZoom').css("backgroundPosition","0 -51px");  
		
	}
}

function sliderAutoWidth() {
	var numOf = $("#content-holder > li").length;
	$("#content-holder").width(numOf * 240);
	
	var numOf2 = $("#content-holder2 > li").length;
	$("#content-holder2").width(numOf2 * 180);
	
	
	var slideA = $("#content-holder").height();
	if(numOf < 4){
		$("#content-slider").css("display","none");
	}
	else{
		$("#content-slider").css("display","block");

	}

	
}
// SLIDER handler
function handleSlider(e, ui)
{
	var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
	$("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
	
	var maxScroll = $("#content-scroll2").attr("scrollWidth") - $("#content-scroll2").width();
	$("#content-scroll2").attr({scrollLeft: ui.value * (maxScroll / 100) });

}

var timeouts = 7000; 
function calculateTimeout(currElement, nextElement, opts, isForward) { 
    //INSERIR FUNCTION DE FADE BLACK// 
    return timeouts; 
} 




