/*
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2011 RocketTheme, LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */

(function(){if(typeof this.RokGallery=="undefined"){this.RokGallery={};}Element.extend({sumStyles:function(d){var e=[],c=0;d.each(function(f){e.push(this.getStyle(f).toInt());
},this);e.each(function(f){c+=f;});return c;}});Elements.extend({sumStyles:function(d){var c=0;this.each(function(e){c+=e.sumStyles(d);},this);return c;
}});this.RokGallery.Slideshow=new Class({options:{onJump:function(c){this.animation.index=this.current;this.animation.setBackground(this.slices[c].getElement("img").getProperty("src"));
this.animation.setAnimation(this.options.animation);this.animation.play();if(this.captions.length){if(this.current==c){this.captions[this.current].fx.start(1);
}else{this.captions[this.current].fx.start(0);this.captions[c].fx.start(1);}}},animation:"random",duration:500,autoplay:{enabled:true,delay:5000,complete:function(){this.progress.reset();
this.next();}}},initialize:function(d,c){this.setOptions(c);this.element=$(d)||$E(d)||null;this.rtl=document.body.getStyle("direction")=="rtl";if(!this.element){throw new Error('The element "'+d+'" has not been found in the page.');
}this.current=0;this.container=$E(".rg-ss-slice-container",this.element);this.slices=$ES(".rg-ss-slice",this.element);this.captions=$ES(".rg-ss-info",this.element);
this.arrows=$ES(".rg-ss-controls .next, .rg-ss-controls .prev",this.element);this.scrollerContainer=$E(".rg-ss-thumb-scroller",this.element);this.loaderBar=$E(".rg-ss-loader",this.element);
this.progressBar=$E(".rg-ss-progress",this.element);if(this.options.autoplay.enabled){var e=this.progressBar;if(!e){e=new Element("div",{styles:{display:"none",position:"absolute"}}).inject(document.body);
}this.progress=new RokGallery.Slideshow.Progress(e,{duration:this.options.autoplay.delay,width:this.loaderBar?this.loaderBar.getSize().size.x:0,onComplete:this.options.autoplay.complete.bind(this)}).play();
this.bounds={progress:{mouseenter:this.progress.pause.bind(this.progress),mouseleave:this.progress.resume.bind(this.progress)}};this.element.addEvents(this.bounds.progress);
}else{if(this.loaderBar){this.loaderBar.setStyle("display","none");}}this.setup();if(this.arrows.length){this.setArrows();}if(this.scrollerContainer){this.setNavigation();
}this.jump(0,true);},setup:function(){this.animation=new RokGallery.Slideshow.Animations(this.element,{container:this.container,width:this.container.getSize().size.x,height:this.container.getSize().size.y,duration:this.options.duration,transition:Fx.Transitions.Quad.easeInOut,onStart:function(){if(this.options.autoplay.enabled){this.progress.pause();
}}.bind(this),onComplete:function(){this.slices[this.current].setStyle("display","block");if(this.current!=this.animation.index){this.slices[this.animation.index].setStyle("display","none");
}this.animation.clean();if(this.options.autoplay.enabled){this.progress.play();}}.bind(this)});if(this.captions.length){this.captions.setStyles({display:"block",opacity:0,visibility:"hidden"});
this.captions.each(function(c){c.fx=new Fx.Style(c,"opacity",{duration:this.options.duration,transition:Fx.Transitions.Quad.easeInOut});},this);}this.fireEvent("onSetup");
},setArrows:function(){["next","previous"].each(function(d,c){this.arrows[c].addEvent("click",this[d].bind(this));},this);},setNavigation:function(){this.scroller=new RokGallery.Slideshow.Thumbnails(this.element,this,{});
},next:function(){var c=this.getNext();this.jump(c);if(this.options.autoplay.enabled&&!this.progress.isPaused){this.progress.play();}return this;},previous:function(){var c=this.getPrevious();
this.jump(c);return this;},jump:function(c,d){if(c==this.current&&!d){return this;}if(this.animation.timer){return this;}this.fireEvent("onJump",c);if(this.scrollerContainer){this.scroller.setActive(c);
this.scroller.toThumb(c);}this.current=c;return this;},getNext:function(){return(this.current+1>=this.slices.length)?0:this.current+1;},getPrevious:function(){return(this.current-1<0)?this.slices.length-1:this.current-1;
}});this.RokGallery.Slideshow.implement(new Events,new Options);this.RokGallery.Slideshow.Progress=Fx.Style.extend({options:{transition:Fx.Transitions.linear,fps:24,width:100},initialize:function(d,c){this.element=$(d);
this.isPaused=false;this.property="width";this.reset();this.setOptions(c);this.parent(c);},increase:function(){if(this.element){this.element.setStyle(this.property,this.css.getValue(this.now,this.options.unit,this.property));
}},reset:function(){this.set(0);return this;},play:function(){this.start(0,this.options.width);return this;},pause:function(){this.isPaused=true;this.stopTimer();
return this;},resume:function(){this.isPaused=false;this.startTimer();return this;},stopTimer:function(){if(!this.timer){return false;}this.time=$time()-this.time;
this.timer=$clear(this.timer);return true;},startTimer:function(){if(this.timer){return false;}this.time=$time()-this.time;this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);
return true;}});this.RokGallery.Slideshow.Thumbnails=new Class({options:{onClickElement:function(c,d){if(this.base.animation.timer){return this;}this.base.jump(d);
this.setActive(d);return this;},scroller:{duration:300,transition:Fx.Transitions.Expo.easeInOut}},initialize:function(d,e,c){this.setOptions(c);this.base=e;
this.element=d;this.thumbSize=0;this.wrapper=$E(".rg-ss-navigation-container",this.element);this.container=$E(".rg-ss-thumb-scroller",this.wrapper);this.arrows=$ES(".rg-ss-arrow-left, .rg-ss-arrow-right",this.wrapper);
this.list=$E(".rg-ss-thumb-list",this.wrapper);this.thumbsWrapper=$ES(".rg-ss-thumb-list .rg-ss-thumb",this.wrapper);this.thumbs=$ES(".rg-ss-thumb-list .rg-ss-thumb img",this.wrapper);
this.arrowsSize=this.arrows.sumStyles(["width"]);this.scroller=new Fx.Scroll(this.container,this.options.scroller);this.scroller.set(0,0);this.setup();
this.attach();return this;},attach:function(){this.thumbsWrapper.each(function(c,d){c.bounds={click:this.clickElement.bindWithEvent(this,c)};c.addEvents(c.bounds);
},this);this.arrows.each(function(d,c){d.bounds={click:this.arrowsClick.bindWithEvent(this,[d,(!c?"left":"right")])};d.addEvent("dblclick",function(f){f.stop();
});d.addEvents(d.bounds);},this);},detach:function(){this.thumbsWrapper.each(function(c,d){c.removeEvents(c.bounds);},this);this.arrows.removeEvents(this.bounds.arrows);
},arrowsClick:function(e,f,g){e.stop();var c=this.container.scrollLeft+(g=="left"?-this.thumbSize:+this.thumbSize),d=this.container.scrollWidth-this.container.offsetWidth,h=this.container.scrollLeft+this.thumbSize;
if(d-h<this.thumbSize){c+=d-h;}if(h-this.thumbSize*2<this.thumbSize&&g=="left"){c=0;}this.scroller.scrollTo(c,0);},toThumb:function(c){this.scroller.scrollTo(this.thumbSize*c,0);
},clickElement:function(e,c){if(e){new Event(e).stop();}var d=this.thumbsWrapper.indexOf(c);this.fireEvent("onClickElement",[c,d]);},setup:function(){var c=0,d=[];
["padding-%x","border-%x-width","margin-%x"].each(function(e){["left","right"].each(function(f){d.push(e.replace(/%x/g,f));});});this.thumbs.each(function(e,f){this.thumbSize=this.thumbsWrapper[f].sumStyles(d)+e.getProperty("width").toInt();
c+=this.thumbSize;},this);this.list.setStyle("width",c);if(c<this.wrapper.offsetWidth-this.arrowsSize){this.wrapper.removeClass("arrows-enabled");}else{this.wrapper.addClass("arrows-enabled");
}},setActive:function(c){this.thumbsWrapper.removeClass("active");this.thumbsWrapper[c].addClass("active");}});this.RokGallery.Slideshow.Thumbnails.implement(new Events,new Options);
this.RokGallery.Slideshow.Animations=Fx.Base.extend({options:{duration:1000,transition:Fx.Transitions.Expo.easeInOut,animation:"crossfade",container:"",background:"",width:0,height:0,blinds:24,boxes:{rows:10,cols:24}},animations:{},animationsKeys:[],initialize:function(d,c){this.isPaused=false;
this.slides=[];this.originalDuration=this.options.duration;this.delay=0;this.type="blinds";this.background=this.options.background;this.blinds=1;this.boxes={rows:1,cols:1};
this.properties={};this.direction="right";this.reorder=false;this.parent(c);this.setOptions(c);this.container=new Element("div",{"class":"rg-ss-slice-animations"}).inject(this.options.container);
this.setAnimation(this.options.animation);},setNow:function(){for(var e in this.from){var h=this.from[e],g=this.to[e],d=this.css[e],c=this.now[e]={};for(var f in h){c[f]=d[f].getNow(h[f],g[f],this);
}}},set:function(j){var d={};this.css={};for(var f in j){var h=j[f],e=this.css[f]={},c=d[f]={};for(var g in h){e[g]=Fx.CSS.select(g,h[g]);c[g]=e[g].parse(h[g]);
}}return this.parent(d);},start:function(f){if(this.timer&&this.options.wait){return this;}this.now={};this.css={};var l={},m={};for(var g in f){var j=f[g],c=l[g]={},k=m[g]={},e=this.css[g]={};
for(var d in j){var h=Fx.CSS.parse(this.elements[g],d,j[d]);c[d]=h.from;k[d]=h.to;e[d]=h.css;}}return this.parent(l,m);},increase:function(){for(var e in this.now){var c=this.now[e],d=this.css[e];
for(var f in c){this.elements[e].setStyle(f,d[f].getValue(c[f],this.options.unit,f));}}},build:function(c){this.container.empty();this.slides=[];this["build"+c.capitalize()]();
this.elements=$$(this.slides);},addAnimation:function(c,d){if(!this.animations[c]){this.animations[c]=d;}this.animationsKeys.include(c);},setAnimation:function(c){if(c=="random"){c=this.animationsKeys.getRandom();
}if(!this.animations[c]){this.setOptions({animation:"crossfade"});}for(var d in this.animations[c]){this[d]=this.animations[c][d];}if(!this.animations[c]["blinds"]){this.blinds=this.options.blinds;
}if(!this.animations[c]["boxes"]){this.boxes=this.options.boxes;}if(!this.animations[c]["reorder"]){this.reorder=false;}this.build(this.type);},buildBlinds:function(){var e={width:this.options.width,height:this.options.height},d=this.background,c=this.blinds,f=Math.round(e.width/c);
this.sliceSize={width:f,height:e.height};(c).times(function(h){var g=((f+(h*f))-f);var j=new Element("div",{styles:{opacity:0,position:"absolute",top:0,left:(f*h)+"px",height:e.height+"px",width:(h==c-1)?e.width-(f*h):f,background:"url("+d+") no-repeat -"+g+"px 0%"}}).inject(this.container);
this.slides.push(j);}.bind(this));},buildBoxes:function(){var e={width:this.options.width,height:this.options.height},d=this.background,c=this.boxes,f={width:Math.round(e.width/c.cols),height:Math.round(e.height/c.rows)};
this.sliceSize={width:f.width,height:f.height};(c.rows).times(function(g){(c.cols).times(function(i){var h={x:(f.width+(i*f.width))-f.width,y:(f.height+(g*f.height))-f.height};
var j=new Element("div",{styles:{opacity:0,position:"absolute",top:(f.height*g)+"px",left:(f.width*i)+"px",width:(i==c.cols-1)?e.width-(f.width*i):f.width,height:f.height,background:"url("+d+") no-repeat -"+h.x+"px -"+h.y+"px"}}).inject(this.container);
this.slides.push(j);}.bind(this));}.bind(this));},setBackground:function(c){this.background=c;},reset:function(c,d){var e={};(this.elements.length).times(function(f){e[f]=c;
},this);this.set(e,d);},play:function(d){var e={};d=d||this.properties;if(this.direction=="left"){this.elements.reverse();}if(this.reorder){this.elements=this.reorder.pass([this.elements],this)();
}for(var f in d){switch(typeof d[f]){case"object":case"array":var c=d[f];c.each(function(h,g){if(typeof h=="string"){d[f][g]=h.replace("%height2%",this.sliceSize.height*2).replace("%width2%",this.sliceSize.width*2).replace("%height%",this.sliceSize.height).replace("%width%",this.sliceSize.width).toInt();
}},this);break;case"string":d[f]=d[f].replace("%height2%",this.sliceSize.height*2).replace("%width2%",this.sliceSize.width*2).replace("%height%",this.sliceSize.height).replace("%width%",this.sliceSize.width).toInt();
break;}}(this.elements.length).times(function(g){e[g]=d;});this.start(e);return this;},clean:function(){this.slides.each(function(c){c.remove();});this.slides=[];
return this;}});var b={crossfade:{type:"blinds",blinds:1,delay:0,direction:"right",properties:{opacity:[0,1]}},blindsRight:{type:"blinds",direction:"right",delay:50,properties:{opacity:[0,1]}},blindsLeft:{type:"blinds",direction:"left",delay:50,properties:{opacity:[0,1]}},blindsDownLeft:{type:"blinds",direction:"left",delay:50,properties:{width:[0,"%width%"],height:[0,"%height%"],opacity:[0,1]}},blindsDownRight:{type:"blinds",direction:"right",delay:50,properties:{width:[0,"%width%"],height:[0,"%height%"],opacity:[0,1]}},boxesOpacityRight:{type:"boxes",direction:"right",delay:6,properties:{opacity:[0,1]}},boxesOpacityLeft:{type:"boxes",direction:"left",delay:6,properties:{opacity:[0,1]}},slideDown:{type:"boxes",boxes:{cols:1,rows:1},direction:"right",delay:200,properties:{height:[0,"%height%"],opacity:[0,1]}},slideUp:{type:"boxes",boxes:{cols:1,rows:1},direction:"right",delay:200,properties:{top:["%height%",0],opacity:[0,1]}},slideLeft:{type:"boxes",boxes:{cols:1,rows:1},direction:"left",delay:200,properties:{left:["-%width%",0],opacity:[0,1]}},slideRight:{type:"boxes",boxes:{cols:1,rows:1},direction:"right",delay:200,properties:{left:["%width%",0],opacity:[0,1]}},boxesRight:{type:"boxes",direction:"right",delay:6,properties:{width:[0,"%width%"],height:[0,"%height%"],opacity:[0,1]}},boxesLeft:{type:"boxes",direction:"left",delay:6,properties:{width:[0,"%width%"],height:[0,"%height%"],opacity:[0,1]}},boxesMirror:{type:"boxes",direction:"left",reorder:function(f){var e=[];
for(var d=0,c=f.length-1;d<f.length/2;d++,c--){e.push(f[d]);e.push(f[c]);}return $$(e);},delay:6,properties:{opacity:[0,1],width:[0,"%width%"],height:[0,"%height%"]}},boxesRandom:{type:"boxes",direction:"right",reorder:function(d){var c=d;
c.sort(function(){return 0.5-Math.random();});return $$(c);},delay:4,properties:{opacity:[0,1]}},blindsMirrorIn:{type:"blinds",direction:"left",reorder:function(f){var e=[];
for(var d=0,c=f.length-1;d<f.length/2;d++,c--){e.push(f[d]);e.push(f[c]);}return $$(e);},delay:50,properties:{opacity:[0,1],width:[0,"%width%"],height:[0,"%height%"]}},blindsMirrorOut:{type:"blinds",direction:"left",reorder:function(f){var e=[];
for(var d=0,c=f.length-1;d<f.length/2;d++,c--){e.push(f[d]);e.push(f[c]);}e.reverse();return $$(e);},delay:50,properties:{opacity:[0,1],width:[0,"%width%"],height:[0,"%height%"]}},blindsRandom:{type:"blinds",direction:"right",reorder:function(d){var c=d;
c.sort(function(){return 0.5-Math.random();});return $$(c);},delay:35,properties:{opacity:[0,1]}}};for(var a in b){this.RokGallery.Slideshow.Animations.prototype.addAnimation(a,b[a]);
}}());
