/* --- slideshow --- */

var Loop=new Class({loopCount:0,isStopped:true,isLooping:false,loopMethod:$empty,setLoop:function(b,a){if(this.isLooping){this.stopLoop();var c=true}else{var c=false}this.loopMethod=b;this.loopDelay=a||3000;if(c){this.startLoop()}return this},stopLoop:function(){this.isStopped=true;this.isLooping=false;$clear(this.periodical);return this},startLoop:function(a){if(this.isStopped){var a=(a)?a:this.loopDelay;this.isStopped=false;this.isLooping=true;this.periodical=this.looper.periodical(a,this)}return this},resetLoop:function(){this.loopCount=0;return this},looper:function(){this.loopCount++;this.loopMethod(this.loopCount);return this}});var SlideShow=new Class({Implements:[Options,Events,Loop],options:{delay:7000,transition:"crossFade",duration:"500",autoplay:false},initialize:function(b,a){this.setOptions(a);this.setLoop(this.showNext,this.options.delay);this.element=document.id(b);this.slides=this.element.getChildren();this.current=this.slides[0];this.transitioning=false;this.setup();if(this.options.autoplay){this.play()}},setup:function(){this.setupElement().setupSlides(true);return this},setupElement:function(){var a=this.element;if(a.getStyle("position")!="absolute"&&a!=document.body){a.setStyle("position","relative")}return this},setupSlides:function(a){this.slides.each(function(b,c){this.storeTransition(b).reset(b);if(a&&c!=0){b.setStyle("display","none")}},this);return this},storeTransition:function(a){var c=a.get("class");var b=/transition:[a-zA-Z]+/;var e=/duration:[0-9]+/;var f=(c.match(b))?c.match(b)[0].split(":")[1]:this.options.transition;var d=(c.match(e))?c.match(e)[0].split(":")[1]:this.options.duration;a.store("ssTransition",f).store("ssDuration",d);return this},resetOptions:function(a){this.options=$merge(this.options,a);this.setupSlides(false);return this},getTransition:function(a){return a.retrieve("ssTransition")},getDuration:function(a){return a.retrieve("ssDuration")},show:function(a,b){a=(typeof a=="number")?this.slides[a]:a;if(a!=this.current&&!this.transitioning){this.transitioning=true;var g=(b&&b.transition)?b.transition:this.getTransition(a),f=(b&&b.duration)?b.duration:this.getDuration(a),d=this.current.setStyle("z-index",1),c=this.reset(a);var e={previous:{element:d,index:this.slides.indexOf(d)},next:{element:c,index:this.slides.indexOf(c)}};this.fireEvent("show",e);this.transitions[g](d,c,f,this);(function(){d.setStyle("display","none");this.fireEvent("showComplete",e);this.transitioning=false}).bind(this).delay(f);this.current=c}return this},reset:function(a){return a.setStyles({position:"absolute","z-index":0,display:"block",left:0,top:0}).fade("show")},nextSlide:function(){var a=this.current.getNext();return(a)?a:this.slides[0]},previousSlide:function(){var a=this.current.getPrevious();return(a)?a:this.slides.getLast()},showNext:function(a){this.show(this.nextSlide(),a);return this},showPrevious:function(a){this.show(this.previousSlide(),a);return this},play:function(){this.startLoop();this.fireEvent("play");return this},pause:function(){this.stopLoop();this.fireEvent("pause");return this},reverse:function(){var a=(this.loopMethod==this.showNext)?this.showPrevious:this.showNext;this.setLoop(a,this.options.delay);this.fireEvent("reverse");return this},toElement:function(){return this.element}});Element.Properties.slideshow={set:function(a){var b=this.retrieve("slideshow");if(b){b.pause()}return this.eliminate("slideshow").store("slideshow:options",a)},get:function(a){if(a||!this.retrieve("slideshow")){if(a||!this.retrieve("slideshow:options")){this.set("slideshow",a)}this.store("slideshow",new SlideShow(this,this.retrieve("slideshow:options")))}return this.retrieve("slideshow")}};Element.implement({playSlideShow:function(a){this.get("slideshow",a).play();return this},pauseSlideShow:function(a){this.get("slideshow",a).pause();return this}});SlideShow.adders={transitions:{},add:function(b,a){this.transitions[b]=a;this.implement({transitions:this.transitions})},addAllThese:function(a){$A(a).each(function(b){this.add(b[0],b[1])},this)}};$extend(SlideShow,SlideShow.adders);SlideShow.implement(SlideShow.adders);SlideShow.add("fade",function(c,b,d,a){c.set("tween",{duration:d}).fade("out");return this});SlideShow.addAllThese([["none",function(c,b,d,a){c.setStyle("display","none");return this}],["crossFade",function(c,b,d,a){c.set("tween",{duration:d}).fade("out");b.set("tween",{duration:d}).fade("in");return this}],["fadeThroughBackground",function(c,b,e,a){var d=e/2;b.set("tween",{duration:d}).fade("hide");c.set("tween",{duration:d,onComplete:function(){b.fade("in")}}).fade("out")}],["fadeBasic",function(c,b,e,a){var d=e;b.set("tween",{duration:d}).fade("hide");c.set("tween",{duration:d,onComplete:function(){b.fade("in")}}).fade("out")}],["pushLeft",function(c,b,d,a){var e=a.element.getSize().x;b.setStyle("left",e);new Fx.Elements([c,b],{duration:d}).start({0:{left:[-e]},1:{left:[0]}});return this}],["pushRight",function(b,f,c,a){var e=a.element.getSize().x;f.setStyle("left",-e);new Fx.Elements([b,f],{duration:c}).start({0:{left:[e]},1:{left:[0]}});return this}],["pushUp",function(b,f,c,a){var e=a.element.getSize().y;f.setStyle("top",e);new Fx.Elements([b,f],{duration:c}).start({0:{top:[-e]},1:{top:[0]}});return this}],["pushDown",function(b,f,c,a){var e=a.element.getSize().y;f.setStyle("top",-e);new Fx.Elements([b,f],{duration:c}).start({0:{top:[e]},1:{top:[0]}});return this}],["backLeft",function(c,b,d,a){var e=a.element.getSize().x;b.setStyle("left",e);new Fx.Elements([c,b],{transition:"back:out",duration:d}).start({0:{left:[-e]},1:{left:[0]}});return this}],["backRight",function(b,f,c,a){var e=a.element.getSize().x;f.setStyle("left",-e);new Fx.Elements([b,f],{transition:"back:out",duration:c}).start({0:{left:[e]},1:{left:[0]}});return this}],["backUp",function(b,f,c,a){var e=a.element.getSize().y;f.setStyle("top",e);new Fx.Elements([b,f],{transition:"back:out",duration:c}).start({0:{top:[-e]},1:{top:[0]}});return this}],["backDown",function(b,f,c,a){var e=a.element.getSize().y;f.setStyle("top",-e);new Fx.Elements([b,f],{transition:"back:out",duration:c}).start({0:{top:[e]},1:{top:[0]}});return this}],["quartLeft",function(c,b,d,a){var e=a.element.getSize().x;b.setStyle("left",e);new Fx.Elements([c,b],{transition:"quart:in:out",duration:d}).start({0:{left:[-e]},1:{left:[0]}});return this}],["quartRight",function(b,f,c,a){var e=a.element.getSize().x;f.setStyle("left",-e);new Fx.Elements([b,f],{transition:"quart:in:out",duration:c}).start({0:{left:[e]},1:{left:[0]}});return this}],["quartUp",function(b,f,c,a){var e=a.element.getSize().y;f.setStyle("top",e);new Fx.Elements([b,f],{transition:"quart:in:out",duration:c}).start({0:{top:[-e]},1:{top:[0]}});return this}],["quartDown",function(b,f,c,a){var e=a.element.getSize().y;f.setStyle("top",-e);new Fx.Elements([b,f],{transition:"quart:in:out",duration:c}).start({0:{top:[e]},1:{top:[0]}});return this}],["blindRight",function(b,f,c,a){var e=a.element.getSize().x;f.setStyles({left:-e,"z-index":2}).set("tween",{duration:c}).tween("left",0);return this}],["blindLeft",function(b,f,c,a){var e=a.element.getSize().x;f.setStyles({left:e,"z-index":2}).set("tween",{duration:c}).tween("left",0);return this}],["blindUp",function(b,f,c,a){var e=a.element.getSize().y;f.setStyles({top:e,"z-index":2}).set("tween",{duration:c}).tween("top",0);return this}],["blindDown",function(b,f,c,a){var e=a.element.getSize().y;f.setStyles({top:-e,"z-index":2}).set("tween",{duration:c}).tween("top",0);return this}],["blindDownFade",function(b,e,c,a){this.blindDown(b,e,c,a).fade(b,e,c,a)}],["blindUpFade",function(b,e,c,a){this.blindUp(b,e,c,a).fade(b,e,c,a)}],["blindLeftFade",function(b,e,c,a){this.blindLeft(b,e,c,a).fade(b,e,c,a)}],["blindRightFade",function(b,e,c,a){this.blindRight(b,e,c,a).fade(b,e,c,a)}]]);

/* --- 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")});
