(function(b){b.fn.XQSlide=function(t){b.XQ=b.XQ||{};b.XQ.Slide=b.XQ.Slide||{};var a={autoplay:!0,carousel:!0,interval:3E3,clickable:!0,startIndex:1,onPlay:null,onPause:null,onStop:null,onPrevious:null,onNext:null,onRotate:null,ContainerSelector:".xqslide-container",NavigationSelector:".xqslide-navigation",ToolbarSelector:".xqslide-toolbar",ItemSelector:".xqslide-item",pauseOnHover:!1,transition:"default"};b.XQ.Slide.Transitions={transitions:{"default":function(){this.getCurrentPane().hide();this.getActivePane().show();
this.finish()},fade:function(e){var e=b.extend({fadeInSpeed:444,fadeOutSpeed:444},e),a=this;this.getCurrentPane().show().fadeOut(Math.min(e.fadeInSpeed,e.fadeOutSpeed));this.getActivePane().stop(!0,!0).fadeIn(e.fadeInSpeed,function(){a.finish()})},slide:function(e){var e=b.extend({Speed:1E3,Direction:"horizontal",easing:"swing"},e),f=this,c=this.getPanes(),k=this.getContainer(),n=k.find(".xqslider:eq(0)"),m=this.getIndex(),l=this.getCurrentIndex(),p=e.Direction=="horizontal"||e.Direction=="random"&
Math.round(Math.random())||e.Direction!="vertical"&e.Direction!="random",i=p?k.innerWidth():k.innerHeight(),g=i*c.length,d=i*m*-1,o=l*i*-1,q=!1,h=g*-1;c.css({position:"relative","float":"left"}).show();c.parent(".xqslider").length||(c.wrapAll('<div class="xqslider"></div>'),n=k.find(".xqslider:eq(0)"));k=f.log[f.log.length-1];a.carousel&k!="show"&&(m==c.length-1&l==0?(d=i,k=="next"&&(h=0,d=i*(c.length-1)*-1),q=!0):m==0&l==c.length-1&&(o=i,k=="previous"&&(h=0,o=i*-1),q=!0));f.log=[];p?(n.stop(!0,!0).css({width:g,
marginLeft:o}),q&&c.last().stop(!0,!0).css({left:h}),d={marginLeft:d}):(n.stop(!0,!0).css({width:i,height:g,marginTop:o}),q&&c.last().stop(!0,!0).css({top:h}),d={marginTop:d});n.stop(!0,!0).animate(d,e.Speed,e.easing,function(){p?n.css({width:i,left:0}):n.css({height:i,top:0});f.setPaneStyles(m);f.finish()})}},addTransition:function(a,f){b.XQ.Slide.Transitions.transitions[a]=f},doTransition:function(a,f){var c=b.XQ.Slide.Transitions.validateTransition(a,f,a.getIndex());b.XQ.Slide.Transitions.transitions[c.name].call(a,
c)},validateTransition:function(a,f,c){a=f;typeof a=="object"&&f[c]!=void 0&&(a=f[c]);if(a.name==void 0)typeof a=="string"?a={name:a}:a.name="default";if(a.name=="random"){var f=0,k;for(k in b.XQ.Slide.Transitions.transitions)f++;f=Math.floor(Math.random()*f);c=0;for(k in b.XQ.Slide.Transitions.transitions){if(c==f){a={name:k};break}c++}}if(b.XQ.Slide.Transitions.transitions[a.name]==void 0)a.name="default";return a}};var r=function(e,f){var c,k,n=[],m="",l,p=0,i=[],g=this,d={Started:!1,Stopped:!1,
RotationStopped:!1,Paused:!1,Rotation:!1};this.log=[];b.extend(this,{getSlideShow:function(){return e},getContainer:function(){return k},getIndex:function(){return l},getCurrentIndex:function(){return p},getStates:function(){return d},getTabs:function(a){if(typeof a=="number")return b("a",n).not(".next, .previous").eq(a);return b("a",n).not(".next, .previous")},getActiveTab:function(){return this.getTabs(l)},getCurrentTab:function(){return this.getTabs(p)},getInactiveTabs:function(){return this.getTabs().not(this.getActiveTab())},
getPanes:function(){return c},getActivePane:function(){return c.eq(l)},getCurrentPane:function(){return c.eq(p)},getInactivePanes:function(){return c.not(this.getActivePane())},setSettings:function(j){var w=a.startIndex;b.extend(a,j||{});e.add(g);c=b(a.ItemSelector,e);k=c.parents(a.ContainerSelector);n=b(a.NavigationSelector,e);$toolbar=b(a.ToolbarSelector,e);a.startIndex=typeof j.startIndex!=void 0?s(a.startIndex-1):w;a.clickable&&c.click(function(){g.next(!0);return!1});h({Started:a.autoplay,Paused:!a.autoplay,
Stopped:!a.autoplay});a.pauseOnHover&&k.hover(this.pause,function(){!d.Rotation&!d.Stopped&!d.RotationStopped&&g.play()})},getSettings:function(){return a},getInterval:function(){if(typeof a.interval!="number")return a.interval[l];return a.interval},play:function(){window.clearTimeout(m);h({Started:!1,RotationStopped:!1,Stopped:!1,Paused:!1});b.isFunction(a.onPlay)&&a.onPlay.call(this);o()},stop:function(){window.clearTimeout(m);d.Stopped||(h({Stopped:!0,RotationStopped:!1,Paused:!1}),b.isFunction(a.onStop)&&
a.onStop.call(this),i=[],o({index:a.startIndex,random:!1}),h({Started:!1}))},pause:function(){h({Paused:!0});b.isFunction(a.onPause)&&a.onPause.call(this);window.clearTimeout(m)},show:function(j,c){j==l|d.Rotation||(window.clearTimeout(m),h({Started:!0,RotationStopped:c,Stopped:!1,Paused:!1}),g.log.push("show"),b.isFunction(a.onShow)&&a.onShow.call(this),o({index:j,random:!1}))},previous:function(j){d.Rotation||(h({Started:!0,RotationStopped:j,Stopped:!1,Paused:!1}),g.log.push("previous"),b.isFunction(a.onPrevious)&&
a.onPrevious.call(this),o({index:l-1}))},next:function(j){d.Rotation||(h({Started:!0,RotationStopped:j,Stopped:!1,Paused:!1}),g.log.push("next"),b.isFunction(a.onNext)&&a.onNext.call(this),o({index:l+1}))},setPaneStyles:function(a){var d=c.length,a=c.eq(a);c.not(a).hide();c.stop(!0,!0).each(function(a){b(this).find("object").length||b(this).css({position:"absolute"});b(this).css({zIndex:d*10-a,top:0,left:0,margin:"auto"})})},finish:function(){h({Rotation:!1});!d.Stopped&!d.Paused&!d.RotationStopped&
g.getInterval()>0?m=window.setTimeout(function(){g.next()},this.getInterval()):b(".xqslide-progress").stop(!0,!0).css({width:0})}});var o=function(j){window.clearTimeout(m);if(!d.Paused&&!d.Stopped)if(h({Rotation:!0}),d.Started){var c={index:l,random:a.random},e=!1;if(typeof j!="undefined"&&typeof j.random!="undefined")e=j.random,j.random=e;b.extend(c,j);j=c;j.index=s(j.index);q(j.index,j.random);b.isFunction(a.onRotate)&&a.onRotate.call(g);r();b.XQ.Slide.Transitions.doTransition(g,a.transition)}else g.finish(),
h({Started:!0})},q=function(b,d){var e,f=0;if(d){if(i.length==c.length&&(i=[],!a.carousel))g.stop(),e=a.startIndex;for(;e==void 0;)if(f=Math.floor(Math.random()*c.length),a.carousel&&(f=s(f)),!(f==l&i.length+1<c.length)){for(var h=0;h<i.length;h++)if(f==i[h])break;f!=i[h]&&(e=f)}}else e=s(b);i.push(e);p=l;l=e;u()},h=function(a){b.extend(d,a);r()},s=function(b){a.carousel?b>c.length-1?b=0:b<0&&(b=c.length-1):b>c.length-1?(g.stop(),b=a.startIndex):b<0&&(b=0);return b},r=function(){b("li",$toolbar).show();
var a=b(".pause",$toolbar),c=b(".play",$toolbar),e=b(".stop",$toolbar);e.find("a").removeClass("disabled");d.Started&!d.RotationStopped&&(c.hide(),a.show());d.Paused|d.RotationStopped&&(a.hide(),c.show());d.Stopped&&(a.hide(),c.show(),e.find("a").addClass("disabled"))},t=function(){var a=g.getTabs().show(),c=b(".previous",e),d=b(".next",e);c.click(function(){!b(this).parents(".disabled").length&!b(this).hasClass("disabled")&&g.previous(!0);return!1});d.click(function(){!b(this).parents(".disabled").length&&
!b(this).hasClass("disabled")&&g.next(!0);return!1});a.each(function(a){b(this).click(function(){!b(this).parents(".disabled").length&&!b(this).hasClass("disabled")&&g.show(a,!0);return!1})});u()},u=function(){g.getTabs().show();var d=b(".previous",e),f=b(".next",e),h=l,i=c.length;!a.carousel&!a.random&&(h==0?(d.addClass("disabled"),d.find("a").addClass("disabled")):(d.removeClass("disabled"),d.find("a").removeClass("disabled")),h==i-1?(f.addClass("disabled"),f.find("a").addClass("disabled")):(f.removeClass("disabled"),
f.find("a").removeClass("disabled")))},v=function(){g.slideshow_height+e.offset().top<b(document).scrollTop()?d.Paused||g.pause():!d.Stopped&d.Paused&!d.RotationStopped&!d.Rotation&&g.play()};g.setSettings(f);if(c.length>1)q(a.startIndex),p=a.startIndex,g.setPaneStyles(a.startIndex),r(),g.slideshow_height=e.height(),t(),b.isFunction(a.onInit)&&a.onInit.call(g),a.autoplay?g.play():h({Started:!0}),v(),b(window).bind("scroll",v)};return this.each(function(){var a=b(this);a.data("SlideShow")||(r=new r(b(this),
t),a.data("SlideShow",r))})}})(jQuery);
