/*
 * @version   $Id: strips.js 10889 2013-05-30 07:48:35Z btowles $
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2014 RocketTheme, LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */
((function(){if(typeof this.RokSprocket=="undefined"){this.RokSprocket={};
}else{Object.merge(this.RokSprocket,{Strips:null});}var a=new Class({Implements:[Options,Events],options:{settings:{}},initialize:function(c){this.setOptions(c);
this.strips=document.getElements("[data-strips]");this.settings={};this.timers={};this.statuses={};this.curve=Browser.opera?{equation:"ease-in-out"}:{curve:"cubic-bezier(0.37,0.61,0.59,0.87)"};
},attach:function(e,c){e=typeOf(e)=="number"?document.getElements("[data-strips="+this.getID(e)+"]"):e;c=typeOf(c)=="string"?JSON.decode(c):c;var d=(e?new Elements([e]).flatten():this.strips);
d.each(function(f){f.store("roksprocket:strips:attached",true);this.setSettings(f,c,"restore");var h={mouseenter:f.retrieve("roksprocket:strips:mouseenter",function(i){this.stopTimer.call(this,f);
this.pause.call(this,f);}.bind(this)),mouseleave:f.retrieve("roksprocket:strips:mouseleave",function(i){this.resume.call(this,f);this.startTimer.call(this,f);
}.bind(this)),page:f.retrieve("roksprocket:strips:relay",function(i,j){if(i){i.preventDefault();}this.toPage.call(this,f,j);}.bind(this)),next:f.retrieve("roksprocket:strips:next",function(j,i){this.direction.call(this,j,f,i,"next");
}.bind(this)),previous:f.retrieve("roksprocket:strips:previous",function(j,i){this.direction.call(this,j,f,i,"previous");}.bind(this)),swipe:f.retrieve("roksprocket:strips:swipe",function(j,i){j.preventDefault();
this.direction.call(this,j,f,i,(j.direction=="right"?"previous":"next"));}.bind(this))};["mouseenter","mouseleave"].each(function(i){f.addEvent(i,h[i]);
});["page","next","previous"].each(function(j,k){var l="[data-strips-"+j+"]";if(k>0){l+=", [data-"+j+"]";}f.addEvent("click:relay("+l+")",h[j]);},this);
f.retrieve("roksprocket:strips:ajax",new RokSprocket.Request({model:"strips",model_action:"getPage",onRequest:this.onRequest.bind(this,f),onSuccess:function(i){this.onSuccess(i,f,f.retrieve("roksprocket:strips:ajax"));
}.bind(this)}));if(Browser.Features.Touch){f.addEvent("swipe",h.swipe);}var g=f.getElement("[data-strips-page].active");if(!g){this.toPage(f,0);}else{if(this.getSettings(f).autoplay&&this.getSettings(f).autoplay.toInt()){this.startTimer(f);
}}},this);},detach:function(d){d=typeOf(d)=="number"?document.getElements("[data-strips="+this.getID(d)+"]"):d;var c=(d?new Elements([d]).flatten():this.strips);
c.each(function(e){e.store("roksprocket:strips:attached",false);var f={mouseenter:e.retrieve("roksprocket:strips:mouseenter"),mouseleave:e.retrieve("roksprocket:strips:mouseleave"),page:e.retrieve("roksprocket:strips:relay"),next:e.retrieve("roksprocket:strips:next"),previous:e.retrieve("roksprocket:strips:previous")};
["mouseenter","mouseleave"].each(function(g){e.removeEvent(g,f[g]);});["page","next","previous"].each(function(g,h){var j="[data-strips-"+g+"]";if(h>0){j+=", [data-"+g+"]";
}e.removeEvent("click:relay("+j+")",f[g]);},this);if(Browser.Features.Touch){e.removeEvent("swipe",f.swipe);}},this);},setSettings:function(c,f,e){var g=this.getID(c),d=Object.clone(this.options.settings);
if(!e||!this.settings["id-"+g]){this.settings["id-"+g]=Object.merge(d,f||d);}},getSettings:function(c){var d=this.getID(c);return this.settings["id-"+d];
},getContainer:function(c){if(!c){c=document.getElements("[data-strips]");}if(typeOf(c)=="number"){c=document.getElement("[data-strips="+c+"]");}if(typeOf(c)=="string"){c=document.getElement(c);
}return c;},getID:function(c){if(typeOf(c)=="number"){c=document.getElement("[data-strips="+c+"]");}if(typeOf(c)=="string"){c=document.getElement(c);}return !c?c:c.get("data-strips");
},toPage:function(c,f){c=this.getContainer(c);f=(typeOf(f)=="element")?f.get("data-strips-page"):f;if(!c.retrieve("roksprocket:strips:attached")){return;
}var d=c.getElements("[data-strips-page]"),e=c.retrieve("roksprocket:strips:ajax");if(!d.length){return;}if(f>d.length){f=1;}if(f<1){f=d.length;}if(d[f-1].hasClass("active")){return;
}if(!e.isRunning()){e.cancel().setParams({moduleid:c.get("data-strips"),page:f}).send();}},direction:function(f,c,e,d){if(f){f.preventDefault();}d=d||"next";
this[d](c,e);},next:function(c,d){c=this.getContainer(c);if(!c.retrieve("roksprocket:strips:attached")){return;}if(typeOf(c)=="elements"){return this.nextAll(c,d);
}var f=c.getElements("[data-strips-page]");if(!f.length){return;}var g=c.getElement("[data-strips-page].active").get("data-strips-page"),e=g.toInt()+1;
if(e>f.length){e=1;}this.dir="right";this.toPage(c,e);},nextAll:function(d,c){d=this.getContainer(d);if(typeOf(d)=="element"){return this.next(d,c);}d.each(function(e){this.next(e,c);
},this);},previous:function(c,d){c=this.getContainer(c);if(!c.retrieve("roksprocket:strips:attached")){return;}if(typeOf(c)=="elements"){return this.nextAll(c,d);
}var f=c.getElements("[data-strips-page]");if(!f.length){return;}var g=c.getElement("[data-strips-page].active").get("data-strips-page"),e=g.toInt()-1;
if(e<1){e=f.length;}this.dir="left";this.toPage(c,e);},previousAll:function(d,c){d=this.getContainer(d);if(typeOf(d)=="element"){return this.previous(d,c);
}d.each(function(e){this.previous(e,c);},this);},startTimer:function(d){d=this.getContainer(d);if(!d.retrieve("roksprocket:strips:attached")){return;}var f=this.getSettings(d),h=this.getID(d),c=this.statuses["id-"+h],g=f.autoplay.toInt(),e=(f.delay.toInt())*1000;
clearTimeout(this.timers["id-"+h]);if(g&&c!="pause"){this.timers["id-"+h]=this.next.delay(e,this,d);}},stopTimer:function(c){c=this.getContainer(c);var d=this.getID(c);
clearTimeout(this.timers["id-"+d]);},pause:function(c){c=this.getContainer(c);var d=this.getID(c);this.statuses["id-"+d]="pause";},resume:function(c){c=this.getContainer(c);
var d=this.getID(c);this.statuses["id-"+d]="play";},onRequest:function(c){c.addClass("loading");},onSuccess:function(h,d){var l=d.getElement("[data-strips-items]"),j=d.getElements("[data-strips-item]"),i=h.getPath("payload.html"),k=h.getPath("payload.page"),f=this.getSettings(d),g=f.animation||"fadeDelay";
d.removeClass("loading");var e=new Element("div",{html:i}),c=e.getChildren(),m,n;if(g=="random"){g=Object.keys(Object.merge({},this.Animations)).getRandom();
}if(!this.Animations[g]){g="fadeDelay";}f.callback=function(){if(f.autoplay&&f.autoplay.toInt()){this.startTimer(d);}}.bind(this);this.Animations[g].call(this,l,j,c,f);
this._switchPage(d,k);},_switchPage:function(c,e){var d=c.getElements("[data-strips-page]");d.removeClass("active");d[e-1].addClass("active");}});var b={fade:function(){var d=arguments[0],c=arguments[1],g=arguments[2],f=arguments[3],e={duration:this.AnimationsSpeed.fade.duration,curve:this.curve,callback:function(){d.empty().adopt(g);
e.callback=f.callback||function(){};moofx(d).animate({opacity:1},e);}};moofx(d).animate({opacity:0},e);},fadeDelay:function(){var d=arguments[0],c=arguments[1],g=arguments[2],f=arguments[3],e={duration:this.AnimationsSpeed.fadeDelay.duration,curve:this.curve};
if(this.dir=="left"){c.reverse();}c.forEach(function(j,h){(function(){if(h==c.length-1){e.callback=function(){moofx(g).style({opacity:0});d.empty().adopt(g);
e.callback=f.callback||function(){};if(this.dir=="left"){g.reverse();}g.forEach(function(k,i){(function(){moofx(g[i]).animate({opacity:1},e);}).delay(i*this.AnimationsSpeed.fadeDelay.delay);
},this);}.bind(this);}moofx(j).animate({opacity:0},e);}).delay(h*this.AnimationsSpeed.fadeDelay.delay,this);},this);},slide:function(){var d=arguments[0],c=arguments[1],g=arguments[2],f=arguments[3],e={duration:this.AnimationsSpeed.slide.duration,curve:this.curve,callback:function(){d.empty().adopt(g);
e.callback=f.callback||function(){};h=d.getSize().x+25;if(this.dir=="left"){moofx(g).style({right:h,position:"relative",left:"inherit"});moofx(g).animate({right:0},e);
}else{moofx(g).style({left:h,position:"relative",right:"inherit"});moofx(g).animate({left:0},e);}}.bind(this)},h=0;moofx(c).style({position:"relative"});
h=d.getSize().x+25;if(this.dir=="left"){moofx(c).animate({left:h,right:"inherit"},e);}else{moofx(c).animate({right:h,left:"inherit"},e);}},flyIn:function(){var d=arguments[0],c=arguments[1],g=arguments[2],f=arguments[3],e={duration:this.AnimationsSpeed.flyIn.duration,curve:this.curve},h=0;
if(this.dir=="left"){c.reverse();}c.forEach(function(k,j){(function(){if(j==c.length-1){e.callback=function(){d.empty().adopt(g);e.callback=null;if(this.dir=="left"){g.reverse();
}g.forEach(function(l,i){h=d.getSize().x+(g[i].getSize().x/(i+1))+25;if(this.dir=="left"){moofx(g).style({right:h,position:"relative",left:"inherit"});
}else{moofx(g).style({left:h,position:"relative",right:"inherit"});}(function(){if(i==g.length-1){e.callback=f.callback||function(){};}if(this.dir=="left"){moofx(g[i]).animate({right:0},e);
}else{moofx(g[i]).animate({left:0},e);}}).delay(i*this.AnimationsSpeed.flyIn.delay,this);},this);}.bind(this);}moofx(k).style({position:"relative"});h=d.getSize().x+(k.getSize().x/(j+1))+25;
if(this.dir=="left"){moofx(k).animate({left:h,right:"inherit"},e);}else{moofx(k).animate({right:h,left:"inherit"},e);}}).delay(j*this.AnimationsSpeed.flyIn.delay,this);
},this);},fallDown:function(){var d=arguments[0],c=arguments[1],g=arguments[2],f=arguments[3],e={duration:this.AnimationsSpeed.fallDown.duration,curve:this.curve},h=0;
if(this.dir=="left"){c.reverse();}c.forEach(function(k,j){(function(){if(j==c.length-1){e.callback=function(){d.empty().adopt(g);e.callback=null;if(this.dir=="left"){g.reverse();
}g.forEach(function(l,i){h=d.getSize().y+(g[i].getSize().y/(i+1))+25;moofx(g).style({bottom:h,position:"relative",top:"inherit"});(function(){if(i==g.length-1){e.callback=function(){g.set("style",null);
f.callback.call(this);};}moofx(g[i]).animate({bottom:0},e);}).delay(i*this.AnimationsSpeed.fallDown.delay,this);},this);}.bind(this);}moofx(k).style({position:"relative"});
h=d.getSize().y+(k.getSize().y/(j+1))+25;moofx(k).animate({top:h,bottom:"inherit"},e);}).delay(j*this.AnimationsSpeed.fallDown.delay,this);},this);},floatUp:function(){var d=arguments[0],c=arguments[1],g=arguments[2],f=arguments[3],e={duration:this.AnimationsSpeed.floatUp.duration,curve:this.curve},h=0;
if(this.dir=="left"){c.reverse();}c.forEach(function(k,j){(function(){if(j==c.length-1){e.callback=function(){d.empty().adopt(g);e.callback=null;if(this.dir=="left"){g.reverse();
}g.forEach(function(l,i){h=d.getSize().y+(g[i].getSize().y/(i+1))+25;moofx(g).style({top:h,position:"relative",bottom:"inherit"});(function(){if(i==g.length-1){e.callback=function(){g.set("style",null);
f.callback.call(this);};}moofx(g[i]).animate({top:0},e);}).delay(i*this.AnimationsSpeed.floatUp.delay,this);},this);}.bind(this);}moofx(k).style({position:"relative"});
h=d.getSize().y+(k.getSize().y/(j+1))+25;moofx(k).animate({bottom:h,top:"inherit"},e);}).delay(j*this.AnimationsSpeed.floatUp.delay,this);},this);},scaleOut:function(){var d=arguments[0],c=arguments[1],g=arguments[2],f=arguments[3],e={duration:this.AnimationsSpeed.scaleOut.duration,curve:this.curve};
if(this.dir=="left"){c.reverse();}c.forEach(function(j,h){(function(){if(h==c.length-1){e.callback=function(){d.empty().adopt(g);e.callback=null;if(this.dir=="left"){g.reverse();
}g.forEach(function(k,i){moofx(g).style({transform:"scale(0)",opacity:0});if(i==g.length-1){e.callback=f.callback||function(){};}(function(){moofx(g[i]).animate({transform:"scale(1)",opacity:1},e);
}).delay(i*this.AnimationsSpeed.scaleOut.delay,this);},this);}.bind(this);}moofx(j).style({"transform-origin":"center"});moofx(j).animate({transform:"scale(0)",opacity:0},e);
}).delay(h*this.AnimationsSpeed.scaleOut.delay,this);},this);},scaleIn:function(){var d=arguments[0],c=arguments[1],g=arguments[2],f=arguments[3],e={duration:this.AnimationsSpeed.scaleIn.duration,curve:this.curve};
if(this.dir=="left"){c.reverse();}d.store("overflow",d.getStyle("overflow"));d.setStyle("overflow","visible");c.forEach(function(j,h){(function(){if(h==c.length-1){e.callback=function(){d.empty().adopt(g);
e.callback=null;if(this.dir=="left"){g.reverse();}g.forEach(function(k,i){moofx(g).style({transform:"scale(1.5)",opacity:0});if(i==g.length-1){e.callback=function(){d.setStyle("overflow",null);
f.callback.call(this);};}(function(){moofx(g[i]).animate({transform:"scale(1)",opacity:1},e);}).delay(i*this.AnimationsSpeed.scaleIn.delay,this);},this);
}.bind(this);}moofx(j).style({"transform-origin":"center"});moofx(j).animate({transform:"scale(1.5)",opacity:0},e);}).delay(h*this.AnimationsSpeed.scaleIn.delay,this);
},this);}};a.prototype.Animations=b;this.RokSprocket.Strips=a;})());