/* Copyright  2007 - 2010 YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

var Warp=Warp||{};
Warp.Follower=new Class({startElement:false,initialize:function(a,b){var c=this;this.setOptions({activeClass:"active",hoveredClass:"isfollowing",slider:{"class":"fancyfollower",html:"<div></div>"},effect:{transition:Fx.Transitions.backOut,duration:300}},b);this.menu=$(a);this.menu.setStyle("position","relative");this.menuitems=this.menu.getChildren();this.menuitems.addEvents({mouseenter:function(){c.slideTo(this,"enter")},mouseleave:function(){c.slideTo(c.current,"leave")},click:function(d){c.click(d,this)}}).setStyles({position:"relative"});
var e=this.options.slider.html;delete this.options.slider.html;this.slider=(new Element(this.menuitems[0].getTag(),this.options.slider)).inject(this.menu);this.slider.innerHTML=e;this.slider.fx=this.slider.effects(this.options.effect);this.setCurrent(this.menu.getElement("."+this.options.activeClass));if(this.current)this.startElement=this.current},click:function(a,b){this.setCurrent(b,true);this.fireEvent("click",[a,b])},setCurrent:function(a,b){if(a&&!this.current){this.slider.setStyles({left:a.offsetLeft,
width:a.offsetWidth,height:a.offsetHeight,top:a.offsetTop});b?this.slider.effect("opacity").set(0).start(1):this.slider.setOpacity(1)}this.current&&this.current.removeClass(this.options.hoveredClass);if(a)this.current=a.addClass(this.options.hoveredClass);return this},slideTo:function(a,b){this.current||this.setCurrent(a);this.slider.fx.stop().custom({left:[this.slider.offsetLeft,a.offsetLeft],width:[this.slider.offsetWidth,a.offsetWidth],top:[this.slider.offsetTop,a.offsetTop],height:[this.slider.offsetHeight,
a.offsetHeight]});this.isHovered=b=="leave"?false:true;if(b=="leave"&&!this.startElement){var c=this;window.setTimeout(function(){if(!c.isHovered){c.slider.setOpacity(0);c.current=false}},200)}else this.slider.setOpacity(1);return this}});Warp.Follower.implement(new Events,new Options);
