var menumarker = new Class( {
	defaultOptions: function() {
		return {
			container: $('menu'),
			elements: $$('#menu li'),
			marker: $('marker'),
			display: 0,
			color: '#fff'
		}
	},
	initialize: function(options) {
		this.setOptions(this.defaultOptions(), options);
		this.defaultcolor = this.options.marker.getStyle('background-color');
		this.timer=null;
		
		this.options.elements.each( function ( el, i ) {
			if ( el.hasClass('current') ) this.options.display = i;
			el.addEvent('mouseenter', function( ) {
				this.allerA( i, this.options.color );			
			}.bind(this) );
		}.bind(this) );
		
		/*window.document.addEvent( 'mouseover', function( ) {
			if(this.timer==null) {
				this.timer = function () {
					this.allerA( this.options.display, this.defaultcolor );
					this.timer=null;
				}.bind(this).delay(8000);
			}
		}.bind(this) );*/
		
		this.allerA( this.options.display, this.defaultcolor );
		
	},
	allerA: function( i, color ) {
		if ( !this.options.elements[i] ) return;

		this.target = new Array;
		this.target[0] = this.options.marker;
		var obj = {};
		var x = this.options.elements[i].getCoordinates().left - this.options.elements[0].getCoordinates().left;
		x += this.options.container.getStyle('margin-left').toInt();
		obj[0] = { 'margin-left':+x+'px', 'width': this.options.elements[i].getCoordinates().width+'px'/*, 'background-color' : color*/ };
			
		this.fx = new Fx.Elements( this.target, {duration: 300, 'wait': false, transition: Fx.Transitions.linear} );
		this.fx.start(obj);
	}
} );

menumarker.implement(new Events); // Implements addEvent(type, fn), fireEvent(type, [args], delay) and removeEvent(type, fn)
menumarker.implement(new Options);// Implements setOptions(defaults, options)

window.addEvent( 'domready', function() { new menumarker()} );