/*
 * jQuery UI Slider 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Slider
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.mouse.js
 *	jquery.ui.widget.js
 */

(function(d){d.widget("ui.slider",d.ui.mouse,{widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var a=this,b=this.options,c=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f=b.values&&b.values.length||1,e=[];this._mouseSliding=this._keySliding=!1;this._animateOff=!0;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+
this.orientation+" ui-widget ui-widget-content ui-corner-all"+(b.disabled?" ui-slider-disabled ui-disabled":""));this.range=d([]);if(b.range){if(b.range===!0){if(!b.values)b.values=[this._valueMin(),this._valueMin()];if(b.values.length&&b.values.length!==2)b.values=[b.values[0],b.values[0]]}this.range=d("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(b.range==="min"||b.range==="max"?" ui-slider-range-"+b.range:""))}for(var g=c.length;g<f;g+=1)e.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
this.handles=c.add(d(e.join("")).appendTo(a.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(a){a.preventDefault()}).hover(function(){b.disabled||d(this).addClass("ui-state-hover")},function(){d(this).removeClass("ui-state-hover")}).focus(function(){b.disabled?d(this).blur():(d(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),d(this).addClass("ui-state-focus"))}).blur(function(){d(this).removeClass("ui-state-focus")});this.handles.each(function(a){d(this).data("index.ui-slider-handle",
a)});this.handles.keydown(function(b){var c=!0,e=d(this).data("index.ui-slider-handle"),f,i,g;if(!a.options.disabled){switch(b.keyCode){case d.ui.keyCode.HOME:case d.ui.keyCode.END:case d.ui.keyCode.PAGE_UP:case d.ui.keyCode.PAGE_DOWN:case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(c=!1,!a._keySliding&&(a._keySliding=!0,d(this).addClass("ui-state-active"),f=a._start(b,e),f===!1))return}g=a.options.step;f=a.options.values&&a.options.values.length?i=a.values(e):
i=a.value();switch(b.keyCode){case d.ui.keyCode.HOME:i=a._valueMin();break;case d.ui.keyCode.END:i=a._valueMax();break;case d.ui.keyCode.PAGE_UP:i=a._trimAlignValue(f+(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.PAGE_DOWN:i=a._trimAlignValue(f-(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(f===a._valueMax())return;i=a._trimAlignValue(f+g);break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(f===a._valueMin())return;i=a._trimAlignValue(f-g)}a._slide(b,
e,i);return c}}).keyup(function(b){var c=d(this).data("index.ui-slider-handle");if(a._keySliding)a._keySliding=!1,a._stop(b,c),a._change(b,c),d(this).removeClass("ui-state-active")});this._refreshValue();this._animateOff=!1},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();return this},_mouseCapture:function(a){var b=
this.options,c,f,e,g,h;if(b.disabled)return!1;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c=this._normValueFromMouse({x:a.pageX,y:a.pageY});f=this._valueMax()-this._valueMin()+1;g=this;this.handles.each(function(b){var a=Math.abs(c-g.values(b));f>a&&(f=a,e=d(this),h=b)});b.range===!0&&this.values(1)===b.min&&(h+=1,e=d(this.handles[h]));if(this._start(a,h)===!1)return!1;this._mouseSliding=!0;g._handleIndex=h;e.addClass("ui-state-active").focus();
b=e.offset();this._clickOffset=!d(a.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:a.pageX-b.left-e.width()/2,top:a.pageY-b.top-e.height()/2-(parseInt(e.css("borderTopWidth"),10)||0)-(parseInt(e.css("borderBottomWidth"),10)||0)+(parseInt(e.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(a,h,c);return this._animateOff=!0},_mouseStart:function(){return!0},_mouseDrag:function(a){var b=this._normValueFromMouse({x:a.pageX,y:a.pageY});this._slide(a,
this._handleIndex,b);return!1},_mouseStop:function(a){this.handles.removeClass("ui-state-active");this._mouseSliding=!1;this._stop(a,this._handleIndex);this._change(a,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b;this.orientation==="horizontal"?(b=this.elementSize.width,a=a.x-this.elementOffset.left-(this._clickOffset?
this._clickOffset.left:0)):(b=this.elementSize.height,a=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0));b=a/b;b>1&&(b=1);b<0&&(b=0);this.orientation==="vertical"&&(b=1-b);a=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+b*a)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};if(this.options.values&&this.options.values.length)c.value=this.values(b),c.values=this.values();return this._trigger("start",a,c)},_slide:function(a,
b,c){var d;if(this.options.values&&this.options.values.length){d=this.values(b?0:1);if(this.options.values.length===2&&this.options.range===!0&&(b===0&&c>d||b===1&&c<d))c=d;c!==this.values(b)&&(d=this.values(),d[b]=c,a=this._trigger("slide",a,{handle:this.handles[b],value:c,values:d}),this.values(b?0:1),a!==!1&&this.values(b,c,!0))}else c!==this.value()&&(a=this._trigger("slide",a,{handle:this.handles[b],value:c}),a!==!1&&this.value(c))},_stop:function(a,b){var c={handle:this.handles[b],value:this.value()};
if(this.options.values&&this.options.values.length)c.value=this.values(b),c.values=this.values();this._trigger("stop",a,c)},_change:function(a,b){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[b],value:this.value()};if(this.options.values&&this.options.values.length)c.value=this.values(b),c.values=this.values();this._trigger("change",a,c)}},value:function(a){if(arguments.length)this.options.value=this._trimAlignValue(a),this._refreshValue(),this._change(null,0);else return this._value()},
values:function(a,b){var c,f,e;if(arguments.length>1)this.options.values[a]=this._trimAlignValue(b),this._refreshValue(),this._change(null,a);else if(arguments.length)if(d.isArray(arguments[0])){c=this.options.values;f=arguments[0];for(e=0;e<c.length;e+=1)c[e]=this._trimAlignValue(f[e]),this._change(null,e);this._refreshValue()}else return this.options.values&&this.options.values.length?this._values(a):this.value();else return this._values()},_setOption:function(a,b){var c,f=0;if(d.isArray(this.options.values))f=
this.options.values.length;d.Widget.prototype._setOption.apply(this,arguments);switch(a){case "disabled":b?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.propAttr("disabled",!0),this.element.addClass("ui-disabled")):(this.handles.propAttr("disabled",!1),this.element.removeClass("ui-disabled"));break;case "orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);
this._refreshValue();break;case "value":this._animateOff=!0;this._refreshValue();this._change(null,0);this._animateOff=!1;break;case "values":this._animateOff=!0;this._refreshValue();for(c=0;c<f;c+=1)this._change(null,c);this._animateOff=!1}},_value:function(){var a=this.options.value;return a=this._trimAlignValue(a)},_values:function(a){var b,c;if(arguments.length)b=this.options.values[a],b=this._trimAlignValue(b);else{b=this.options.values.slice();for(c=0;c<b.length;c+=1)b[c]=this._trimAlignValue(b[c])}return b},
_trimAlignValue:function(a){if(a<=this._valueMin())return this._valueMin();if(a>=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b;a-=c;Math.abs(c)*2>=b&&(a+=c>0?b:-b);return parseFloat(a.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var a=this.options.range,b=this.options,c=this,f=!this._animateOff?b.animate:!1,e,g={},h,l,j,k;if(this.options.values&&this.options.values.length)this.handles.each(function(a){e=
(c.values(a)-c._valueMin())/(c._valueMax()-c._valueMin())*100;g[c.orientation==="horizontal"?"left":"bottom"]=e+"%";d(this).stop(1,1)[f?"animate":"css"](g,b.animate);if(c.options.range===!0)if(c.orientation==="horizontal"){if(a===0)c.range.stop(1,1)[f?"animate":"css"]({left:e+"%"},b.animate);if(a===1)c.range[f?"animate":"css"]({width:e-h+"%"},{queue:!1,duration:b.animate})}else{if(a===0)c.range.stop(1,1)[f?"animate":"css"]({bottom:e+"%"},b.animate);if(a===1)c.range[f?"animate":"css"]({height:e-h+
"%"},{queue:!1,duration:b.animate})}h=e});else{l=this.value();j=this._valueMin();k=this._valueMax();e=k!==j?(l-j)/(k-j)*100:0;g[c.orientation==="horizontal"?"left":"bottom"]=e+"%";this.handle.stop(1,1)[f?"animate":"css"](g,b.animate);if(a==="min"&&this.orientation==="horizontal")this.range.stop(1,1)[f?"animate":"css"]({width:e+"%"},b.animate);if(a==="max"&&this.orientation==="horizontal")this.range[f?"animate":"css"]({width:100-e+"%"},{queue:!1,duration:b.animate});if(a==="min"&&this.orientation===
"vertical")this.range.stop(1,1)[f?"animate":"css"]({height:e+"%"},b.animate);if(a==="max"&&this.orientation==="vertical")this.range[f?"animate":"css"]({height:100-e+"%"},{queue:!1,duration:b.animate})}}});d.extend(d.ui.slider,{version:"1.8.16"})})(jQuery);
