function slideSwitchTimed() {
  $active = $('.image_thumb ul li.active').next();
  if ( $active.length == 0 ) $active = $('.image_thumb ul li:first'); //goes back to start when finishes
  $active.trigger("rodatempo");
}
$(document).ready(function() {	
	//Show Banner
        	$(".newsFancyBox").fancybox({
				ajax : {
				    type	: "POST",
				    url: "news_details.php",
					'titleShow'     : false,
					'transitionIn'	: 'elastic',
					'transitionOut'	: 'elastic',
					'width'				: '500px',
					'height'			: '400px',
					'autoScale'     	: false

				}
			});
		
    $(document).pngFix(); 
	
	$(".main_image .desc").hide(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity

	
	$(".main_image .block").click(function(){
	  if ($(this).find('a').attr("href") != '') {
		document.location = $(this).find('a').attr("href");
	  }
	});
	$(".main_image img").click(function(){
	  if ($(this).attr("title") != '') {
		document.location = $(this).attr("title");
	  }
	});
	
	$(".image_thumb ul li img").click(function(){
	  	  if ($(this).find('a').attr("href") != '') {
		document.location = $(this).find('a').attr("href");
	  }
	});
	
	//Click and Hover events for thumbnail list
		$(".image_thumb ul li").bind("rodatempo", function(){ 
			//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("title"); //Get Main Image URL
		var imgCodLink = $(this).find('img').attr("title"); //Get Link
		var imgDesc = $(this).find('.block').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 img").animate({ opacity: 0}, 250 );
//            $(".main_image img").attr({ src: imgTitle, alt: imgAlt }).animate({ opacity: 1 }, 250);

							
            // });			
			//$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
			//	$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
			//	$(".main_image img").attr({ src: imgTitle , alt: imgAlt }).animate({ opacity: 1 }, 250);
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt , title: imgCodLink}).css("cursor","pointer").animate({ opacity: 1}, 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');
		clearInterval(playSlideshow);
	    $(this).trigger("rodatempo");		
		var imgAlt2 = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle2 = $(this).find('a').attr("title"); //Get Main Image URL
		var imgCodLink2 = $(this).find('img').attr("title"); //Get Link
		var imgDesc2 = $(this).find('.block').html(); 	//Get HTML of block
		var imgDescHeight2 = $(".main_image").find('.block').height();	//Calculate height of block			
			//$(".main_image img").attr({ src: imgTitle2 , alt: imgAlt2}).css("cursor","pointer").animate({ opacity: 1}, 250 );
		//	$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight2 }, 250 , function() {
	//			$(".main_image .block").html(imgDesc2).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle2 , alt: imgAlt2, title: imgCodLink2 }).animate({ opacity: 1 }, 250);
		//	});

			}, function() {
		$(this).removeClass('hover');
		playSlideshow = setInterval( "slideSwitchTimed()", 3000 );
	});
//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li").click(function(){ 
	    clearInterval(playSlideshow);
	    $(this).trigger("rodatempo");
	});			
	//Toggle Teaser
	$("a.collapse").click(function(){
		$(".main_image .block").slideToggle();
		$("a.collapse").toggleClass("show");
		return false;
	});
playSlideshow = setInterval( "slideSwitchTimed()", 3000 );
 
});//Close Function


