/*
 * AnythingSlider Slide FX
 * By Rob Garrison (aka Mottie & Fudgey)
 * Dual licensed under the MIT and GPL licenses.
 */
(function($){$.fn.anythingSliderFx=function(options){var wrap=$(this).closest('.anythingSlider'),sliderWidth=wrap.width(),sliderHeight=wrap.height(),getBaseFx=function(size){return{'top':[{inFx:{top:0},outFx:{top:'-'+(size||sliderHeight)}}],'bottom':[{inFx:{bottom:0},outFx:{bottom:(size||sliderHeight)}}],'left':[{inFx:{left:0},outFx:{left:'-'+(size||sliderWidth)}}],'right':[{inFx:{right:0},outFx:{right:(size||sliderWidth)}}],'fade':[{inFx:{opacity:1,time:500},outFx:{opacity:0,time:500}}],'expand':[{inFx:{width:'100%',top:'0%',left:'0%'},outFx:{width:(size||'10%'),top:'50%',left:'50%'}}],'listLR':[{inFx:{left:0,opacity:1},outFx:[{left:(size||sliderWidth),opacity:0},{left:'-'+(size||sliderWidth),opacity:0}],selector:[':odd',':even']}],'listRL':[{inFx:{left:0,opacity:1},outFx:[{left:(size||sliderWidth),opacity:0},{left:'-'+(size||sliderWidth),opacity:0}],selector:[':even',':odd']}],'caption-Top':[{inFx:{top:0,opacity:0.8,zIndex:10},outFx:{top:('-'+size||-50),opacity:0,zIndex:0}}],'caption-Right':[{inFx:{right:0,opacity:0.8,zIndex:10},outFx:{right:('-'+size||-150),opacity:0,zIndex:0}}],'caption-Bottom':[{inFx:{bottom:0,opacity:0.8,zIndex:10},outFx:{bottom:('-'+size||-50),opacity:0,zIndex:0}}],'caption-Left':[{inFx:{left:0,opacity:0.8,zIndex:10},outFx:{left:('-'+size||-150),opacity:0,zIndex:0}}]};};return this.each(function(){var baseFx=getBaseFx(),defaults={easing:'swing',timeIn:400,timeOut:350};var hideOffscreen=function(el){el.each(function(){if(!$(this).closest('.panel').is('.activePage')){$(this).hide();}});};var animateFx=function(el,opt,isOut){if(el.length===0||typeof opt=='undefined'){return;}
var o=opt[0]||opt,s=o[1]||'',t=parseInt(((s==='')?o.time:o[0].time),10);if(isOut){if(el.css('position')!=='absolute'){el.css({position:'relative'});}
el.stop();if(s!==''){el.filter(opt[1][0]).animate(o[0],{queue:false,duration:t,easing:o[0].easing});el.filter(opt[1][1]).animate(s,{queue:false,duration:t,easing:o[0].easing,complete:function(){setTimeout(function(){hideOffscreen(el);},defaults.timeOut);}});return;}}
if(!isOut){el.show();}
el.animate(o,{queue:false,duration:t,easing:o.easing,complete:function(){if(isOut){setTimeout(function(){hideOffscreen(el);},defaults.timeOut);}}});};var getFx=function(opts,isOut){var tmp,bfx2,ex=(isOut)?'outFx':'inFx',bfx={},time=(isOut)?defaults.timeOut:defaults.timeIn,fx=$.trim(opts[0].replace(/\s+/g,' ')).split(' ');if(isOut&&fx.length==1&&baseFx.hasOwnProperty(fx)&&typeof(baseFx[fx][0].selector)!=='undefined'){bfx2=baseFx[fx][0].outFx;bfx2[0].time=opts[2]||defaults.timeOut;bfx2[0].easing=opts[3]||defaults.easing;return[bfx2,baseFx[fx][0].selector||[]];}
$.each(fx,function(i,f){if(baseFx.hasOwnProperty(f)){tmp=(typeof opts[1]=='undefined')?baseFx:getBaseFx(opts[1]);$.extend(true,bfx,tmp[f][0][ex]);bfx.time=opts[2]||bfx.time||time;bfx.easing=opts[3]||defaults.easing;}});return[bfx];};$(this).bind('slide_init',function(e,slider){var page=slider.$currentPage,lastPage=slider.$lastPage;if(page.is('.cloned')){var tar=(slider.currentPage==slider.pages)?slider.pages:1;page=page.add(lastPage).add(slider.$items.eq(tar));}else{page=page.add(lastPage);}
for(var el in options){if(el=='outFx'){for(var elOut in options.outFx){if(page.find(elOut)){animateFx(page.find(elOut),options.outFx[elOut],true);}}}else if(el!=='inFx'){if($.isArray(options[el])){animateFx(page.find(el),getFx(options[el],true),true);}}}}).bind('slide_complete',function(e,slider){var page=slider.$currentPage;if(page.is('.cloned')){var tar=(slider.currentPage==slider.pages)?slider.pages:1;page=slider.$items.eq(tar);}
for(var el in options){if(el=='inFx'){for(var elIn in options.inFx){if(page.find(elIn)){animateFx(page.find(elIn),options.inFx[elIn],false);}}}else if(el!='outFx'&&$.isArray(options[el])){if(page.find(el)){animateFx(page.find(el),getFx(options[el],false),false);}}}});});};})(jQuery);
