/****************************
MainMenu
Version: 1.0
@author Alvaro Talavera (alvarotala@gmail.com)
*****************************/

var MainMenu = Class.create({
  
  initialize: function(speed) {
	this.speed = speed;
	this.nav = $$('#nav li.nav_i');
	this.effect = new Array();
	
	this.set_listeners();
  },

  set_listeners: function() {
	var obj = this;
	this.nav.each(function(li) {		
		li.observe('mouseover', function(event){
		  obj.hover(li, 1);
		});
		
		li.observe('mouseout', function(event){
		  obj.hover(li, 0);
		});
	});
  },

  hover: function(li, show) {
	var id = li.previousSiblings().length;
	var a = li.down('a', 0);
	var direction = (show==1 ? -40 : 0);
	if(this.effect[id] != undefined) {
		this.effect[id].cancel();
	}
	this.effect[id] = new Effect.Move(a, { x: 0, y: direction, mode: 'absolute', duration: this.speed });
  }

});