function do_init(){

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

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

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

	});
	
}


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();

}


function abilitaDisabilitaScroll(){
	

	if ($('lyr').offsetHeight>$('wn').offsetHeight){
		
		wndo = new oggettoScroll('wn', 'lyr');
		oggettoScroll.scrdy=true;
		wndo.setUpScrollbar(('dragBar'), ('track'), 'v', 1, 1);
		oggettoScroll.GeckoTableBugFix('wn');
		
		$('wn').setStyles({width: '718px',clip: 'rect(0px, 718px, 330px, 0px)'});
		$('lyr').setStyle('width','718px');
		$('up').setStyle('visibility','visible');
		$('track').setStyle('visibility','visible');
		$('down').setStyle('visibility','visible');
	
		
		var lyrScroll=20;

		var lyrHeight=$('lyr').offsetHeight;
		var wnHeight=$('wn').offsetHeight;
		var lyrMax=(lyrHeight-wnHeight);
		
		var dragHeight=$('dragBar').offsetHeight;
		var trackHeight=$('track').offsetHeight;
		
		var dragMax=(trackHeight-dragHeight);

		var dragScroll=parseInt((dragMax*lyrScroll)/lyrMax);
		
		var dragStartPos=$('dragBar').offsetTop;
		
		//alert(dragStartPos);
		
		$('lyr').addEvent('mousewheel', function(e){
		
			var lyrPos=$('lyr').offsetTop;
			
			var dragPos=$('dragBar').offsetTop;
			
			//alert(dragPos + '-->' + dragScroll);
	
				if(e.wheel<0){ 
					
					if(lyrPos>-lyrMax){
						$('lyr').setStyle('top',(lyrPos-lyrScroll)+'px');
						if(dragPos<=dragMax){
							$('dragBar').setStyle('top',(dragPos+dragScroll)+'px');
						}
					}
					
				}else{
	
					if(lyrPos<0){
						$('lyr').setStyle('top',(lyrPos+lyrScroll)+'px');
					
						if(dragPos>0 && (dragPos-dragScroll>=0)){
							$('dragBar').setStyle('top',(dragPos-dragScroll)+'px');
						}
	
					}
				}
		});

	}else{
		
		$('wn').setStyles({width: '743px',clip: 'rect(0px, 718px, 330px, 0px)'});
		$('lyr').setStyle('width','743px');
		$('up').setStyle('visibility','hidden');
		$('track').setStyle('visibility','hidden');
		$('down').setStyle('visibility','hidden');
	
	}
	

	
}

