/* --- slideshow v.2 --- */

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}});var watcher={init:function(slideshows){watcher.slideshows=slideshows;watcher.setPositions().attach().check();return watcher},check:function(){var scroll=window.getScroll().y;watcher.slideshows.each(function(item){if(item.position.stop<=scroll||item.position.start>scroll){if(item.isLooping){item.pause()}return}if(item.position.start<=scroll){if(!item.isLooping){item.show("next").play()}}});setTimeout(watcher.check,500);return watcher},setPositions:function(){watcher.slideshows.each(function(item){var el=$(item),top=el.getPosition().y;item.position={start:top-window.getSize().y,stop:top+el.getSize().y}});return watcher},attach:function(){window.addEvent("resize",watcher.setPositions);return watcher}};(function(){var SlideShow=this.SlideShow=new Class({Implements:[Options,Events,Loop],options:{delay:7000,transition:"crossFade",duration:500,autoplay:false,dataAttribute:"data-slideshow",selector:"> *",initialSlideIndex:0},transitioning:false,reversed:false,initialize:function(element,options,noSetup){this.element=document.id(element);this.setOptions(options);if(!noSetup){this.setup()}},setup:function(options){if(options){this.setOptions(options)}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(slide,options){if(slide=="next"||slide=="previous"){slide=this[slide+"Slide"]()}if(typeof slide=="number"){slide=this.slides[slide]}if(slide==this.current||this.transitioning){return this}this.transitioning=true;this.current.store("slideshow:oldStyles",this.current.get("style"));var transition=(options&&options.transition)?options.transition:slide.retrieve("slideshow-transition"),duration=(options&&options.duration)?options.duration:slide.retrieve("slideshow-duration"),previous=this.current.setStyle("z-index",1),next=this.reset(slide).setStyle("z-index",0),nextIndex=this.index=next.retrieve("slideshow-index");slideData={previous:{element:previous,index:previous.retrieve("slideshow-index")},next:{element:next,index:nextIndex}};this.fireEvent("show",slideData);SlideShow.transitions[transition]({previous:previous,next:next,duration:duration,instance:this});(function(){previous.setStyle("display","none");this.fireEvent("showComplete",slideData);this.transitioning=false}).bind(this).delay(duration);this.current=next;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(slide,index){slide.store("slideshow-index",index).store("slideshow:oldStyles",slide.get("style"));this.storeData(slide);slide.setStyle("display",(this.current||index==this.options.initialSlideIndex)?"":"none")},this);return this},storeData:function(element){var ops=this.options;element.store("slideshow-transition",ops.transition);element.store("slideshow-duration",ops.duration);if(element==this.element){element.store("slideshow-delay",ops.delay)}var data=element.get(this.options.dataAttribute);if(!data){return this}Slick.parse(data).expressions[0].each(function(option){element.store("slideshow-"+option.tag,option.pseudos[0].key)});return this},reset:function(slide){return slide.set("style",slide.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}});SlideShow.transitions={};SlideShow.defineTransition=function(name,fn){SlideShow.transitions[name]=fn};SlideShow.defineTransitions=function(transitions){Object.each(transitions,function(item,index){SlideShow.defineTransition(index,item)})}})();Element.Properties.slideshow={set:function(options){this.get("slideshow").setup(options);return this},get:function(){var instance=this.retrieve("slideshow");if(!instance){instance=new SlideShow(this,{},true);this.store("slideshow",instance)}return instance}};Element.implement({playSlideShow:function(options){this.get("slideshow").setup(options).play();return this},pauseSlideShow:function(){this.get("slideshow").pause();return this}});SlideShow.defineTransitions({none:function(data){data.previous.setStyle("display","none");return this},fade:function(data){data.previous.set("tween",{duration:data.duration}).fade("out");return this},crossFade:function(data){data.previous.set("tween",{duration:data.duration}).fade("out");data.next.set("tween",{duration:data.duration}).fade("in");return this},fadeThroughBackground:function(data){var half=data.duration/2;data.next.set("tween",{duration:half}).fade("hide");data.previous.set("tween",{duration:half,onComplete:function(){data.next.fade("in")}}).fade("out");return this}});(function(){function getStyles(direction){return{property:(direction=="left"||direction=="right")?"left":"top",inverted:(direction=="left"||direction=="up")?1:-1}}function go(type,styles,data){var tweenOptions={duration:data.duration,unit:"%"};if(type=="blind"){data.next.setStyle("z-index",2)}if(type!="slide"){data.next.set("tween",tweenOptions).setStyle(styles.property,100*styles.inverted+"%");data.next.tween(styles.property,0)}if(type!="blind"){data.previous.set("tween",tweenOptions).tween(styles.property,-(100*styles.inverted))}}["left","right","up","down"].each(function(direction){var capitalized=direction.capitalize(),blindName="blind"+capitalized,slideName="slide"+capitalized;[["push"+capitalized,(function(){var styles=getStyles(direction);return function(data){go("push",styles,data)}}())],[blindName,(function(){var styles=getStyles(direction);return function(data){go("blind",styles,data)}}())],[slideName,(function(){var styles=getStyles(direction);return function(data){go("slide",styles,data)}}())],[blindName+"Fade",function(data){this.fade(data)[blindName](data);return this}]].each(function(transition){SlideShow.defineTransition(transition[0],transition[1])})})})();$$("html")[0].removeClass("not-ready").removeClass("no-js");

/* --- elements stack --- */

var StaticScroller=new Class({Implements:Options,options:{offset:0,scrollElement:document},initialize:function(b,a){this.setOptions(a);this.element=document.id(b);this.scrollElement=document.id(this.options.scrollElement);this.originalPosition=this.element.getPosition();this.bound={scroll:this.scroll.bind(this),resize:this.resize.bind(this)};this.attachWindow();this.checkHeight()},attachScroll:function(){this.scrollElement.addEvent("scroll",this.bound.scroll);return this},attachWindow:function(){window.addEvent("resize",this.bound.resize);return this},detachScroll:function(){this.scrollElement.removeEvent("scroll",this.bound.scroll);return this},detachWindow:function(){window.removeEvent("resize",this.bound.resize);return this},checkHeight:function(){if(document.getSize().y<this.element.getSize().y){this.detachScroll().reset()}else{this.attachScroll().scroll()}return this},isPinned:function(){return(this.element.retrieve("pinned"))},scroll:function(){var b=(this.scrollElement.getScroll().y>=this.originalPosition.y-this.options.offset);var a=this.isPinned();if(b){if(!a){this.element.pin().setStyle("top",this.options.offset.toInt())}}else{if(a){this.reset()}}return this},resize:function(){if(this.isPinned()){this.reset()}this.checkHeight();return this},reset:function(){if(this.isPinned()){this.element.unpin().setStyle("position","")}}});

/* --- scroll spy --- */

var ScrollSpy=new Class({Implements:[Options,Events],options:{min:0,mode:"vertical",max:0,container:window,onEnter:$empty,onLeave:$empty,onTick:$empty},initialize:function(a){this.setOptions(a);this.container=document.id(this.options.container);this.enters=this.leaves=0;this.max=this.options.max;if(this.max==0){var b=this.container.getScrollSize();this.max=this.options.mode=="vertical"?b.y:b.x;}this.addListener();},addListener:function(){this.inside=false;this.container.addEvent("scroll",function(){var a=this.container.getScroll();var b=this.options.mode=="vertical"?a.y:a.x;if(b>=this.options.min&&b<=this.max){if(!this.inside){this.inside=true;this.enters++;this.fireEvent("enter",[a,this.enters]);}this.fireEvent("tick",[a,this.inside,this.enters,this.leaves]);}else{if(this.inside){this.inside=false;this.leaves++;this.fireEvent("leave",[a,this.leaves]);}}}.bind(this));}});

/* --- target blank --- */

var moopop={width:0,height:0,captureByRel:function(a,b){this.capture((b||document).getElements("a[rel*="+(a||"target_blank")+"]"))},capture:function(c,b,a){if($defined(b)&&$defined(a)){this.width=b;this.height=a}switch($type(c)){case"string":c=$$(c);case"element":case"array":$splat(c).each(this.add_pop_to,this)}this.width=null;this.height=null},add_pop_to:function(c){c.addEvent("click",function(d){d.stop();this.popup(c)}.bind(this));var b=c.get("rel").match(/\[(\d+),\s*(\d+)/)||["",this.width,this.height];var a=c.get("rel").match(/,(r)/)||[];if(b[1]){c.store("popupprops","width="+b[1]+", height="+b[2]+(a[1]?", scrollbars=yes, resizable=yes":""))}},popup:function(a){window.open(a.get("href"),a.get("name")||"",a.retrieve("popupprops")||"")}};window.addEvent("domready",function(){moopop.captureByRel("target_blank")});

/* --- style form select --- */

var SelectBox=new Class({Implements:[Options,Events],options:{allowSplit:true,altClass:"select-box-alt",alternate:false,alternateOdd:false,attachResize:true,container:null,disableClass:"disabled",elem:null,filter:null,fxOptions:{},groupClass:"select-box-options-group",maxShow:null,minShow:3,optionClass:"select-box-opt",selectboxClass:"select-box",selectClass:"selected",selectmenuClass:"select-box-options",separator:"--",showStyles:false,size:1,template:"<span>%s</span>",tmplt_regex:null,useFx:true,onHide:$empty(),onOver:$empty(),onSelect:$empty(),onShow:$empty()},isCrolling:false,container:null,element:null,focused:null,length:0,selected:null,selectedIndex:0,showing:false,textSearch:"",version:"0.5.5",initialize:function(a){this.boundShow=this.show.bind(this);this.boundKey_option=this.key_option.bind(this);this.boundHide=this.hide.bind(this);var b=($type(a)!="object"?{elem:a}:a);if(!$defined(b.elem)){return}this.setOptions(b);if(this.options.filter){this.filter=this.options.filter}this.element=$(this.options.elem);this.elementCopy=this.element.clone().set({id:this.element.get("id"),name:this.element.get("name")});if(!$defined(this.options.container)||(this.container=$(this.options.container))==null){this.container=null}this.optClass="li[class*="+this.options.optionClass+"]";this.create_select();if(this.options.attachResize){window.addEvent("resize",function(){if(this.showing){this.show()}}.bind(this))}},destroy:function(a){if(a){if(this.selected&&$defined(this.selected.retrieve("value"))){$each(this.elementCopy.options,function(b){if(b.value==this.selected.retrieve("value")){b.selected=true}},this)}this.elementCopy.replaces($(this.element.get("id")))}this.remove_events();this.elementSelect.destroy()},ieFocus:function(){this.isCrolling=true},create_select:function(){var a=this.element.getSize();this.eid=this.element.get("id");this.elementSelect=new Element("div",{"class":this.options.selectboxClass,styles:{width:a.x,height:a.y}}).inject(this.element,"after");this.elementDisplay=new Element("a",{href:"javascript:void(0)"}).inject(this.elementSelect,"top");if(this.elementCopy.get("tabindex")!=0){this.elementDisplay.set("tabindex",this.elementCopy.get("tabindex"))}this.elementDisplay.setStyles({height:(a.y-5),"line-height":(a.y-5)});this.add_events();this.elementOptions=new Element("ul",{styles:{width:a.x},opacity:(this.options.useFx?0:1),"class":this.options.selectmenuClass}).inject(this.elementSelect);if(Browser.Engine.trident){this.boundIeFocus=this.ieFocus.bind(this);this.elementOptions.addEvent("mousedown",this.boundIeFocus)}this.fx=this.options.useFx?new Fx.Tween(this.elementOptions,$merge({duration:"200",link:"cancel"},this.options.fxOptions)):null;$each(this.element.getChildren(),this.create_option.bind(this));if(this.options.alternate){this.elementOptions.getElements(this.optClass+":"+(this.options.alternateOdd?"odd":"even")).addClass(this.options.altClass)}(this.selected=this.elementOptions.getElement("li."+this.options.selectClass)).removeClass(this.options.selectClass);this.selectedIndex=this.selected.retrieve("idx");this.elementDisplay.set({html:this.selected.get("html"),"class":(this.options.showStyles?this.selected.get("class"):""),style:(this.options.showStyles?this.selected.get("style"):"")});this.elementOptions.store("coords",this.elementOptions.getCoordinates()).setStyles({visibility:"",display:"none"});this.element=new Element("input",{type:"hidden",value:this.element.get("value"),id:this.element.get("id"),name:this.element.get("name")}).replaces(this.element).set("id",this.eid)},create_option:function(f,b,a){var d=f.get("value"),g=!!(f.selected);var i=(f.get("label")?f.get("label"):(f.get("text")||"&nbsp;"));var e=(f.get("tag")=="optgroup"?" optgroup unselectable":" "+this.options.optionClass)+(g&&!f.disabled?" "+this.options.selectClass:"")+(f.disabled?" "+this.options.disableClass:"");var h=new Element("li",{id:this.eid+"_opt"+b,html:this.filter(i,this.options.tmplt_regex,this.options.template),style:f.get("style"),"class":f.get("class")+e}).store("value",f.get("value")).store("idx",(f.get("tag")!="optgroup"?(++this.length):"")).addEvents({mouseover:this.over.bind(this),mousedown:this.select.bind(this)}).inject(($(a)||this.elementOptions));h.store("coords",h.getCoordinates());if(f.get("tag")=="optgroup"){var c=new Element("ul",{"class":this.options.groupClass}).inject(h);$each(f.getChildren(),function(k,j){this.create_option(k,(b+""+j),c)},this)}if(this.options.allowSplit&&i.match(new RegExp(this.options.separator))){i=i.split(this.options.separator);this.elementOptions.lastChild.set("html",'<span><span class="goleft">'+i[0].trim()+'</span><span class="goright">'+i[1].trim()+'</span><br style="clear:both" /></span>')}},filter:function(c,b,a){return a.replace(/\%s/i,c)},inject:function(b,a){},dispose:function(a){},add_events:function(){this.elementDisplay.addEvents({click:this.boundShow,keydown:this.boundKey_option,blur:this.boundHide})},remove_events:function(){this.elementOptions.removeEvent(this.boundIeFocus);this.elementDisplay.removeEvents({click:this.boundShow,keydown:this.boundKey_option,blur:this.boundHide})},key_option:function(a){a=new Event(a);if(a.key!="tab"){a.stop();switch(a.key){case"esc":this.hide();break;case"enter":this.select(this.selected);case"tab":this.hide();break;case"up":case"down":if(a.alt){this.show()}this.select(a.key);break;case"shift":case"control":case"alt":break;default:this.search(a.key)}}},search:function(d,b){this.textSearch+=d;var f=this.get_options(),a=false,e=false;for(var c=0;c<f.length;c++){var e=f[c];if((e.get("text")).match(new RegExp("^"+this.textSearch,"i"))){if(this.selected!=e){this.select(e)}a=true;break}}if(a===false){this.textSearch="";if(!b){this.search(d,true)}}},get_options:function(a){return this.elementOptions.getElements((a||this.optClass))},determine:function(a){var c=($type(a)=="element"?(a.get("tag")!="li"?a.getParent("li"):a):this.get_options());if($type(a)!="element"){var b=((this.focused&&this.focused!=this.selected)?this.focused:this.selected).retrieve("idx");c=c.filter(function(d){return(!$(d).hasClass(this.options.disableClass)&&((a=="up"&&$(d).retrieve("idx")<b)||(a=="down"&&$(d).retrieve("idx")>b)))},this);c=c[0]?(a=="up"?c.reverse():c)[0]:c}return c},over:function(b){b=new Event(b);var a=($(b.target).get("tag")!="li"?$(b.target).getParent("li"):$(b.target));if(!a.hasClass(this.options.disableClass)&&!a.hasClass("unselectable")){if($type(this.focused)=="element"){this.focused.removeClass(this.options.selectClass)}(this.focused=a).addClass(this.options.selectClass);this.fireEvent("over")}},select:function(a){var b=($type(a)=="event"?new Event(a).target:a);b=this.determine(b);if(b&&!b.hasClass(this.options.disableClass)&&!b.hasClass("unselectable")){if(this.focused){this.focused.removeClass(this.options.selectClass)}if(this.showing===true){(this.focused=this.selected=b).addClass(this.options.selectClass);this.scroll()}else{this.selected=b}this.element.set("value",this.selected.retrieve("value"));this.selectedIndex=this.selected.retrieve("idx");this.elementDisplay.set({html:this.selected.get("html"),"class":(this.options.showStyles?this.selected.get("class"):"")}).removeClass(this.options.selectClass).removeClass(this.options.altClass);this.fireEvent("select",this.selected);if(Browser.Engine.trident){this.isCrolling=false;this.hide()}}},scroll:function(){var a=this.elementOptions.getCoordinates();var c=this.selected.getCoordinates();var b=this.elementOptions.scrollTop;if((b+a.height)<(c.top-a.top+5)){this.elementOptions.scrollTop=(c.top-a.top-a.height+c.height)}else{if((c.top-a.top+c.height)<(b+5)){this.elementOptions.scrollTop=(c.top-a.top)}}},show:function(){var f=this.elementOptions.retrieve("coords");var b=this.elementSelect.getCoordinates(),d=(b.top+b.height);if(this.container){d-=this.container.getStyle("top");b.left-=this.container.getStyle("left")}var c=((window.getSize().y+window.getScroll().y)-d);var a=(f.height>=c?0:"auto"),e=0;if(f.height>=c){$each(this.get_options(),function(g){var h=g.retrieve("coords").height;if(a<c&&(a+h)<c){a+=h;e++}},this);if(e<this.options.minShow){a=(b.top<f.height?b.top-10:f.height);d=b.top-a-1}}this.elementOptions.setStyles({display:"",height:a,top:d,left:b.left,margin:0});this.scroll();this.showing=true;this.focused=this.selected;this.focused.addClass(this.options.selectClass);this.fireEvent("show");if(this.options.useFx){this.fx.start("opacity",0,1)}this.elementDisplay.focus()},hide:function(a){if(this.isCrolling){this.isCrolling=false;this.elementDisplay.focus()}else{if(this.showing){if(this.options.useFx){this.fx.start("opacity",1,0).chain(function(){this.elementOptions.scrollTop=0;this.elementOptions.setStyle("display","none");if(this.focused){this.focused.removeClass(this.options.selectClass)}this.showing=this.focused=false}.bind(this))}else{this.elementOptions.setStyle("display","none");if(this.focused){this.focused.removeClass(this.options.selectClass)}this.showing=this.focused=false}this.fireEvent("hide")}}this.textSearch=""}});

