$(document).ready(function() {	
	
	$(function() {
		
		var Aux = setInterval( "slideSwitch()", 1800 );
		$(".main_image img").click(function(){  clearInterval(Aux);});
		 
	});
	
	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	
	$(".image_thumb ul li").click(function(){ 
		
		//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			
			//Animate the Teaser				
			$(".main_image img").attr({ src: imgTitle , alt: imgAlt}).animate({ opacity: 0.7 }, 0 , function() {
				$(".main_image img").animate({ opacity: 1.0 }, 250 );

			});
		}
		
		$(".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');
	});
			
	//Toggle Teaser
	$(".main_image img").click(function(){
		$(".main_image .block").slideToggle();
		$("a.collapse").toggleClass("show");
	});
	
	
	

	
});//Close Function
function slideSwitch() {
	
		//Set Variables
		var $active = $('.image_thumb ul li.active');		   
	    var $next =  $active.next().length ? $active.next() : $('.image_thumb ul li:first');
		var imgAlt = $next.find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $next.find('a').attr("href"); //Get Main Image URL
		
		
		$active.addClass('last-active');
		
		if ($next.is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser			
			$(".main_image img").attr({ src: imgTitle , alt: imgAlt}).animate({ opacity: 0.7 }, 0 , function() {
				$(".main_image img").animate({ opacity: 1.0 }, 250 );
			});
		}
		
		$active.removeClass('active'); //Remove class of 'active' on all lists
		$next.addClass('active');  //add class of 'active' on this list only
		return false;
	
	};
