(function(a){jQuery.fn.extend({slimScroll:function(c){var b=c;this.each(function(){var y,t,i,n,j="<div></div>",v=30,q=30,p=b||{},u=p.width||"auto",r=p.height||"250px",m=p.size||"7px",s=p.color||"#000",C=p.position||"right",g=p.opacity||0.7;var B=a(this);var h=a(j).css({position:"relative",overflow:"hidden",width:u,height:r}).attr({"class":"slimScrollDiv"});B.css({overflow:"hidden",width:u,height:r});var d=a(j).css({width:"15px",height:"100%",position:"relative",top:0});var w=a(j).attr({"class":"slimScrollBar ",style:"border-radius: "+m}).css({background:s,width:m,position:"absolute",top:0,opacity:g,display:"visible",BorderRadius:m,MozBorderRadius:m,WebkitBorderRadius:m,zIndex:99});var e=(C=="right")?{right:"1px"}:{left:"1px"};d.css(e);w.css(e);var l=Math.max((B.outerHeight()/B[0].scrollHeight)*B.outerHeight(),v);w.css({height:l+"px"});B.wrap(h);B.parent().append(w);B.parent().append(d);w.draggable({axis:"y",containment:"parent",start:function(){i=true},stop:function(){i=false;k()},drag:function(o){x(0,a(this).position().top,false)}});d.hover(function(){f()},function(){k()});w.hover(function(){t=true},function(){t=false});B.hover(function(){y=true;f();k()},function(){y=false;k()});var A=function(o){if(!y){return}var o=o||window.event;var D=0;if(o.wheelDelta){D=-o.wheelDelta/120}if(o.detail){D=o.detail/3}x(0,D,true);if(o.preventDefault){o.preventDefault()}o.returnValue=false};var x=function(o,G,D){var F=G;if(D){F=w.position().top+G*q;F=Math.max(F,0);var E=B.outerHeight()-w.outerHeight();F=Math.min(F,E);w.css({top:F+"px"})}percentScroll=parseInt(w.position().top)/(B.outerHeight()-w.outerHeight());F=percentScroll*(B[0].scrollHeight-B.outerHeight());B.scrollTop(F);f()};var z=function(){if(window.addEventListener){this.addEventListener("DOMMouseScroll",A,false);this.addEventListener("mousewheel",A,false)}else{document.attachEvent("onmousewheel",A)}};z();var f=function(){clearTimeout(n);w.fadeIn("fast")};var k=function(){n=setTimeout(function(){if(!t&&!i){w.fadeOut("slow")}},1000)}});return this}});jQuery.fn.extend({slimscroll:jQuery.fn.slimScroll})})(jQuery);
