$(document).ready(function() {	
		
		 
		var int = setInterval(function() {
			
			var position = $('.active').parent().parent().next().children().children().length;
			if (position){
			
				$('.active').removeClass('active') 
				.parent().parent().next().children().children().addClass('active');
				var teste = $('.active').find('.slider-image').html();
			}
			else {
				$('.active').removeClass('active');
				$('.image_thumb:nth-child(2)').children().children().addClass('active');
			}
			;
			
			ativaActive();
		}, 7000)
		
		
	//Show Banner
	$(".main_image .desc").show(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.65 }, 1 ); //Set Opacity

	
	var imgTitle = $(this).find('.slider-image').html(); //Get Main Image URL
	var sliderTitulo = $(this).find('.titulo').html(); 	//Get HTML of block
	var sliderContent = $(this).find('.slider-content').html(); 	//Get HTML of block
	$(".main_image .titulo_imagem").html(sliderTitulo);
	$(".main_image .content_imagem").html(sliderContent);
	$(".main_image img").attr({ src: imgTitle });
	
	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li").click(function(){ 
		
		clearInterval(int);
		//Set Variables
		var imgTitle = $(this).find('.slider-image').html(); //Get Main Image URL
		var sliderTitulo = $(this).find('.titulo').html(); 	//Get HTML of block
		var sliderContent = $(this).find('.slider-content').html(); 	//Get HTML of block
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser
			$(".main_image .imagem_slider").animate({ opacity: 0 }, 100);
			
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 300 , function() {
				$(".main_image .block").animate({ opacity: 0.65,	marginBottom: "0" }, 300 );
				$(".main_image .imagem_slider").animate({ opacity: 1 }, 300);
				$(".main_image .titulo_imagem").html(sliderTitulo);
				$(".main_image .content_imagem").html(sliderContent);
				$(".main_image img").attr({ src: imgTitle });
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
	
	
	
	
	
	
	function ativaActive(){ 
		//Set Variables
		var imgTitle = $('.active').find('.slider-image').html(); //Get Main Image URL
		var sliderTitulo = $('.active').find('.titulo').html(); 	//Get HTML of block
		var sliderContent = $('.active').find('.slider-content').html(); 	//Get HTML of block
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
			//Animate the Teaser
			$(".main_image .imagem_slider").animate({ opacity: 0 }, 100);
			
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 300 , function() {
				$(".main_image .block").animate({ opacity: 0.65,	marginBottom: "0" }, 300 );
				$(".main_image .imagem_slider").animate({ opacity: 1 }, 300);
				$(".main_image .titulo_imagem").html(sliderTitulo);
				$(".main_image .content_imagem").html(sliderContent);
				$(".main_image img").attr({ src: imgTitle });
			});
	};
			
});//Close Function

