$(document).ready(function(){
    

	$('#mycarousel').jcarousel();
	$('#mycarousel2').jcarousel();	
	$('#mycarousel3').jcarousel({
		auto: 6,
		scroll: 1,
		wrap: 'both',
		itemLoadCallback: {
		  onBeforeAnimation: selecionarItens
		}
	});		
	
	function selecionarItens(carousel, state){
		$(".botoes-flashtv a").removeClass("item-flashtv");
		var i = $(".botoes-flashtv a").eq(carousel.first - 1);
		i.addClass('item-flashtv');				
		
		$('.botoes-flashtv a').each(function(index) {
			$(this).click(function(){
				$(".botoes-flashtv a").removeClass("item-flashtv");								   
				$('#mycarousel3').jcarousel('scroll', index)
				$(this).addClass("item-flashtv");
			});		
		});		
	}


	
	
	$("#menu ul > li").hover(function(){
		$(this).find("> ul").stop(true, true).slideDown('fast');
	}, function(){
		$(this).find("> ul").stop(true, true).slideUp('fast');		
	})
	
	
	
	//GALERIA FOTOS
	
	$(".thumbs li a").click(function(){
		var path = $(this).parent().find('a').attr("rel");
                var titulo = $(this).parent().find('input[name=titulo_video]').val();
                var descricao = $(this).parent().find('input[name=descr_video]').val();
		$(".imagem-grande img").attr("src", path);
                $(".titulo-produto").html(titulo);
                $(".descricao-video").html(descricao);
	})
	
	//	

	
	//GALERIA VIDEOS
	
	$(".videos li a").click(function(){
		var path = $(this).parent().find('a').attr("rel");
		$(".imagem-grande iframe").attr("src", path);
	})
	
	//	
	$("#conteudo .destaques:nth-child(3n + 1)").addClass('zera-margin-right');
	
	$(".destaques-listagem-personalizada ul li:nth-child(2n + 1)").addClass('flutuar-esquerda');
		
	//Troca galeria
	
	$(".aba-videos").hide();
	$(".aba-fotos").show()
	
	$(".videos").click(function(){
		$(".fotos").removeClass("selecionado");
		$(".arquivos").removeClass("selecionado");		
		$(this).addClass("selecionado");		
		$(".aba-videos").show()
		$(".aba-fotos").hide();		
		$(".aba-arquivos").hide();		
	})

	$(".fotos").click(function(){
		$(".videos").removeClass("selecionado");
		$(".arquivos").removeClass("selecionado");		
		$(this).addClass("selecionado");							   
		$(".aba-fotos").show();
		$(".aba-videos").hide();				
		$(".aba-arquivos").hide();
	})
	
	$(".arquivos").click(function(){
		$(".fotos").removeClass("selecionado");
		$(".videos").removeClass("selecionado");
		$(this).addClass("selecionado");							   
		$(".aba-arquivos").show();
		$(".aba-fotos").hide();
		$(".aba-videos").hide()				
	})	
	
	$(".aba-videos ul li a").click(function(){
		var i = $(this).attr("rel");
		$(".imagem-grande").html("<iframe width='633' height='338' frameborder='0' allowfullscreen='' src='http://www.youtube.com/embed/"+ i +"'></iframe>");
	})
	
	$(".aba-fotos ul li a").click(function(){
		var i = $(this).attr("rel");
		$(".imagem-grande").html("<img alt='' src='"+i+"' />");
	})	
        
        
        
        $(".orcamento").click(function(){
            
            var titulo = $(".titulo").html();
            
            window.open('contato.php?assunto=1&titulo='+titulo, '_self');
        })
})
