var SlideList = new Class({
	initialize: function(menu, options) {
 
		this.menuContainer = $('menu-container');
		this.menu = $(menu), this.current = $('current');
 
		this.menu.getElements('li').each(function(item){
	//		item.addEvent('mouseenter', function(){ this.moveBg(item); }.bind(this));
			item.addEvent('mouseenter', function(){ this.setBg(item); }.bind(this));
		}.bind(this));
 
	//	this.menuContainer.addEvent('mouseleave', function(){ if(this.current) this.moveBg(this.current); else this.hideBg();}.bind(this));
		this.menuContainer.addEvent('mouseleave', function(){ if(this.current) this.setBg(this.current); else this.hideBg();}.bind(this));
		
		this.back = new Element('li').addClass('background').adopt(new Element('div').addClass('left')).injectInside(this.menu);

		if(this.current) this.setBg(this.current);
	},
 
 	hideBg: function(){

		this.back.setStyle('display','none');
	
	},
 
	moveBg: function(to) {
		
		if (this.back.getStyle('display')=='none') this.back.setStyle('display','list-item');
		
		this.back.fx = new Fx.Tween(this.back,{link:'cancel'});		
		this.back.fx.start('left', [this.back.offsetLeft, to.offsetLeft]);
		
		this.back.fx = new Fx.Tween(this.back,{link:'cancel'});
		this.back.fx.start('width', [this.back.offsetWidth, to.offsetWidth]);
		
	},
	
	setBg: function(to) {
			
		if (this.back.getStyle('display')=='none') this.back.setStyle('display','list-item');
		
		this.back.setStyle('left',to.offsetLeft);
		this.back.setStyle('width',to.offsetWidth);
			
	}
});
