window.addEvent('load', function() {

	//Gestisco il menù animato nel menù a SX nei contenuti
	//Metto in una variabile l'array della lista
	
	if ($('menu')) {
	
		var listTabs = $('menu').getChildren('ul');
		listTabs = listTabs[0].getChildren('li');
	
		//Creo un evento per OGNI elemento LI
		listTabs.each(function(el){
		
		    //Variabile che contiene l'altezza base delle tabs
		    var tabsHeight = 22;
		    //Se esiste un qualsiasi primo elemento all'interno di LI esegue la funzione:
		    if(el.getFirst('div')){
		        //Riattribuisco a tabsHeight l'altezza degli elementi interni a LI
		        //Utilizzo il getFirst perchè restituisce UN solo elemento. getChildren restituisce un array e avrei
		        //dovuto utilizzare un each()
			    tabsHeight = el.getFirst('div').getSize().y;
		        //Se l'elemento corrente ID "currentOpen" gli setto l'altezza fissa e lascio aperto il tabs
		        if(el.get('id') == 'currentOpen'){ el.setStyle('height', tabsHeight) }
		    }
		    
			// Se l'elemento corrente è "currentOpen" non assegno mouseenter e mouseleave
		    if(el.get('id') != 'currentOpen'){
			    el.addEvent('mouseenter', function(){
				        //Setto a LI l'altezza dell'elemento al suo interno
				        this.set('tween', {transition: Fx.Transitions.Sine.easeOut});
				        this.set('tween', {duration: 800});
				        this.tween('height', tabsHeight);
			    })
			    el.addEvent('mouseleave', function(){
				        this.tween('height', '22px');
			    })
			}
		
		});
		
	}
	

// Chiusura del LOAD
});

window.addEvent('domready', function() {

// Taglio le parole lunghe con i CSS3 :D
if($('contentText')){
	$('contentText').setStyle('word-wrap', 'break-word');
}


//Gestisco il menù a comparsa nella navbar
var menu = $$('#navbar ul li');

menu.each(function(el){
				   	
	var childs = el.getChildren('ul');

	if(childs.length > 0){
		el.addEvent('mouseenter', function(){
			childs[0].setStyle('display', 'block');
		});
		
		el.addEvent('mouseleave', function(){
			childs[0].setStyle('display', 'none');
		});
	}

});


//////////////////////////////////////////////////////////////////////////////////////////////////////// Gestione Pagine Generiche e Opacity

$$('#genericContent img').addEvent('mouseenter', function(){
	this.set('tween', { duration : 300} );
	this.tween('opacity', 0.4);
	}).addEvent('mouseleave', function(){
		this.set('tween', { duration : 1000} );
		this.tween('opacity', 1);
		})

//////////////////////////////////////////////////////////////////////////////////////////////////////// Gestione Tips
 
    var tippi = new Tips($$('.tipsBox'), {
            initialize:function(){
                this.tip.setStyle('opacity',0);
        },
            onShow: function() {
                this.tip.set('tween', {duration: 50});
                this.tip.tween('opacity', 0.9);
        },
            onHide: function() {
                this.tip.set('tween', {duration: 300});
                this.tip.tween('opacity', 0);
        }
    });

// Chiusura del DOMREADY
});
