(function(A){A.fn.extend({slider:function(C){var B=Array.prototype.slice.call(arguments,1);if(C=="value"){return A.data(this[0],"ui-slider").value(arguments[1])}return this.each(function(){if(typeof C=="string"){var D=A.data(this,"ui-slider");D[C].apply(D,B)}else{if(!A.data(this,"ui-slider")){new A.ui.slider(this,C)}}})}});A.ui.slider=function(D,C){var B=this;this.element=A(D);A.data(D,"ui-slider",this);this.element.addClass("ui-slider");this.options=A.extend({},C);var E=this.options;A.extend(E,{axis:E.axis||(D.offsetWidth<D.offsetHeight?"vertical":"horizontal"),maxValue:!isNaN(parseInt(E.maxValue,10))?parseInt(E.maxValue,10):100,minValue:parseInt(E.minValue,10)||0,startValue:parseInt(E.startValue,10)||"none"});E.realMaxValue=E.maxValue-E.minValue;E.stepping=parseInt(E.stepping,10)||(E.steps?E.realMaxValue/E.steps:0);A(D).bind("setData.slider",function(G,F,H){B.options[F]=H}).bind("getData.slider",function(G,F){return B.options[F]});this.handle=E.handle?A(E.handle,D):A("> *",D);A(this.handle).mouseInteraction({executor:this,delay:E.delay,distance:E.distance||0,dragPrevention:E.prevention?E.prevention.toLowerCase().split(","):["input","textarea","button","select","option"],start:this.start,stop:this.stop,drag:this.drag,condition:function(G,F){if(!this.disabled){if(this.currentHandle){this.blur(this.currentHandle)}this.focus(F,1);return !this.disabled}}}).wrap('<a href="javascript:void(0)"></a>').parent().bind("focus",function(F){B.focus(this.firstChild)}).bind("blur",function(F){B.blur(this.firstChild)}).bind("keydown",function(F){if(/(37|39)/.test(F.keyCode)){B.moveTo((F.keyCode==37?"-":"+")+"="+(B.options.stepping?B.options.stepping:(B.options.realMaxValue/B.size)*5),this.firstChild)}});if(E.helper=="original"&&(this.element.css("position")=="static"||this.element.css("position")=="")){this.element.css("position","relative")}if(E.axis=="horizontal"){this.size=this.element.outerWidth();this.properties=["left","width"]}else{this.size=this.element.outerHeight();this.properties=["top","height"]}this.element.bind("click",function(F){B.click.apply(B,[F])});if(!isNaN(E.startValue)){this.moveTo(E.startValue,0)}if(this.handle.length==1){this.previousHandle=this.handle}if(this.handle.length==2&&E.range){this.createRange()}};A.extend(A.ui.slider.prototype,{plugins:{},createRange:function(){this.rangeElement=A("<div></div>").addClass("ui-slider-range").css({position:"absolute"}).css(this.properties[0],parseInt(A(this.handle[0]).css(this.properties[0]),10)+this.handleSize(0)/2).css(this.properties[1],parseInt(A(this.handle[1]).css(this.properties[0]),10)-parseInt(A(this.handle[0]).css(this.properties[0]),10)).appendTo(this.element)},updateRange:function(){this.rangeElement.css(this.properties[0],parseInt(A(this.handle[0]).css(this.properties[0]),10)+this.handleSize(0)/2);this.rangeElement.css(this.properties[1],parseInt(A(this.handle[1]).css(this.properties[0]),10)-parseInt(A(this.handle[0]).css(this.properties[0]),10))},getRange:function(){return this.rangeElement?this.convertValue(parseInt(this.rangeElement.css(this.properties[1]),10)):null},ui:function(B){return{instance:this,options:this.options,handle:this.currentHandle,value:this.value(),range:this.getRange()}},propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.ui()]);this.element.triggerHandler(C=="slide"?C:"slide"+C,[B,this.ui()],this.options[C])},destroy:function(){this.element.removeClass("ui-slider ui-slider-disabled").removeData("ul-slider").unbind(".slider");this.handles.removeMouseInteraction()},enable:function(){this.element.removeClass("ui-slider-disabled");this.disabled=false},disable:function(){this.element.addClass("ui-slider-disabled");this.disabled=true},focus:function(B,C){this.currentHandle=A(B).addClass("ui-slider-handle-active");if(C){this.currentHandle.parent()[0].focus()}},blur:function(B){A(B).removeClass("ui-slider-handle-active");if(this.currentHandle&&this.currentHandle[0]==B){this.previousHandle=this.currentHandle;this.currentHandle=null}},value:function(B){if(this.handle.length==1){this.currentHandle=this.handle}return((parseInt(A(B!=undefined?this.handle[B]||B:this.currentHandle).css(this.properties[0]),10)/(this.size-this.handleSize()))*this.options.realMaxValue)+this.options.minValue},convertValue:function(B){return(B/(this.size-this.handleSize()))*this.options.realMaxValue},translateValue:function(B){return((B-this.options.minValue)/this.options.realMaxValue)*(this.size-this.handleSize())},handleSize:function(B){return A(B!=undefined?this.handle[B]:this.currentHandle)["outer"+this.properties[1].substr(0,1).toUpperCase()+this.properties[1].substr(1)]()},click:function(C){var D=[C.pageX,C.pageY];var B=false;this.handle.each(function(){if(this==C.target){B=true}});if(B||this.disabled||!(this.currentHandle||this.previousHandle)){return }if(this.previousHandle){this.focus(this.previousHandle,1)}this.offset=this.element.offset();this.moveTo(this.convertValue(C[this.properties[0]=="top"?"pageY":"pageX"]-this.offset[this.properties[0]]-this.handleSize()/2))},start:function(C,B){var D=this.options;this.offset=this.element.offset();this.handleOffset=this.currentHandle.offset();this.clickOffset={top:C.pageY-this.handleOffset.top,left:C.pageX-this.handleOffset.left};this.firstValue=this.value();this.propagate("start",C);return false},stop:function(B){this.propagate("stop",B);if(this.firstValue!=this.value()){this.propagate("change",B)}return false},drag:function(F,E){var G=this.options;var C={top:F.pageY-this.offset.top-this.clickOffset.top,left:F.pageX-this.offset.left-this.clickOffset.left};var B=C[this.properties[0]];if(B>=this.size-this.handleSize()){B=this.size-this.handleSize()}if(B<=0){B=0}if(G.stepping){var D=this.convertValue(B);D=Math.round(D/G.stepping)*G.stepping;B=this.translateValue(D)}if(this.rangeElement){if(this.currentHandle[0]==this.handle[0]&&B>=this.translateValue(this.value(1))){B=this.translateValue(this.value(1))}if(this.currentHandle[0]==this.handle[1]&&B<=this.translateValue(this.value(0))){B=this.translateValue(this.value(0))}}this.currentHandle.css(this.properties[0],B);if(this.rangeElement){this.updateRange()}this.propagate("slide",F);return false},moveTo:function(C,B){var D=this.options;if(B==undefined&&!this.currentHandle&&this.handle.length!=1){return false}if(B==undefined&&!this.currentHandle){B=0}if(B!=undefined){this.currentHandle=this.previousHandle=A(this.handle[B]||B)}if(C.constructor==String){C=/\-\=/.test(C)?this.value()-parseInt(C.replace("-=",""),10):this.value()+parseInt(C.replace("+=",""),10)}if(D.stepping){C=Math.round(C/D.stepping)*D.stepping}C=this.translateValue(C);if(C>=this.size-this.handleSize()){C=this.size-this.handleSize()}if(C<=0){C=0}if(this.rangeElement){if(this.currentHandle[0]==this.handle[0]&&C>=this.translateValue(this.value(1))){C=this.translateValue(this.value(1))}if(this.currentHandle[0]==this.handle[1]&&C<=this.translateValue(this.value(0))){C=this.translateValue(this.value(0))}}this.currentHandle.css(this.properties[0],C);if(this.rangeElement){this.updateRange()}this.propagate("start",null);this.propagate("stop",null);this.propagate("change",null)}})})(jQuery);