var Loop=new Class({loopCount:0,isStopped:true,isLooping:false,loopMethod:$empty,setLoop:function(b,a){if(this.isLooping){this.stopLoop();var d=true}else{var d=false}this.loopMethod=b;this.loopDelay=a||3000;if(d){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.setup();if(this.options.autoplay){this.startLoop()}},setup:function(){this.setupElement();this.setupSlides();return this},setupElement:function(){var a=this.element;if(a.getStyle("position")!="absolute"&&a!=document.body){a.setStyle("position","relative")}return this},setupSlides:function(){this.slides.each(function(a,b){this.storeTransition(a).reset(a);if(b!=0){a.setStyle("display","none")}},this);return this},storeTransition:function(a){var d=a.get("class");var b=/transition:[a-zA-Z]+/;var f=/duration:[0-9]+/;var g=(d.match(b))?d.match(b)[0].split(":")[1]:this.options.transition;var e=(d.match(f))?d.match(f)[0].split(":")[1]:this.options.duration;a.store("ssTransition",g);a.store("ssDuration",e);return this},getTransition:function(a){return a.retrieve("ssTransition")},getDuration:function(a){return a.retrieve("ssDuration")},show:function(a){this.fireEvent("show");a=(typeof a=="number")?this.slides[a]:a;if(a!=this.current){var f=this.getTransition(a);var e=this.getDuration(a);var d=this.current.setStyle("z-index",1);var b=this.reset(a);this.transitions[f](d,b,e,this);(function(){d.setStyle("display","none");this.fireEvent("showComplete")}).bind(this).delay(e);this.current=b}return this},reset:function(a){return a.setStyles({position:"absolute","z-index":0,display:"block",left:0,top:0}).fade("show");return this},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(){this.show(this.nextSlide());return this},showPrevious:function(){this.show(this.previousSlide());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}});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(d,b,e,a){d.set("tween",{duration:e}).fade("out");return this});SlideShow.addAllThese([["none",function(d,b,e,a){d.setStyle("display","none");return this}],["crossFade",function(d,b,e,a){d.set("tween",{duration:e}).fade("out");b.set("tween",{duration:e}).fade("in");return this}],["fadeThroughBackground",function(d,b,f,a){var e=f/2;b.set("tween",{duration:e}).fade("hide");d.set("tween",{duration:e,onComplete:function(){b.fade("in")}}).fade("out")}],["pushLeft",function(d,b,e,a){var f=a.element.getStyle("width").toInt();b.setStyle("left",f);[b,d].each(function(g){var h=g.getStyle("left").toInt()-f;g.set("tween",{duration:e}).tween("left",h)});return this}],["pushRight",function(d,b,e,a){var f=a.element.getStyle("width").toInt();b.setStyle("left",-f);[b,d].each(function(g){var h=g.getStyle("left").toInt()+f;g.set("tween",{duration:e}).tween("left",h)});return this}],["pushDown",function(d,b,e,a){var f=a.element.getStyle("height").toInt();b.setStyle("top",-f);[b,d].each(function(g){var h=g.getStyle("top").toInt()+f;g.set("tween",{duration:e}).tween("top",h)});return this}],["pushUp",function(d,b,e,a){var f=a.element.getStyle("height").toInt();b.setStyle("top",f);[b,d].each(function(g){var h=g.getStyle("top").toInt()-f;g.set("tween",{duration:e}).tween("top",h)});return this}],["blindLeft",function(d,b,e,a){var f=a.element.getStyle("width").toInt();b.setStyles({left:f,"z-index":1}).set("tween",{duration:e}).tween("left",0);return this}],["blindRight",function(d,b,e,a){var f=a.element.getStyle("width").toInt();b.setStyles({left:-f,"z-index":1}).set("tween",{duration:e}).tween("left",0);return this}],["blindUp",function(d,b,e,a){var f=a.element.getStyle("height").toInt();b.setStyles({top:f,"z-index":1}).set("tween",{duration:e}).tween("top",0);return this}],["blindDown",function(d,b,e,a){var f=a.element.getStyle("height").toInt();b.setStyles({top:-f,"z-index":1}).set("tween",{duration:e}).tween("top",0);return this}],["blindDownFade",function(d,b,e,a){this.blindDown(d,b,e,a).fade(d,b,e,a)}],["blindUpFade",function(d,b,e,a){this.blindUp(d,b,e,a).fade(d,b,e,a)}],["blindLeftFade",function(d,b,e,a){this.blindLeft(d,b,e,a).fade(d,b,e,a)}],["blindRightFade",function(d,b,e,a){this.blindRight(d,b,e,a).fade(d,b,e,a)}]]);window.addEvent("domready",function(){function b(f){var e=0;f.each(function(h,g){if(h.getSize().y>e){e=h.getSize().y}});return e}function d(f,h){var g=$(f);var e=true;if(g){g.setStyle("display","block");g.addEvent("click",function(){if(e==true){h.pause();g.setStyle("background-position","0px 0px");e=false}else{h.showNext();h.play();g.setStyle("background-position","-26px 0px");e=true}})}}if($("changable")){var a=$("changable").getElements("li");a.each(function(f,e){c=f.getChildren();c.each(function(){c.dispose()});t=f.get("text");f.empty();c.each(function(h,g){if(h.match("a")){h.setProperty("target","_blank")}f.adopt(h);f.appendText(" ")});obj=f.getFirst("strong").getFirst("a");obj.set("text",obj.get("text").replace("klarucha |",""))});if(a.length>1){$("changable").getFirst().getFirst().set("id","rajceslide");rajce_slide=new SlideShow("rajceslide",{delay:3000,autoplay:true});d("play_pause_rajce",rajce_slide)}}if($("novinky")){if($$(".novinka").length>1){$("novinky").setStyle("height",b($$(".novinka"))+60+"px");novinky_slide=new SlideShow("novinky",{delay:5000,autoplay:true});d("play_pause_novinky",novinky_slide)}}});
