/*
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2012 RocketTheme, LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */
(function(){if(typeof this.RokGallery=="undefined"){this.RokGallery={};}this.RokGallery.ShowcaseResponsive=new Class({Implements:[Options,Events],options:{onJump:function(j){this.animation.index=this.current;
this.animation.setBackground(this.slices[j].getElement("img").get("src"));this.animation.setAnimation(this.options.animation);this.animation.play();if(this.captions.length){this.adjustHeight(j);
this.captionsAnimation.setAnimation(this.options.captions.animation);this.captionsAnimation.setFromTo(this.current,j);this.captionsAnimation.play();}},animation:"random",duration:500,imgpadding:0,captions:{fixedheight:false,animated:true,animation:"crossfade"},autoplay:{enabled:true,delay:5000,complete:function(){this.progress.reset();
this.next();}}},initialize:function(k,j){this.setOptions(j);this.element=document.id(k)||document.getElement(k)||null;this.rtl=document.body.getStyle("direction")=="rtl";
if(!this.element){return false;}this.current=0;this.container=this.element.getElement(".rg-scr-slice-container");this.main=this.element.getElement(".rg-scr-main");
this.imglist=this.element.getElement(".rg-scr-img-list");this.slices=this.element.getElements(".rg-scr-slice");this.captions=this.element.getElements(".rg-scr-info");
this.arrows=this.element.getElements(".rg-scr-controls .next, .rg-scr-controls .prev");this.loaderBar=this.element.getElement(".rg-scr-loader");this.progressBar=this.element.getElement(".rg-scr-progress");
this.slices[0].setStyles({position:"relative",display:"block"});if(this.options.autoplay.enabled){this.progress=new RokGallery.ShowcaseResponsive.Progress(this.progressBar,{duration:this.options.autoplay.delay,container:this.container,width:this.loaderBar?this.loaderBar.getSize().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();}this.jump(0,true);RokMediaQueries.on("every",function(){this.jump(this.current,true);
}.bind(this));window.addEvent("load",function(){this.adjustHeight(0);}.bind(this));if(Browser.Features.Touch){this.element.addEvent("swipe",function(l){l.preventDefault();
this[l.direction=="right"?"previous":"next"]();}.bind(this));}},setup:function(){this.animation=new RokGallery.ShowcaseResponsive.Animations(this.element,{container:this.imglist,width:this.container.getSize().x,height:this.container.getSize().y,duration:this.options.duration,transition:"quad:in:out",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].setStyles({display:"none",position:"absolute"});
}this.slices[this.current].setStyle("position","relative");this.animation.clean();if(this.options.autoplay.enabled){this.progress.play();}}.bind(this)});
if(this.captions.length){this.captions.setStyles({display:"block",opacity:0});this.captions[this.current].setStyle("opacity",1);this.captionsAnimation=new RokGallery.ShowcaseResponsive.CaptionsAnimations(this.captions,{duration:this.options.duration,onStart:function(){this.captions.setStyle("visibility","visible");
}.bind(this),onComplete:function(){this.captions.setStyle("visibility","hidden");this.captions[this.current].setStyle("visibility","visible");if(this.current==this.captionsAnimation.index){this.captions[this.current].setStyle("min-height",this.captions[this.current].getSize().y);
}}.bind(this)});}this.fireEvent("setup");},setArrows:function(){var j;this.arrows.each(function(k){j=k.className.contains("next")?"next":"previous";k.addEvent("click",this[j].bind(this));
},this);},adjustHeight:function(n){var m=this.captions[n].offsetHeight,l=this.container.getSize().y,k=this.main.offsetHeight,j=matchMedia("(max-width: 767px)").matches?(m+l):Math.max(m,l);
if(k!=j){if(this.options.captions.animated){moofx(this.main).animate({"min-height":j},{duration:this.options.duration});}else{moofx(this.main).style({"min-height":j});
}}},next:function(){var j=this.getNext();this.jump(j);if(this.options.autoplay.enabled&&!this.progress.isPaused){this.progress.play();}return this;},previous:function(){var j=this.getPrevious();
this.jump(j);return this;},jump:function(j,k){if(j==this.current&&!k){return this;}if(this.animation.timer){return this;}if(typeof GantrySmartLoad!="undefined"){window.fireEvent("scroll");
}this.fireEvent("jump",j);this.current=j;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.ShowcaseResponsive.Progress=new Class({Extends:Fx,options:{container:null,transition:"linear",fps:24,width:100},initialize:function(k,j){this.element=document.id(k);
this.isPaused=false;this.parent(j);},set:function(j){if(this.element){this.element.setStyle("width",j);}return this;},reset:function(){this.set(0);return this;
},play:function(){this.options.width=this.options.container.getSize().x;this.start(0,this.options.width);return this;},pause:function(){this.isPaused=true;
return this.parent();},resume:function(){this.isPaused=false;return this.parent();}});this.RokGallery.ShowcaseResponsive.Animations=new Class({Extends:Fx.CSS,options:{duration:1000,transition:"expo:in:out",animation:"crossfade",container:"",background:"",imgpadding:0,width:0,height:0,blinds:24,boxes:{rows:5,cols:10}},animations:{},animationsKeys:[],initialize:function(k,j){this.isPaused=false;
this.parent(j);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.container=new Element("div",{"class":"rg-scr-slice-animations"}).inject(this.options.container);
this.setAnimation(this.options.animation);},build:function(j){this.container.empty();this.slides.empty();this["build"+j.capitalize()]();this.elements=$$(this.slides);
},addAnimation:function(j,k){if(!this.animations[j]){this.animations[j]=k;}this.animationsKeys.include(j);},setAnimation:function(j){if(j=="random"){j=this.animationsKeys.getRandom();
}if(!this.animations[j]){this.setOptions({animation:"crossfade"});}this.properties={};for(var k in this.animations[j]){this[k]=this.animations[j][k];}if(!this.animations[j]["blinds"]){this.blinds=this.options.blinds;
}if(!this.animations[j]["boxes"]){this.boxes=this.options.boxes;}if(!this.animations[j]["reorder"]){this.reorder=false;}this.build(this.type);},buildBlinds:function(){var n=this.options.container.getSize(),l={width:n.x,height:n.y},k=this.background,j=k&&k.length?this.blinds:0,m=Math.round(l.width/j);
this.sliceSize={width:m,height:l.height};(j).times(function(p){var o=((m+(p*m))-m);var q=new Element("div").inject(this.container);moofx(q).style({opacity:0,position:"absolute",top:this.options.imgpadding,zIndex:2,left:(m*p)+this.options.imgpadding+"px",height:l.height+"px",width:(p==j-1)?l.width-(m*p):m,background:"url("+k+") no-repeat -"+o+"px 0%",backgroundSize:l.width+"px "+l.height+"px"});
this.slides.push(q);},this);},buildBoxes:function(){var m=this.options.container.getSize(),l={width:m.x,height:m.y},k=this.background,j=k&&k.length?this.boxes:{rows:0,cols:0},n={width:Math.round(l.width/j.cols),height:Math.round(l.height/j.rows)};
this.sliceSize={width:n.width,height:n.height};(j.rows).times(function(o){(j.cols).times(function(q){var p={x:(n.width+(q*n.width))-n.width,y:(n.height+(o*n.height))-n.height};
var r=new Element("div").inject(this.container);moofx(r).style({opacity:0,position:"absolute",zIndex:2,top:(n.height*o)+this.options.imgpadding+"px",left:(n.width*q)+this.options.imgpadding+"px",width:(q==j.cols-1)?l.width-(n.width*q):n.width,height:n.height,background:"url("+k+") no-repeat -"+p.x+"px -"+p.y+"px",backgroundSize:l.width+"px "+l.height+"px"});
this.slides.push(r);},this);},this);},setBackground:function(j){this.background=j;},compute:function(q,r,s){var l={};for(var m in q){var j=q[m],n=r[m],o=l[m]={};
for(var k in j){o[k]=this.parent(j[k],n[k],s);}}return l;},set:function(l,n){var j=this.buffer=0;for(var m in l){if(!this.elements[m]){continue;}var k=l[m];
for(var o in k){this.render.delay(n?0:j,this,[this.elements[m],o,k[o],this.options.unit]);}j+=this.delay;}this.buffer=j;return this;},step:function(){var k=Date.now();
var j=(this.delay||1)*this.slides.length+this.options.duration;if(k<this.time+this.options.duration){var l=this.transition((k-this.time)/this.options.duration);
this.set(this.compute(this.from,this.to,l));}else{if(k>this.time+j){this.set(this.compute(this.from,this.to,1));this.complete();}}},start:function(m){if(!this.check(m)){return this;
}var s={},t={};for(var n in m){if(!this.elements[n]){continue;}var q=m[n],j=s[n]={},r=t[n]={};for(var k in q){var o=this.prepare(this.elements[n],k,q[k]);
j[k]=o.from;r[k]=o.to;}}var l=this.options.duration;this.options.duration=Fx.Durations[l]||l.toInt();this.from=s;this.to=t;this.time=0;this.transition=this.getTransition();
this.startTimer();this.onStart();return this;},reset:function(j,k){var l={};(this.elements.length).times(function(m){l[m]=j;},this);this.set(l,k);},play:function(l){var n={},j={from:{},to:{}};
l=l||Object.clone(this.properties);if(this.direction=="left"){this.elements.reverse();}if(this.reorder){this.elements=this.reorder.bind(this,[this.elements])();
}for(var o in l){switch(typeof l[o]){case"object":case"array":var k=l[o];k.each(function(q,p){if(typeof q=="string"){l[o][p]=q.replace("%height2%",this.sliceSize.height*2).replace("%width2%",this.sliceSize.width*2).replace("%height%",this.sliceSize.height).replace("%width%",this.sliceSize.width).toInt();
}if(["top","right","bottom","left"].contains(o)&&!l[o][p]){l[o][p]+=this.options.imgpadding;}j[!p?"from":"to"][o]=l[o][p];},this);break;case"string":l[o]=l[o].replace("%height2%",this.sliceSize.height*2).replace("%width2%",this.sliceSize.width*2).replace("%height%",this.sliceSize.height).replace("%width%",this.sliceSize.width).toInt();
if(["top","right","bottom","left"].contains(o)&&!l[o][i]){l[o][i]+=this.options.imgpadding;}j.to[o]=l[o];break;}}var m;this.time=0;this.transition=this.getTransition();
this.startTimer();this.onStart();(this.elements.length).times(function(p){(function(){if(p!=this.elements.length-1){m={duration:this.options.duration,equation:"cubic-bezier(0.37,0.61,0.59,0.87)"};
}else{m={duration:this.options.duration,equation:"cubic-bezier(0.37,0.61,0.59,0.87)",callback:function(){this.complete();}.bind(this)};}moofx(this.elements[p]).animate(j.to,m);
}).delay(this.delay*p,this);},this);return this;},complete:function(){if(this.stopTimer()){this.onComplete();}return this;},cancel:function(){if(this.stopTimer()){this.onCancel();
}return this;},onStart:function(){this.fireEvent("start",this.subject);},onComplete:function(){this.fireEvent("complete",this.subject);if(!this.callChain()){this.fireEvent("chainComplete",this.subject);
}},onCancel:function(){this.fireEvent("cancel",this.subject).clearChain();},pause:function(){this.isPaused=true;this.stopTimer();return this;},resume:function(){this.isPaused=false;
this.startTimer();return this;},clean:function(){$$(this.slides).dispose();this.slides.empty();return this;},stopTimer:function(){if(!this.timer){return false;
}this.time=Date.now()-this.time;this.timer=g(this);return true;},startTimer:function(){if(this.timer){return false;}this.time=Date.now()-this.time;this.timer=c(this);
return true;}});var f={},e={};var a=function(){for(var j=this.length;j--;){if(this[j]){this[j].step();}}};var c=function(j){var l=j.options.fps,k=f[l]||(f[l]=[]);
k.push(j);if(!e[l]){e[l]=a.periodical(Math.round(1000/l),k);}return true;};var g=function(j){var l=j.options.fps,k=f[l]||[];k.erase(j);if(!k.length&&e[l]){e[l]=clearInterval(e[l]);
}return false;};this.RokGallery.ShowcaseResponsive.CaptionsAnimations=new Class({Extends:Fx.Elements,options:{duration:1000,transition:"expo:in:out",link:"cancel",animation:"crossfade"},animations:{},animationsKeys:[],initialize:function(k,j){this.parent(j);
this.setOptions(j);this.isPaused=false;this.elements=this.subject=$$(k);this.properties={};this.setAnimation(this.options.animation);this.setFromTo(0,0);
},addAnimation:function(j,k){if(!this.animations[j]){this.animations[j]=k;}this.animationsKeys.include(j);},setAnimation:function(j){if(j=="random"){j=this.animationsKeys.getRandom();
}if(!this.animations[j]){this.setOptions({animation:"crossfade"});}this.properties={};for(var k in this.animations[j]){this.properties[k]=this.animations[j][k];
}},setFromTo:function(k,j){this.fromCaption=this.elements[k]?k:0;this.toCaption=this.elements[j]?j:0;},reset:function(j,k){var l={};(this.elements.length).times(function(m){l[m]=j;
},this);this.set(l,k);},play:function(r){var l={},o={},m={};r=r||this.properties;var n={width:this.elements[this.fromCaption].offsetWidth,height:this.elements[this.fromCaption].offsetHeight},j={width:this.elements[this.toCaption].offsetWidth,height:this.elements[this.toCaption].offsetHeight};
if(this.fromCaption!=this.toCaption){l[this.fromCaption]=r.current;l[this.toCaption]=r.next;}else{l[this.toCaption]=r.next;}var k=this.fromCaption,p=this.toCaption;
for(var s in l[k]){l[this.fromCaption][s].each(function(u,t){if(typeof u=="string"){l[this.fromCaption][s][t]=u.replace("%height2%",n.width*2).replace("%width2%",n.width*2).replace("%height%",n.height).replace("%width%",n.width).toInt();
}},this);}for(var q in l[p]){l[this.toCaption][q].each(function(u,t){if(typeof u=="string"){l[this.toCaption][q][t]=u.replace("%height2%",j.height*2).replace("%width2%",j.width*2).replace("%height%",j.height).replace("%width%",j.width).toInt();
}},this);}if(this.fromCaption==this.toCaption){this.onStart();this.set(l[this.toCaption]);this.onComplete();}else{this.start(l);}return this;},complete:function(){if(this.stopTimer()){this.onComplete();
}return this;},cancel:function(){if(this.stopTimer()){this.onCancel();}return this;},onStart:function(){this.fireEvent("start",this.subject);},onComplete:function(){this.fireEvent("complete",this.subject);
if(!this.callChain()){this.fireEvent("chainComplete",this.subject);}},onCancel:function(){this.fireEvent("cancel",this.subject).clearChain();},pause:function(){this.isPaused=true;
this.stopTimer();return this;},resume:function(){this.isPaused=false;this.startTimer();return this;},clean:function(){$$(this.slides).dispose();this.slides.empty();
return this;},stopTimer:function(){if(!this.timer){return false;}this.time=Date.now()-this.time;this.timer=g(this);return true;},startTimer:function(){if(this.timer){return false;
}this.time=Date.now()-this.time;this.timer=c(this);return true;}});var b={crossfade:{current:{opacity:[1,0]},next:{opacity:[0,1]}},topdown:{current:{opacity:[1,0],top:[0,"%height%"]},next:{opacity:[0,1],top:["-%height%",0]}},bottomup:{current:{opacity:[1,0],top:[0,"-%height%"]},next:{opacity:[0,1],top:["%height2%",0]}}};
var h={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:{height:[0,"%height%"],opacity:[0,1]}},blindsDownRight:{type:"blinds",direction:"right",delay:50,properties:{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(n){var m=[];
for(var l=0,k=n.length-1;l<n.length/2;l++,k--){m.push(n[l]);m.push(n[k]);}return $$(m);},delay:6,properties:{opacity:[0,1],width:[0,"%width%"]}},boxesRandom:{type:"boxes",direction:"right",reorder:function(k){var j=k;
j.sort(function(){return 0.5-Math.random();});return $$(j);},delay:4,properties:{opacity:[0,1]}},blindsMirrorIn:{type:"blinds",blinds:12,direction:"left",reorder:function(n){var m=[];
for(var l=0,k=n.length-1;l<n.length/2;l++,k--){m.push(n[l]);m.push(n[k]);}return $$(m);},delay:50,properties:{opacity:[0,1],width:[0,"%width%"],height:[0,"%height%"]}},blindsMirrorOut:{type:"blinds",blinds:12,direction:"left",reorder:function(n){var m=[];
for(var l=0,k=n.length-1;l<n.length/2;l++,k--){m.push(n[l]);m.push(n[k]);}m.reverse();return $$(m);},delay:50,properties:{opacity:[0,1],width:[0,"%width%"],height:[0,"%height%"]}},blindsRandom:{type:"blinds",blinds:12,direction:"right",reorder:function(k){var j=k;
j.sort(function(){return 0.5-Math.random();});return $$(j);},delay:35,properties:{opacity:[0,1]}}};var d;for(d in h){this.RokGallery.ShowcaseResponsive.Animations.prototype.addAnimation(d,h[d]);
}for(d in b){this.RokGallery.ShowcaseResponsive.CaptionsAnimations.prototype.addAnimation(d,b[d]);}}());