var MenuItem = new Class({
	id:null,
	is_select:false,
	curtain:null,
	
	Extends:Movable,
	initialize:function(cont, curtain) {
		this.parent(cont);
		
		this._parent = new Movable(this.cont.getParent());

		this.curtain = curtain;
		this.property = 'margin-top';
		this.src = 0;
		this.dest = - this._parent.cont.getSize().y;
		this.fx = new Fx.Tween(this.cont.getFirst('div'), {duration: 200, link:'cancel', transition:Fx.Transitions.Sine.easeIn});
		
		this._parent.property = 'width';
		this._parent.src = 235;
		this._parent.dest = this._parent.cont.getParent().getSize().x;
		this._parent.fx = new Fx.Tween(this._parent.cont, {duration: 500, link:'cancel', transition:Fx.Transitions.Sine.easeIn});
		
		var reg=new RegExp("[0-9]{4}");
		this.cat = null;
		if(this.cont.href.search(reg) != -1) this.cat = this.cont.href.match(reg);
		this.cat = this.cat != null ? this.cat[0] : null;
		
		this.gets = this.cont.get('href').split('?')[1];
		
		this.bound_click = this.clickHandler.bindWithEvent(this);
		this.bound_over = this.overHandler.bind(this);
		this.bound_out = this.outHandler.bind(this);

		this.retrieveEvents();
		this.cont.addEvent('click', this.bound_click);
		
		if(this._parent.cont.hasClass('select')) {
			this.cont.removeEvents({
				mouseenter: this.bound_over,
				mouseleave: this.bound_out
			});
			this.fx.set(this.property, this.dest);
			this.is_open = true;
			this.is_select = true;
		}
	},
	
	clickHandler:function(e) {
		if(this.curtain != null) e.stop();
		if(!this.is_select) this.clickHandlerCallback();
	},
	
	clickHandlerCallback:function() {
		this.curtain.my_menu.open();
	},
	
	overHandler:function() {
		this.open();
	},
	
	outHandler:function() {
		this.close();
	},
	
	removeEvents:function() {
		this.cont.removeEvents({
			mouseenter: this.bound_over,
			mouseleave: this.bound_out
		});
	},
	
	retrieveEvents:function() {
		this.cont.addEvents({
			mouseenter: this.bound_over,
			mouseleave: this.bound_out
		});
	},
	
	maximize:function()  {
		if(this._parent.cont.hasClass('movable')) {
			this.cont.removeEvents({
				mouseenter: this.bound_over,
				mouseleave: this.bound_out
			});
			this._parent.open();
		}
		this.open();
	},
	
	minimize:function() {
		if(this._parent.cont.hasClass('movable')) {
			this.cont.addEvents({
				mouseenter: this.bound_over,
				mouseleave: this.bound_out
			});
			this._parent.close();
		}
		this.close();
	}
});
