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