(function(a){a.fn.thumbCarousel=function(b){var p=a("#"+b.WidgetID),c=a("#"+b.WidgetID+" ul.thumbCarousel-list"),g=a("#"+b.WidgetID+" ul.thumbCarousel-list li:first"),r=a("#"+b.WidgetID+" div.thumbCarousel-prev"),q=a("#"+b.WidgetID+" div.thumbCarousel-next"),d=0,k=null,l=false,h=false,i=false;function j(d){var a=b.SmoothDuration;if(h){a=a*(d*-1/f);c.css("left",d).animate({left:0},{queue:false,duration:a,easing:"linear",complete:function(){j(-f)}})}else{if(d<0)a-=Math.ceil(a*(d*-1/f));c.css("left",d).animate({left:-f},{queue:false,duration:a,easing:"linear",complete:function(){j(0)}})}}function e(a){b.PauseSection&&window.clearTimeout(k);var j=b.SectionDuration,i=b.SectionEasing==="linear"||b.SectionEasing===""?null:b.SectionEasing;if(h){d-=1;c.css("left",a).animate({left:-(g.outerWidth(true)*d)},{queue:false,duration:j,easing:i,complete:function(){if(a>=-g.outerWidth(true)){d=b.SectionTotal;if(b.PauseSection)k=window.setTimeout(function(){e(-f)},b.PauseSectionDuration);else e(-f)}else if(b.PauseSection)k=window.setTimeout(function(){e(c.position().left)},b.PauseSectionDuration);else e(c.position().left)}})}else{d+=1;c.css("left",a).animate({left:-(g.outerWidth(true)*d)},{queue:false,duration:j,easing:i,complete:function(){if(a*-1>=f-g.outerWidth(true)){d=0;if(b.PauseSection)k=window.setTimeout(function(){e(0)},b.PauseSectionDuration);else e(0)}else if(b.PauseSection)k=window.setTimeout(function(){e(c.position().left)},b.PauseSectionDuration);else e(c.position().left)}})}}function o(a){if(b.EnableSmooth&&!l){d=0;a=0}else d=h?d-1:d+1;l=true;i=true;var e=b.SingleStepDuration;c.css("left",a).animate({left:-(g.outerWidth(true)*d)},{queue:false,duration:e,easing:b.SectionEasing,complete:function(){i=false}})}function n(d){l=true;i=true;var f=b.SectionDuration,e=g.outerWidth()*b.ViewTotal+a.parseNumber(g.css("marginRight"))*b.ViewTotal,j=h?d+e:-(d*-1+e);c.css("left",d).animate({left:j},{queue:false,duration:f,easing:b.SectionEasing,complete:function(){i=false}})}function m(){c.stop(true);b.PauseSection&&window.clearTimeout(k)}if(b.ShowVertical)return this;var f=g.outerWidth(true)*b.SectionTotal;a("#"+b.WidgetID+" .thumbCarousel-list li:lt("+b.ViewTotal+")").clone().appendTo(c);c.width(g.outerWidth(true)*(b.SectionTotal+b.ViewTotal));var s=g.outerWidth()*b.ViewTotal+a.parseNumber(g.css("marginRight"))*(b.ViewTotal-1);p.width(s);r.click(function(){m();if(b.SingleStep){if(i)return;h=true;var a=c.position().left;if(a===0){a=-f;d=b.SectionTotal}o(a)}else if(b.EnableViewScroll){if(i)return;h=true;var a=c.position().left;if(a===0)a=-f;n(a)}else{h=false;if(b.EnableSmooth)j(c.position().left);else e(c.position().left)}});q.css("left",p.outerWidth()-q.width()-r.position().left).click(function(){m();if(b.SingleStep){if(i)return;h=false;var a=c.position().left;if(a===-f){d=0;a=0}o(a)}else if(b.EnableViewScroll){h=false;var a=c.position().left;if(a===-f)a=0;n(a)}else{h=true;if(b.EnableSmooth)j(c.position().left);else e(c.position().left)}});!b.EnableViewScroll&&a("#"+b.WidgetID+" .thumbCarousel-viewPort").click(function(){m()}).hover(function(){!l&&m()},function(){if(!l)if(b.EnableSmooth)j(c.position().left);else e(c.position().left)});if(b.EnableSmooth)j(0);else!b.EnableViewScroll&&e(0);return this}})(jQuery)
