// Javascript navigation menu

   var SlideList = new Class({
   initialize: function(menu, options) {
   this.setOptions(this.getOptions(), options);
    
   
   
	// set current link dependent on the url of the page
	url = window.location.href;
	current_id = "nav_home";
	if (url.search("yogawithhannah.com/index.php") != -1) {
		current_id = "nav_home";
	}
	else if (url.search("yogawithhannah.com/me") != -1) {
		current_id = "nav_me";
	}
	else if (url.search("yogawithhannah.com/classes") != -1) {
		current_id = "nav_classes";
	}
	else if (url.search("yogawithhannah.com/timetable") != -1) {
		current_id = "nav_timetable";
	}
	else if (url.search("yogawithhannah.com/contact") != -1) {
		current_id = "nav_contact";
	}
	else if (url.search("yogawithhannah.com/gallery") != -1) {
		current_id = "nav_gallery";
	}
	else if (url.search("yogawithhannah.com/faq") != -1) {
		current_id = "nav_faq";
	}
	else if (url.search("yogawithhannah.com/diet") != -1) {
		current_id = "nav_diet";
	}
	else if (url.search("yogawithhannah.com/ethics") != -1) {
		current_id = "nav_ethics";
	}
	else if (url.search("yogawithhannah.com/links") != -1) {
		current_id = "nav_links";
	}
	//set the current to the object identified
	this.menu = $(menu), this.current = document.getElementById(current_id);
	
   this.menu.getElements('li').each(function(item){
   item.addEvent('mouseover', function(){ this.moveBg(item); }.bind(this));
   item.addEvent('mouseout', function(){ this.moveBg(this.current); }.bind(this));
   item.addEvent('click', function(event){ this.clickItem(event, item); }.bind(this));
   }.bind(this));
    
   this.back = new Element('li').addClass('background').adopt(new Element('div').addClass('left')).injectInside(this.menu);
   this.back.fx = this.back.effects(this.options);
   if(this.current) this.setCurrent(this.current);
   },
    
   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);
   this.current = el;
   },
    
   getOptions: function(){
   return {
   transition: Fx.Transitions.sineInOut,
   duration: 1000, wait: false,
   onClick: Class.empty
   };
   },
    
   clickItem: function(event, item) {
   if(!this.current) this.setCurrent(item, true);
   this.current = item;
   this.options.onClick(new Event(event), item);
   },
    
   moveBg: function(to) {
   if(!this.current) return;
   this.back.fx.custom({
   left: [this.back.offsetLeft, to.offsetLeft],
   width: [this.back.offsetWidth, to.offsetWidth]
   });
   }
   });
    
   SlideList.implement(new Options);

  
 window.addEvent('domready', function() {
   new SlideList($E('ul', 'main_nav'), {transition: Fx.Transitions.backOut, duration: 1400, onClick: function(ev, item) {  }});
   });