(function(e){jQuery.fn.extend({slimScrollHorizontal:function(t){var n={wheelStep:20,height:"auto",width:"250px",size:"7px",color:"#208BBD",position:"bottom",distance:"1px",start:"left",opacity:1,alwaysVisible:false,disableFadeOut:false,railVisible:false,railColor:"#333",railOpacity:"0.2",railClass:"slimScrollRail",barClass:"slimScrollBar",wrapperClass:"slimScrollDiv",allowPageScroll:false,scroll:0,touchScrollStep:200};var r=e.extend(n,t);this.each(function(){function w(e,t,n){var i=e;if(g.css("left")=="auto"){g.css("left","0px")}if(t){i=parseInt(g.css("left"))+e*parseInt(r.wheelStep)/100*g.outerWidth();var s=d.outerWidth()-g.outerWidth();i=Math.min(Math.max(i,0),s);g.css({left:i+"px"})}f=parseInt(g.css("left"))/(d.outerWidth()-g.outerWidth());i=f*(d[0].scrollWidth-d.outerWidth());if(n){i=e;var u=i/d[0].scrollWidth*d.outerWidth();g.css({left:u+"px"})}d.scrollLeft(i);x();T()}function S(){a=Math.max(d.outerWidth()/d[0].scrollWidth*d.outerWidth(),h);g.css({width:a+"px"})}function x(){S();clearTimeout(s);if(f==~~f){p=r.allowPageScroll;if(l!=f){var e=~~f==0?"left":"right";d.trigger("slimscroll",e)}}l=f;if(a>=d.outerWidth()){p=true;return}g.stop(true,true).fadeIn("fast");if(r.railVisible){m.stop(true,true).fadeIn("fast")}}function T(){if(!r.alwaysVisible){s=setTimeout(function(){if(!(r.disableFadeOut&&t)&&!n&&!i){g.fadeOut("slow");m.fadeOut("slow")}},1e3)}}var t,n,i,s,u,a,f,l,c="<div></div>",h=30,p=false;var d=e(this);if(d.parent().hasClass("slimScrollDiv")){if(scroll){g=d.parent().find(".slimScrollBar");m=d.parent().find(".slimScrollRail");w(d.scrollLeft()+parseInt(scroll),false,true)}return}var v=e(c).addClass(r.wrapperClass).css({position:"relative",overflow:"hidden",width:r.width,height:r.height});d.css({overflow:"hidden",width:r.width,height:r.height});var m=e(c).addClass(r.railClass).css({width:"100%",height:r.size,position:"absolute",bottom:0,display:r.alwaysVisible&&r.railVisible?"block":"none","border-radius":r.size,background:r.railColor,opacity:r.railOpacity,zIndex:90});var g=e(c).addClass(r.barClass).css({background:r.color,height:r.size,position:"absolute",bottom:0,opacity:r.opacity,display:r.alwaysVisible?"block":"none","border-radius":r.size,BorderRadius:r.size,MozBorderRadius:r.size,WebkitBorderRadius:r.size,zIndex:99});var y=r.position=="top"?{top:r.distance}:{bottom:r.distance};m.css(y);g.css(y);d.wrap(v);d.parent().append(g);d.parent().append(m);g.draggable({axis:"x",containment:"parent",start:function(){i=true},stop:function(){i=false;T()},drag:function(t){w(0,e(this).position().left,false)}});m.hover(function(){x()},function(){T()});g.hover(function(){n=true},function(){n=false});d.hover(function(){t=true;x();T()},function(){t=false;T()});d.bind("touchstart",function(e,t){if(e.originalEvent.touches.length){u=e.originalEvent.touches[0].pageX}});d.bind("touchmove",function(e){e.originalEvent.preventDefault();if(e.originalEvent.touches.length){var t=(u-e.originalEvent.touches[0].pageX)/r.touchScrollStep;w(t,true)}});var b=function(e){if(!t){return}var e=e||window.event;var n=0;if(e.wheelDelta){n=-e.wheelDelta/120}if(e.detail){n=e.detail/3}w(n,true);if(e.preventDefault&&!p){e.preventDefault()}if(!p){e.returnValue=false}};var E=function(){if(window.addEventListener){this.addEventListener("DOMMouseScroll",b,false);this.addEventListener("mousewheel",b,false)}else{document.attachEvent("onmousewheel",b)}};E();S();if(r.start=="right"){g.css({left:d.outerWidth()-g.outerWidth()});w(0,true)}else if(typeof r.start=="object"){w(e(r.start).position().left,null,true);if(!r.alwaysVisible){g.hide()}}});return this}});jQuery.fn.extend({slimscrollHorizontal:jQuery.fn.slimScrollHorizontal})})(jQuery)