$(document).ready(function (){

/*	
        var contenitore_height = $(window).height() - 30;
        $('#contenitore').height(contenitore_height);

*/
	document.getElementsByTagName('html')[0].style.visibility = '';
	$('html').hide().fadeIn(500);
	
   if ($('#flash').length != 0) {
	   home_croll_resize();
	   $(window).resize(function(e) {
		   home_croll_resize();
	   });	
   }
   
   if ($('#testolibero_scroll').length != 0) {
	   gallery_croll_resize();
	   $(window).resize(function(e) {
		   gallery_croll_resize();
	   });	
   }
 //  CATALOGO
   if ($('#testolibero_scroll_catalogo').length != 0) {
	   gallery_croll_resize();
	   $(window).resize(function(e) {
		   gallery_croll_resize();
	   });	
   }
//   FINE CATALOGO


 //  SOTTOPRODOTTI
   if ($('#sottoprodotti flexcroll').length != 0) {
	   gallery_croll_resize();
	   $(window).resize(function(e) {
		   gallery_croll_resize();
	   });	
   }
//   FINE  SOTTOPRODOTTI
   
   function home_croll_resize()
   {
	   var flash = $("#flash");
	   var window_height = $(window).height();
       var flash_height = flash.height();
       var news_height = 0;
       
	   if (flash.length != 0)
	   {
	   	   news_height = window_height - flash_height - 170;
	   	   //console.log("Window height: "+window_height+", flash_height: "+flash_height+", news_height: "+news_height);
		   $('#calendario_scroll,#news_scroll').css("height",(news_height)+"px");
		   
		   window.fleXenv.fleXcrollInit();
	   }
   }
   
   function gallery_croll_resize()
   {
		   var window_height = $(window).height();
		   testolibero_height = window_height - 520;
		   
		   //console.log("Window height: "+window_height+", flash_height: "+flash_height+", news_height: "+news_height);
		   $('#testolibero_scroll').css("height",(testolibero_height)+"px");
		   window.fleXenv.fleXcrollInit();
	   
   }
   
   var active_item = $('#firstpane p.active');
   if (active_item.length == 1)
   {
	   var next = active_item.next();
	   
	   if (next.attr('class') == "menu_body")
	   {
		   next.css("display","block");
	   }
   }
   
});
 

