var idCorrente;
var idThumb=0;
var sommaThumbs=0;

function do_init(){

	accordionMenu(-1);
	if ($('menu')){
		
		categoriesMenuOpen();
	
	}	
	
	opacityImages();
	
	

	if($('contAllTabs')){
		$$('img.thumbs').each(function(img){
		
			var widthThumbs=(img.offsetWidth)+4;
			
			if(img.id!=idThumb){
				
				sommaThumbs=sommaThumbs+widthThumbs;
				
				idThumb=img.id;
				
			}
					
		});
		
		$('contAllTabs').setStyle('width',sommaThumbs+'px');
			
		
		if(sommaThumbs>($('menuTabs').offsetWidth)){
			
			$('prevBtnThumbs').setStyle('display','block');
			$('nextBtnThumbs').setStyle('display','block');
			$('menuTabs').setStyle('margin-left','15px');
			scorriMenuThumbs();
		
		}
	}
}

function opacityImages(){
	
	$$('img.thumbs').each(function(img){
	
		img.onmouseover=function(){ this.setStyle('opacity',0.5); }

		img.onmouseout=function(){ this.setStyle('opacity',1); }

	});
	
}


function scorriMenuAnni() {

	var myScroller = new Scroller('menu', {area: 50, velocity: 0.2});

	myScroller.start();

}

/*****************************************************************/
/************************** SCORRI THUMBS ************************/
/*****************************************************************/
function scorriMenuThumbs() {

	var myScroller = new Scroller('menuTabs', {area: 50, velocity: 0.2});

	myScroller.start();
	
	
	
}


function categoriesMenuOpen(){
	
	var menuHeight=($('menu').offsetHeight);
	
	if(menuHeight<300){
		
		$('menuContainer').setStyle('height',menuHeight+'px');
		var imgLogoTop=(menuHeight+3);
		
		$('contArrows').setStyle('padding','0px');
		$('arrowUp').setStyle('display','none');
		$('arrowDown').setStyle('display','none');

	}else{
		
		$('menuContainer').setStyle('height','295px');
		var imgLogoTop=305;
		$('arrowDown').setStyle('top','307px');
		scorriMenuCategorie();
		
	}
	
	$('titoloMenuCategorie').addEvents({
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.set('tween', {
				duration: 1000,
				transition: Fx.Transitions.Expo.easeOut // This could have been also 'bounce:out'
			}).tween('height', (menuHeight+25)+'px');
			$('loghettoCat').set('tween',{duration: 750}).tween('top',imgLogoTop+'px');
		},
		'mouseleave': function(){
			// Resets the tween and changes the element back to its original size
			this.set('tween', {}).tween('height', '20px');
			$('loghettoCat').set('tween').tween('top','0px');
		}
	});

}

function scorriMenuCategorie() {
	var myScroller = new Scroller('menuContainer', {area: 50, velocity: 0.2});
	
	myScroller.start();

}


