/*var SlideList = new Class({
	initialize: function(menu, options) {
		this.setOptions(this.getOptions(), options);
		
		this.menu = $(menu), this.current = this.menu.getElement('li.current');
		var larghezzaDiv = $(menu).getParent().getStyle('width');
		var numlinks = 0;
		this.menu.getElements('li').each(function(item){
			item.addEvent('mouseover', function(){ this.moveBg(item); }.bind(this));
			item.addEvent('mouseout', function(){ this.moveBg(this.current); }.bind(this));
			item.addEvent('click', function(event){ this.clickItem(event, item); }.bind(this));
			if (item.getChildren().getTag()=="a") {
				numlinks++;
			};
		}.bind(this));
		
		this.menu.getElements('li').each(function(item){
			if (item.getChildren().getTag()=="a") {
				$(item).setStyle('width',parseFloat(larghezzaDiv) / numlinks);
				$(item).getChildren().setStyle('width',parseFloat(larghezzaDiv) / numlinks);
			};
		});
		
		
		
		this.back = new Element('li').addClass('background').adopt(new Element('div').addClass('left')).injectInside(this.menu);
		this.back.fx = this.back.effects(this.options);
		if(this.current) this.setCurrent(this.current);
	},
	
	setCurrent: function(el, effect){
		this.back.setStyles({left: (el.offsetLeft)+'px', width: (el.offsetWidth)+'px'});
		(effect) ? this.back.effect('opacity').set(0).start(1) : this.back.setOpacity(1);
		this.current = el;
	},
	
	getOptions: function(){
		return {
			transition: Fx.Transitions.sineInOut,
			duration: 500, wait: false,
			onClick: Class.empty
		};
	},

	/*clickItem: function(event, item) {
		if(!this.current) this.setCurrent(item, true);
		this.current = item;
		this.options.onClick(new Event(event), item);
	},*/

	/*moveBg: function(to) {
		if(!this.current) return;
		this.back.fx.custom({
			left: [this.back.offsetLeft, to.offsetLeft],
			width: [this.back.offsetWidth, to.offsetWidth]
		});
	}
});*/


var SlideList = new Class({
	Implements:[Options,Events],
	
	options:{
		transition:Fx.Transitions.Sine.easeInOut,
		duration: 500,
		wait: false,
		onClick: $empty
	},

	initialize: function(menu, options) {
		this.setOptions(options);
		
		this.menu = $(menu), this.current = this.menu.getElement('li.current');
		
		var larghezzaDiv = $(menu).getParent().getStyle('width');
		var numlinks = 0;
		
		$$(this.menu.getElements('li')).addEvents({
			'mouseover':this.moveBg.bind(this),
			'mouseout':this.moveBg.bind(this,false),
			'click':this.clickItem.bind(this)
			
			
			
		});
		
		numlinks = $$(this.menu.getElements('li a')).length;
												  
		

		$$(this.menu.getElements('li a')).each(function(item){

			$(item).setStyle('width',parseFloat(larghezzaDiv) / numlinks);
			$(item).getChildren().setStyle('width',parseFloat(larghezzaDiv) / numlinks);

		});
		
		
		this.back = new Element('li',{
			'class':'background',
			morph:this.options
		}).adopt(new Element('div',{'class':'left'})).inject(this.menu);
		if(this.current) this.setCurrent(this.current);
	},
	
	setCurrent: function(el, effect){
		this.back.setStyles({left: (el.offsetLeft), width: (el.offsetWidth)});
		(effect) ? this.back.get('morph').start({'opacity':[0,1]}) : this.back.setStyle('opacity',1);
		this.current = el;
	},

	clickItem: function(event) {
		var item = $(event.target);
		this.setCurrent(item, true);
		this.fireEvent('onClick',[new Event(event), item]);
	},

	moveBg: function(to){
		if(!this.current) return;
		if(to){
			to = $(to.target);
		}else{
			to = this.current;
		}
		this.back.get('morph').start({
			left: to.offsetLeft,
			width: to.offsetWidth
		});
	}
});


/*SlideList.implement(new Options);*/




