var MooDropMenu=new Class({Implements:[Options,Events],options:{onOpen:function(el){el.removeClass('close').addClass('open');},onClose:function(el){el.removeClass('open').addClass('close');},onInitialize:function(el){el.removeClass('open').addClass('close');},mouseoutDelay:100,mouseoverDelay:0,listSelector:'ul',itemSelector:'li'},initialize:function(menu,options,level){this.setOptions(options);options=this.options;var menu=this.menu=document.id(menu);menu.getElements(options.itemSelector+' > '+options.listSelector).each(function(el){this.fireEvent('initialize',el);var parent=el.getParent(options.itemSelector),timer;parent.addEvents({'mouseenter':function(){parent.store('DropDownOpen',true);clearTimeout(timer);if(options.mouseoverDelay)timer=this.fireEvent.delay(options.mouseoverDelay,this,['open',el]);else this.fireEvent('open',el);}.bind(this),'mouseleave':function(){parent.store('DropDownOpen',false);clearTimeout(timer);timer=(function(){if(!parent.retrieve('DropDownOpen'))this.fireEvent('close',el);}).delay(options.mouseoutDelay,this);}.bind(this)});},this);},toElement:function(){return this.menu}});Element.implement({MooDropMenu:function(options){return this.store('MooDropMenu',new MooDropMenu(this,options));}});

var Loop=new Class({loopCount:0,isLooping:false,loopMethod:function(){},setLoop:function(fn,delay){wasLooping=this.isLooping;if(wasLooping)this.stopLoop();this.loopMethod=fn;this.loopDelay=delay||3000;if(wasLooping)this.startLoop();return this;},stopLoop:function(){this.isLooping=false;clearInterval(this.periodical);return this;},startLoop:function(delay,now){if(!this.isLooping){this.isLooping=true;if(now)this.looper();this.periodical=this.looper.periodical(delay||this.loopDelay,this);};return this;},resetLoop:function(){this.loopCount=0;return this;},looper:function(){this.loopCount++;this.loopMethod(this.loopCount);return this;}});

(function(){var a=this.SlideShow=new Class({Implements:[Options,Events,Loop],options:{delay:7e3,transition:"crossFade",duration:840,autoplay:false,dataAttribute:"data-slideshow",selector:"> *",initialSlideIndex:0},transitioning:false,reversed:false,initialize:function(a,b,c){this.element=document.id(a);this.setOptions(b);if(!c)this.setup()},setup:function(a){if(a)this.setOptions(a);this.slides=this.element.getElements(this.options.selector);this.setupElement().setupSlides();this.current=this.current||this.slides[this.options.initialSlideIndex];this.index=this.current.retrieve("slideshow-index");this.setLoop(this.show.pass(this.reversed?"previous":"next",this),this.options.delay);if(this.options.autoplay)this.play();return this},show:function(b,c){if(b=="next"||b=="previous")b=this[b+"Slide"]();if(typeof b=="number")b=this.slides[b];if(b==this.current||this.transitioning)return this;this.transitioning=true;this.current.store("slideshow:oldStyles",this.current.get("style"));var d=c&&c.transition?c.transition:b.retrieve("slideshow-transition"),e=c&&c.duration?c.duration:b.retrieve("slideshow-duration"),f=this.current.setStyle("z-index",1),g=this.reset(b).setStyle("z-index",0),h=this.index=g.retrieve("slideshow-index");slideData={previous:{element:f,index:f.retrieve("slideshow-index")},next:{element:g,index:h}};this.fireEvent("show",slideData);a.transitions[d]({previous:f,next:g,duration:e,instance:this});(function(){f.setStyle("display","none");this.fireEvent("showComplete",slideData);this.transitioning=false}).bind(this).delay(e);this.current=g;return this},play:function(){this.startLoop();this.fireEvent("play");return this},pause:function(){this.stopLoop();this.fireEvent("pause");return this},reverse:function(){this.setLoop(this.show.pass(this.reversed?"next":"previous",this),this.options.delay);this.reversed=!this.reversed;this.fireEvent("reverse");return this},setupElement:function(){this.storeData(this.element);this.options.duration=this.element.retrieve("slideshow-duration");this.options.transition=this.element.retrieve("slideshow-transition");this.options.delay=this.element.retrieve("slideshow-delay");if(this.element.getStyle("position")=="static")this.element.setStyle("position","relative");return this},setupSlides:function(){this.slides.each(function(a,b){a.store("slideshow-index",b).store("slideshow:oldStyles",a.get("style"));this.storeData(a);a.setStyle("display",this.current||b==this.options.initialSlideIndex?"":"none")},this);return this},storeData:function(a){var b=this.options;a.store("slideshow-transition",b.transition);a.store("slideshow-duration",b.duration);if(a==this.element)a.store("slideshow-delay",b.delay);var c=a.get(this.options.dataAttribute);if(!c)return this;Slick.parse(c).expressions[0].each(function(b){a.store("slideshow-"+b.tag,b.pseudos[0].key)});return this},reset:function(a){return a.set("style",a.retrieve("slideshow:oldStyles"))},nextSlide:function(){return this.slides[this.index+1]||this.slides[0]},previousSlide:function(){return this.slides[this.index-1]||this.slides.getLast()},toElement:function(){return this.element}});a.transitions={};a.defineTransition=function(b,c){a.transitions[b]=c};a.defineTransitions=function(b){Object.each(b,function(b,c){a.defineTransition(c,b)})}})();Element.Properties.slideshow={set:function(a){this.get("slideshow").setup(a);return this},get:function(){var a=this.retrieve("slideshow");if(!a){a=new SlideShow(this,{},true);this.store("slideshow",a)}return a}};Element.implement({playSlideShow:function(a){this.get("slideshow").setup(a).play();return this},pauseSlideShow:function(){this.get("slideshow").pause();return this}});SlideShow.defineTransitions({none:function(a){a.previous.setStyle("display","none");return this},fade:function(a){a.previous.set("tween",{duration:a.duration}).fade("out");return this},crossFade:function(a){a.previous.set("tween",{duration:a.duration}).fade("out");a.next.set("tween",{duration:a.duration}).fade("in");return this},fadeThroughBackground:function(a){var b=a.duration/2;a.next.set("tween",{duration:b}).fade("hide");a.previous.set("tween",{duration:b,onComplete:function(){a.next.fade("in")}}).fade("out");return this}});(function(){function b(a,b,c){var d={duration:c.duration,unit:"%"};if(a=="blind"){c.next.setStyle("z-index",2)}if(a!="slide"){c.next.set("tween",d).setStyle(b.property,100*b.inverted+"%");c.next.tween(b.property,0)}if(a!="blind"){c.previous.set("tween",d).tween(b.property,-(100*b.inverted))}}function a(a){return{property:a=="left"||a=="right"?"left":"top",inverted:a=="left"||a=="up"?1:-1}}["left","right","up","down"].each(function(c){var d=c.capitalize(),e="blind"+d,f="slide"+d;[["push"+d,function(){var d=a(c);return function(a){b("push",d,a)}}()],[e,function(){var d=a(c);return function(a){b("blind",d,a)}}()],[f,function(){var d=a(c);return function(a){b("slide",d,a)}}()],[e+"Fade",function(a){this.fade(a)[e](a);return this}]].each(function(a){SlideShow.defineTransition(a[0],a[1])})})})()
