/*! 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: 1.3.8 * */ (function(e){e.fn.extend({slimscroll:function(f){var a=e.extend({width:"auto",height:"250px",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysvisible:!1,disablefadeout:!1,railvisible:!1,railcolor:"#333",railopacity:.2,raildraggable:!0,railclass:"slimscrollrail",barclass:"slimscrollbar",wrapperclass:"slimscrolldiv",allowpagescroll:!1,wheelstep:20,touchscrollstep:200,borderradius:"7px",railborderradius:"7px"},f);this.each(function(){function v(d){if(r){d=d||window.event; var c=0;d.wheeldelta&&(c=-d.wheeldelta/120);d.detail&&(c=d.detail/3);e(d.target||d.srctarget||d.srcelement).closest("."+a.wrapperclass).is(b.parent())&&n(c,!0);d.preventdefault&&!k&&d.preventdefault();k||(d.returnvalue=!1)}}function n(d,g,e){k=!1;var f=b.outerheight()-c.outerheight();g&&(g=parseint(c.css("top"))+d*parseint(a.wheelstep)/100*c.outerheight(),g=math.min(math.max(g,0),f),g=0=b.outerheight()?k=!0:(c.stop(!0, !0).fadein("fast"),a.railvisible&&m.stop(!0,!0).fadein("fast"))}function p(){a.alwaysvisible||(b=settimeout(function(){a.disablefadeout&&r||y||z||(c.fadeout("slow"),m.fadeout("slow"))},1e3))}var r,y,z,b,a,u,l,c,k=!1,b=e(this);if(b.parent().hasclass(a.wrapperclass)){var q=b.scrolltop(),c=b.siblings("."+a.barclass),m=b.siblings("."+a.railclass);x();if(e.isplainobject(f)){if("height"in f&&"auto"==f.height){b.parent().css("height","auto");b.css("height","auto");var h=b.parent().parent().height();b.parent().css("height", h);b.css("height",h)}else"height"in f&&(h=f.height,b.parent().css("height",h),b.css("height",h));if("scrollto"in f)q=parseint(a.scrollto);else if("scrollby"in f)q+=parseint(a.scrollby);else if("destroy"in f){c.remove();m.remove();b.unwrap();return}n(q,!1,!0)}}else if(!(e.isplainobject(f)&&"destroy"in f)){a.height="auto"==a.height?b.parent().height():a.height;q=e("
").addclass(a.wrapperclass).css({position:"relative",overflow:"hidden",width:a.width,height:a.height});b.css({overflow:"hidden", width:a.width,height:a.height});var m=e("
").addclass(a.railclass).css({width:a.size,height:"100%",position:"absolute",top:0,display:a.alwaysvisible&&a.railvisible?"block":"none","border-radius":a.railborderradius,background:a.railcolor,opacity:a.railopacity,zindex:90}),c=e("
").addclass(a.barclass).css({background:a.color,width:a.size,position:"absolute",top:0,opacity:a.opacity,display:a.alwaysvisible?"block":"none","border-radius":a.borderradius,borderradius:a.borderradius,mozborderradius:a.borderradius, webkitborderradius:a.borderradius,zindex:99}),h="right"==a.position?{right:a.distance}:{left:a.distance};m.css(h);c.css(h);b.wrap(q);b.parent().append(c);b.parent().append(m);a.raildraggable&&c.bind("mousedown",function(a){var b=e(document);z=!0;t=parsefloat(c.css("top"));pagey=a.pagey;b.bind("mousemove.slimscroll",function(a){currtop=t+a.pagey-pagey;c.css("top",currtop);n(0,c.position().top,!1)});b.bind("mouseup.slimscroll",function(a){z=!1;p();b.unbind(".slimscroll")});return!1}).bind("selectstart.slimscroll", function(a){a.stoppropagation();a.preventdefault();return!1});m.hover(function(){w()},function(){p()});c.hover(function(){y=!0},function(){y=!1});b.hover(function(){r=!0;w();p()},function(){r=!1;p()});b.bind("touchstart",function(a,b){a.originalevent.touches.length&&(a=a.originalevent.touches[0].pagey)});b.bind("touchmove",function(b){k||b.originalevent.preventdefault();b.originalevent.touches.length&&(n((a-b.originalevent.touches[0].pagey)/a.touchscrollstep,!0),a=b.originalevent.touches[0].pagey)}); x();"bottom"===a.start?(c.css({top:b.outerheight()-c.outerheight()}),n(0,!0)):"top"!==a.start&&(n(e(a.start).position().top,null,!0),a.alwaysvisible||c.hide());window.addeventlistener?(this.addeventlistener("dommousescroll",v,!1),this.addeventlistener("mousewheel",v,!1)):document.attachevent("onmousewheel",v)}});return this}});e.fn.extend({slimscroll:e.fn.slimscroll})})(jquery);