var current;

var SlideList = new Class({
	initialize: function(menu, options) {
		this.setOptions(this.getOptions(), options);
 
		this.menu = $(menu);
		current = this.menu.getElement('li.selected');
 
		this.menu.getElements('li').each(function(item){
			item.addEvent('mouseover', function(){ this.moveBg(item); }.bind(this));
			item.addEvent('mouseout', function(){ this.moveBg(current); }.bind(this));
			item.addEvent('mouseover', function(){ this.changeCol(item,"#C94C14"); }.bind(this));
			item.addEvent('mouseout', function(){ this.changeCol(item,"#EBA400"); }.bind(this));
			
			//item.addEvent('click', function(event){ this.clickItem(event, item); }.bind(this));
		}.bind(this));
 
		
		if (!ie) {
			this.back = new Element('li').addClass('background').adopt(new Element('div').addClass('left')).injectInside(this.menu);
			}
		else {
			this.back = new Element('li').addClass('background2').adopt(new Element('div').addClass('left')).injectInside(this.menu);
		}
			
		this.back.fx = this.back.effects(this.options);
		if (!current) {
			this.dummy = new Element('li').injectInside(this.menu);
			this.setCurrent(this.dummy, false);
			}
		if(current) {
			this.setCurrent(current, true);	
			}
	},
 
	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);
		current = el;
		current.style.zIndex = "999";
	},
 
	getOptions: function(){
		return {
			transition: Fx.Transitions.sineInOut,
			duration: 500, wait: false,
			onClick: Class.empty
		};
	},
 
	clickItem: function(event, item) {
		if(!current) this.setCurrent(item, true);
		current = item;
		this.options.onClick(new Event(event), item);
	},
	
	changeCol: function(item, col) {		
		if (item != current && item.firstChild.style && !item.hasClass('chosen')) item.firstChild.style.color = ""+col;
		change = true;
	},
	
	moveBg: function(to) {
		if(!current) {
		this.back.fx.custom({
			left: ["0px", to.offsetLeft],
			width: ["0px", to.offsetWidth]
		});
		return;
			}	
		to.style.zIndex = "999";
		this.back.fx.custom({
			left: [this.back.offsetLeft, to.offsetLeft],
			width: [this.back.offsetWidth, to.offsetWidth]
		});
				
	}
	});

SlideList.implement(new Options);
