
/* - carousel.js - */
// http://www.regione.emilia-romagna.it/portal_javascripts/carousel.js?original=1
jQuery(function($){setTimeout(function(){var resizeCarousel=function(carousel,scrollable,elems){var base_height=Math.max.apply(null,$(elems).map(function(){return $(this).height()}).get());if(base_height<$(carousel).height()){base_height=$(carousel).height()-$(".navi").outerHeight(true)}
$(elems).height(base_height);var scrollable_height=$(elems).eq(0).outerHeight(true);$(scrollable).height(scrollable_height);var outer_height=$(scrollable).outerHeight(true)+$(".navi").outerHeight(true);var $carousel=$(carousel);if($carousel.height()<outer_height){$carousel.height(outer_height).trigger('resized.carousel',[outer_height])}};$(".toolBar").hide();var carousels=$(".carousel");var interval=3000;carousels.each( function(i){var carousel=this;var scrollable=$(this).find(".scrollable").eq(0);var elems=$(scrollable).find('.tileItem');scrollable_width=$(scrollable).width();for(i=0;i<elems.length;i++){$(elems[i]).css({width:scrollable_width+'px'})};setTimeout(function(){resizeCarousel(carousel,scrollable,elems)},0);$(scrollable).find("img").load(function(event){resizeCarousel(carousel,scrollable,elems)});if(parseInt($(scrollable).attr('rel'))>0){interval=parseInt($(scrollable).attr('rel'))}});var ap=(carousels.length==1)?true:false;var api=$("div.scrollable").scrollable({size:1,clickable:false,loop:true}).circular().autoscroll({autoplay:ap,steps:1,interval:interval}).navigator({api:true});$(".carousel").hover(
function(){$(this).find(".toolBar").eq(0).slideToggle('fast').show()},
function(){$(this).find(".toolBar").eq(0).slideToggle('fast').hide()});$(".carousel .pause").click(function(){api.pause()})},(($.browser.safari||$.browser.webkit)?1250:500))})

