﻿// Original portions (c) Copyright Dimebrain
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

// AjaxControlToolkit portions (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

Type.registerNamespace('DimebrainExtenders');

// Singleton DragDropManager

DimebrainExtenders._DragDrop = function()
{
    DimebrainExtenders._DragDrop.initializeBase(this);
    this._instance = null;
}
DimebrainExtenders._DragDrop.prototype =
{
    _getInstance : function()
    {
        this._instance = new AjaxControlToolkit.GenericDragDropManager();
        this._instance.initialize();
        this._instance.add_dragStart(Function.createDelegate(this, this._raiseDragStart));
        this._instance.add_dragStop(Function.createDelegate(this, this._raiseDragStop));
        return this._instance;
    }   
}
DimebrainExtenders._DragDrop.registerClass('DimebrainExtenders._DragDrop', AjaxControlToolkit._DragDropManager);
DimebrainExtenders.DragDrop = new DimebrainExtenders._DragDrop();

// Enums
DimebrainExtenders.InnerRailView = function() {}
DimebrainExtenders.InnerRailView.prototype =
{
    AsIs : 0,
    SlidingDoors : 1
}
DimebrainExtenders.InnerRailView.registerEnum('DimebrainExtenders.InnerRailView', false);

// Behavior
DimebrainExtenders.RangeSliderBehavior = function(element)
{
    DimebrainExtenders.RangeSliderBehavior.initializeBase(this, [element]);

    // Extender Properties
    this._minimum = null;
    this._maximum = null;
    this._isVertical = false;
    this._railInnerCssClass = null;
    this._railOuterCssClass = null;
    this._valueControls = null;
    this._length = 200;
    this._steps = 0;
    this._isAnimated = false;
    this._useCustomStyles = false;
    this._showInnerRail = true;
    this._showHoverStyle = true;
    this._showDragStyle = true;
    this._liveUpdate = false;
    this._innerRailView = DimebrainExtenders.InnerRailView.AsIs;
    this._allowInnerRangeDrag = true;
    this._allowRailClick = true;
    this._isReadOnly = false;
    this._referenceValueControlID = null;
    this._increment = 1;
    this._enableKeyboard = true;
    this._enableMouseWheel = true;
    this._tooltipText = '';
    
    // Private Fields
    this._textBox = null;
    this._wrapper = null;  
    this._outer = null;
    this._inner = null;
    this._handleData = null;   
    this._handleAnimationDuration =  0.1;
    this._handles = 0;
    
    // Global Handlers
    this._selectStartHandler = null;
    this._mouseUpHandler = null;
    this._mouseOutHandler = null;
    this._keyDownHandler = null;
    this._mouseWheelHandler = null;
    this._mouseOverHandler = null;
    
    // State
    this._animationPending = false;
    this._selectStartPending = false;
    this._updating = false;
    this._initialized = false;    
    this._handleUnderDrag = null;
    this._innerDrag = false;
    this._blockInnerClick = false;
}

// Handle Effects

function showHover(element, index, vertical, custom)
{
    var h = element.parentNode.childNodes[index];
    h.className = custom && custom.length > 0 ? custom :
                  vertical ? 'RangeSlider_Handle_Vertical_Hover'
                           : 'RangeSlider_Handle_Horizontal_Hover';
}

function hideHover(element, index, vertical, custom)
{
    var h = element.parentNode.childNodes[index];
    h.className = custom && custom.length > 0 ? custom :
                  vertical ? 'RangeSlider_Handle_Vertical'
                           : 'RangeSlider_Handle_Horizontal';
}

function showDrag(element, index, vertical, custom)
{
    var h = element.parentNode.childNodes[index];
    h.className = custom && custom.length > 0 ? custom :
                  vertical ? 'RangeSlider_Handle_Vertical_Down'
                           : 'RangeSlider_Handle_Horizontal_Down';
}

function hideDrag(element, index, vertical, custom)
{
    var h = element.parentNode.childNodes[index];
    h.className = custom && custom.length > 0 ? custom :
                  vertical ? 'RangeSlider_Handle_Vertical'
                           : 'RangeSlider_Handle_Horizontal';
}

// RangeSliderExtender Behavior
 
DimebrainExtenders.RangeSliderBehavior.prototype =
{
    initialize : function()
    {
        DimebrainExtenders.RangeSliderBehavior.callBaseMethod(this, 'initialize');

        this._handles = this._valueControls ? this._valueControls.length : 0;
        
        // TODO: Remove this when a better solution is found for MasterPages
        if(this._valueControls && this._referenceValueControlID)
        {
            var firstControl = this._valueControls[0].ControlID;
            var index = this._referenceValueControlID.lastIndexOf(firstControl);
            var token = this._referenceValueControlID.substring(0, index);
            
            for(var i = 0; i < this._handles; i++)
            {
                this._valueControls[i].ControlID = token + this._valueControls[i].ControlID;
            }
        }            

        this._createWrapper();
        this._createOuterRail();
        this._createHandles();
        this._createInnerRail();        
        this._setRailStyles();
        
        if(this._length)
        {
            if(!this._useCustomStyles ||
               (this._useCustomStyles && this._innerRailView != DimebrainExtenders.InnerRailView.SlidingDoors))
            {
                if(this._isVertical)
                {
                    this._outer.style.height = this._length + "px";
                }
                else
                {
                    this._outer.style.width = this._length + "px";
                }
            }
        }
        
        this._build();
        this._enforceElementPositioning();
        this._initializeSlider();
    },
    
    dispose : function()
    {
        this._disposeValueControls();
        this._disposeHandlers();
        
        if(this._isAnimated && this._handleAnimation)
        {
           this._handleAnimation.dispose();
        }
        DimebrainExtenders.RangeSliderBehavior.callBaseMethod(this, 'dispose');
    },
    
    _createWrapper : function()
    {
        this._wrapper = document.createElement("DIV");
        this._wrapper.style.position = "relative";
        this._wrapper.style.outline = "none";
    },
    
    _createOuterRail : function()
    {
        this._outer = document.createElement('DIV');
        this._outer.id = this.get_id() + '_outer';
        this._outer.style.outline = "none";        
        this._outer.tabIndex = -1;
    },
    
    _createInnerRail : function()
    {
        if(this._handles > 1 && this._showInnerRail)
        {
            this._inner = document.createElement('DIV');            
            this._inner.id = this.get_id() + '_inner';
            this._inner.style.outline = "none";        
            this._inner.tabIndex = -1;
        }    
    },
    
    _setRailStyles : function()
    {
        if(this._inner)
        {
            this._outer.className = this._isVertical ? 'RangeSlider_Rail_Vertical_Outer':
                                                       'RangeSlider_Rail_Horizontal_Outer';           
                                                  
            this._inner.className = this._isVertical? 'RangeSlider_Rail_Vertical_Inner':
                                                      'RangeSlider_Rail_Horizontal_Inner';                               
        }
        else
        {
            this._outer.className = this._isVertical? 'RangeSlider_Rail_Vertical_Inner':
                                                      'RangeSlider_Rail_Horizontal_Inner';
        }
        
        // Override with custom styles if found
        if(this._useCustomStyles)
        {
            if(this._inner && this._railInnerCssClass && this._railInnerCssClass.length > 0)
            {
                this._inner.className = this._railInnerCssClass;
            }
            
            if(this._railOuterCssClass && this._railOuterCssClass.length > 0)
            {
                this._outer.className = this._railOuterCssClass;
            }
        }
    },
    
    _createHandles : function()
    {
        for(var i = 0; i < this._handles; i++)
        {
            var handleName = this.get_id() + "_handle_" + i;            
            var v = this._isVertical;
            
            var hideStyle = '';
            var hoverStyle = '';
            var dragStyle = '';
            
            // Overwrite with custom styles if found
            if(this._useCustomStyles)
            {
                if(this._valueControls[i].HandleCssClass && this._valueControls[i].HandleCssClass.length > 0)
                {
                    hideStyle = this._valueControls[i].HandleCssClass;
                    
                    if(this._valueControls[i].HandleHoverCssClass && this._valueControls[i].HandleHoverCssClass.length > 0)
                    {
                        hoverStyle = this._valueControls[i].HandleHoverCssClass;
                    }
                    else
                    {
                        hoverStyle = hideStyle;
                    }
                    if(this._valueControls[i].HandleDragCssClass && this._valueControls[i].HandleDragCssClass.length > 0)
                    {
                        dragStyle = this._valueControls[i].HandleDragCssClass;
                    }
                    else
                    {
                        dragStyle = hideStyle;
                    }
                }
            }
            
            // Build the handle hover effects
            var onMouseHover = "onMouseOver='showHover(this, " + i + "," + v + ",\"" + hoverStyle + "\");' ";
            var onBlur = "onMouseOut='hideHover(this, " + i + "," + v + ",\"" + hideStyle + "\");' ";
            var onMouseDown = "onMouseDown='showDrag(this, " + i + "," + v + ",\"" + dragStyle + "\");' ";
            var onMouseUp = "onMouseUp='hideDrag(this, " + i + "," + v + ",\"" + hideStyle + "\");' ";
            
            // Assemble the handle markup
            var anchorStart = "<a id='" + handleName + "' ";
            var anchorEnd = "><div></div></a>";
            var hover = this._showHoverStyle ? onMouseHover + onBlur : "";         
            var down = this._showDragStyle ? onMouseDown + onMouseUp : "";         
            this._outer.innerHTML += anchorStart + hover + down + anchorEnd;
        }
        
        this._handleData = new Array(this._handles);
        for(i = 0; i < this._handles; i++)
        {
            this._handleData[i] = this._outer.childNodes[i];
            this._handleData[i].style.overflow = 'hidden'; 
            this._handleData[i].className = this._isVertical ? 'RangeSlider_Handle_Vertical':
                                                               'RangeSlider_Handle_Horizontal';      
            if(this._valueControls)
            {
                var valueControlID = this._valueControls[i].ControlID;
                if(this._useCustomStyles)
                {
                    // Overwrite with custom style if found
                    var handleStyle = this._valueControls[i].HandleCssClass;
                    if(handleStyle)
                    {
                        this._handleData[i].className = handleStyle;
                    }
                }
                this._handleData[i].ValueControlID = valueControlID;
            }
                        
            if(Sys.Browser.agent == Sys.Browser.Opera)
            {
                this._handleData[i].style.left = '0px';
                this._handleData[i].style.top = '0px';
            }
            
            // Animation
            if(this._steps < 1)
            {
                if(this._isAnimated)
                {
                    var animation =  new AjaxControlToolkit.Animation.LengthAnimation(
                    this._handleData[i],this._handleAnimationDuration, 100, 'style');
                    
                    animation.add_ended(Function.createDelegate(this, this._onAnimationEnded));
                    this._handleData[i].Animation = animation;
                }
            }
            else
            {
                this._isAnimated = false;
            }
        }
    },
    
    _onAnimationEnded : function()
    {
        this._initializeInnerRail();
    },
    
    _build : function()
    {
        this._textBox = this.get_element();        
        this._textBox.parentNode.insertBefore(this._wrapper, this._textBox);
        this._wrapper.appendChild(this._outer);
        if(this._inner && this._showInnerRail)
        {
           this._outer.appendChild(this._inner);
        }
        this._textBox.style.display = 'none';
    },
    
    _initializeSlider : function()
    {
        DimebrainExtenders.DragDrop.registerDropTarget(this);
        
        this._initializeHandles();
        this._initializeHandlers();
        this._initializeInnerRail();
        this._initialized = true;
        
        this._raiseEvent('load');    
    },
    
    _initializeHandles : function()
    {
        for(var i = 0; i < this._handles; i++)
        {
            var handle = this._handleData[i];
            var decimalPlaces = this._valueControls[i].DecimalPlaces
            
            this._initializeValueControl(handle.ValueControlID, decimalPlaces, handle);
            this._initializeHandleValue(handle);
            this._setHandlePosition(handle, true);
            this._initializeDragHandle(handle);
        }    
    },
    
    _initializeInnerRail : function()
    {
        // TODO: Add support for multiple inner rails between multiple handles in future release
        if(this._inner && this._showInnerRail)
        {        
            var handle = this._handleData[0];
            var lastHandle = this._handles > 1 ? this._handleData[this._handles - 1] : null;
            
            // Set the inner rail
            if(lastHandle)
            {
                var handleWidth = parseInt(this._getBoundsInternal(handle).width);
                var handleLeft = this._isVertical ? parseInt(handle.style.top) : parseInt(handle.style.left);
                var handleRight = this._isVertical ? parseInt(lastHandle.style.top) : parseInt(lastHandle.style.left);
                
                if(this._isVertical)
                {
                    this._inner.style.top = handleLeft + "px";
                    this._inner.style.height = handleRight + handleWidth - handleLeft + "px";
                }
                else
                {
                    this._inner.style.left = handleLeft + "px";
                    this._inner.style.width = (handleRight + handleWidth - handleLeft) +  "px";
                }
                
                // Slide the door
                if(this._innerRailView == DimebrainExtenders.InnerRailView.SlidingDoors)
                {
                    this._inner.style.backgroundPosition = this._isVertical ? "0 -" + handleLeft + "px" 
                                                                            : "-" + handleLeft + "px 0";
                }
            }           
        }
    },
    
    _initializeDragHandle : function(handle)
    {
        var dragHandle = handle.DragHandle = document.createElement('DIV');
        
        dragHandle.style.position = 'absolute';
        dragHandle.style.width = '1px';
        dragHandle.style.height = '1px';
        dragHandle.style.overflow = 'hidden';
        dragHandle.style.zIndex = '999';
        dragHandle.style.background = 'none';
        
        document.body.appendChild(handle.DragHandle);
    },
    
    _setHandlePosition : function(handle, allowAnimation)
    {
        var min = this._minimum;
        var max = this._maximum;
        var value = handle.Value;
        
        var animate = this._isAnimated && this._animationPending && allowAnimation;
        var handleBounds = this._getBoundsInternal(handle);
        var railBounds = this._getOuterBounds();
        
        if(handleBounds.width <= 0 && railBounds.width <= 0)
        {
           handleBounds.width = parseInt($common.getCurrentStyle(handle, 'width'));
           railBounds.width = parseInt($common.getCurrentStyle(this._outer, 'width'));
           if(handleBounds.width <= 0 || railBounds.width <= 0)
           {
               throw Error.argument('width', "You must specify a CSS width and height for all handle styles as well as the rail."); 
           }
        }

        var extent = max - min;
        var fraction = (value - min) / extent;
        var o = Math.round(fraction * (railBounds.width - handleBounds.width));
        
        var offset = (value == min) ? 0
                   : (value == max) ? (railBounds.width - handleBounds.width)
                   : o;
        
        if(animate)
        {
            handle.Animation.set_startValue(handleBounds.x - railBounds.x);
            handle.Animation.set_endValue(offset);
            handle.Animation.set_propertyKey(this._isVertical ? 'top' : 'left');
            handle.Animation.play();
            
            this._animationPending = false;
        }
        else
        {        
            if(this._isVertical)
            {
                handle.style.top = offset + 'px';
            }
            else
            {
                handle.style.left = offset + 'px';
            }
        }
    },    
    
    _initializeHandleValue : function(handle)
    {
        var handleValue;
        try
        {
            var valueControl = $get(handle.ValueControlID);
            handleValue = parseFloat(valueControl.value);
        }
        catch(ex)
        {
            handleValue = Number.NaN;
        }
        
        if(handleValue != Number.NaN)
        {
            handle.Value = handleValue;
        }
        else
        {
            handle.Value = 0;
        }
    },     
    
    _initializeValueControl : function(valueControlID, decimalPlaces, handle)
    {
        if(valueControlID)
        {
            var valueControl = $get(valueControlID);
            
            valueControl.Handle = handle;
            valueControl.DecimalPlaces = decimalPlaces;
            valueControl.OldValue = valueControl.value;
            valueControl.onchange = "setValue(this, " + valueControl.value + ")";
            if(!valueControl.DecimalPlaces)
            {
                valueControl.DecimalPlaces = 0;
            }            
            
            var isInput = valueControl && valueControl.nodeName == 'INPUT';
            if(isInput)
            {
                valueControl.KeyPressHandler = Function.createDelegate(this, this._onValueControlKeyPressed);
                $addHandler(valueControl, 'keypress', valueControl.KeyPressHandler);
            }
        }
    },
    
    _disposeValueControls : function()
    {
        if(this._valueControls)
        {
            for(var i = 0; i < this._handles; i++)
            {
                var valueControl = this._valueControls[i];
                var isInput = valueControl && valueControl.nodeName == 'INPUT';
                
                if(isInput)
                {
                    $removeHandler(valueControl, 'keypress', valueControl.KeyPressHandler);
                }
            }
        }
    },
    
    _onValueControlKeyPressed : function(e)
    {
        var event = new Sys.UI.DomEvent(e);
        if(event.charCode == 13)
        {
            this._animationPending = true;
            var valueControl = event.target;
            this._setValueFromValueControl(valueControl);
            this._initializeInnerRail();
            event.preventDefault();
        }
    },
    
    _setValueFromValueControl : function(valueControl)
    {
        this._updating = true;        
        if(valueControl)
        {   
            if(!this._isReadOnly)
            {
                this._calculateValueControlValue(valueControl);
            }
            else
            {
                this._setValueControlValue(valueControl, valueControl.OldValue);
            }
        }
        this._updating = false;
    },
    
    _calculateValueControlValue : function(valueControl, mouseOffset, computed)
    {
        var secondaryHandle;
        var secondaryValueControl;
        
        if(this._handleUnderDrag && !valueControl)
        {
            handle = this._handleUnderDrag;
            valueControl = $get(this._handleUnderDrag.ValueControlID);    
            if(this._innerDrag)
            {
                var primary = this._indexOf(this._handleData, handle);                
                secondaryHandle = this._handleData[primary + 1];
                if(!secondaryHandle)
                {
                    // On the last handle; use the previous instead
                    secondaryHandle = this._handleData[primary - 1];
                }
                secondaryValueControl = $get(secondaryHandle.ValueControlID);
            }
        }
        
        var handle = valueControl.Handle;
        var value = valueControl.value;        
        
        if(value && !computed)
        {
            if(!Number.isInstanceOfType(value))
            {
                try
                {
                    value = parseFloat(value);
                }
                catch(ex)
                {
                    value = Number.NaN;
                }
            }

            if(isNaN(value))
            {
                value = this._minimum;
            }
            
            val = (value < this._minimum) ? this._minimum
                : (value > this._maximum) ? this._maximum
                : value;
        }
        else
        {                
            var min = this._minimum; 
            var max = this._maximum;
            var handleBounds = this._getBoundsInternal(handle);
            var railBounds = this._getOuterBounds();    
               
            var mark = (mouseOffset) ? mouseOffset - handleBounds.width / 2 
                                      : handleBounds.x - railBounds.x;
            var extent = railBounds.width - handleBounds.width;
            var percent = mark / extent;
            
            val = (mark == 0) ? min
                : (mark == (railBounds.width - handleBounds.width)) ? max
                : min + percent * (max - min);
        }
        
        // Steps
        if(this._steps > 0)
        {
            val = this._getNearestStepValue(val);
        }
        
        // Range constraints
        val = (val < this._minimum) ? this._minimum
            : (val > this._maximum) ? this._maximum
            : val;
            
        // Collision
        var previousControls = new Array();
        var nextControls = new Array();
        var cp = 0; var cn = 0; var block;        
        var prev = true;
        for(var i = 0; i < this._handles; i++)
        {
            var vc = this._valueControls[i];
            if(!vc.ControlID.match(valueControl.id))
            {
                if(prev)
                {
                    previousControls[cp] = this._valueControls[i];
                    cp++;
                }
                else
                {
                    nextControls[cn] = this._valueControls[i];
                    cn++;
                }
            }
            else
            {
                prev = false;
            }
        }        
        if(cp > 0)
        {
            var p = parseFloat($get(previousControls[cp-1].ControlID).value);
            if(p >= val)
            {
                val = p;
                block = true;
            }
        }
        if(cn > 0)
        {
            var n = parseFloat($get(nextControls[0].ControlID).value);
            if(n <= val)
            {
                val = n;
                block = true;
            }
        }      
            
        if(secondaryHandle)
        {
            var delta = val - parseFloat(value);
            var secondaryValue = parseFloat(secondaryValueControl.value);
            var secondaryVal = secondaryValue + delta;
            
            // Find next maximum if there are other handles
            var nextIndex = this._indexOf(this._handleData, secondaryHandle) + 1;
            if(nextIndex < this._valueControls.length)
            {
                var nextValueControlID = this._valueControls[nextIndex].ControlID;
            }
            if(nextValueControlID)
            {
                var nextValueControl = $get(nextValueControlID);
            }
            if(nextValueControl)
            {
                var nextValue = nextValueControl.value;
            }
                                    
            if(secondaryVal > (nextValue || this._maximum))
            {
                secondaryVal = secondaryValue;
                val = value;
                block = true;
            }
        }
                
        if(!block && (val < max && val > min))
        {
            this._updating = true;
            this._setValueControlValue(valueControl, val);
            if(secondaryHandle)
            {
                this._setValueControlValue(secondaryValueControl, secondaryVal);
            }
            this._updating = false;
        }
        else
        {
            valueControl.value = val;
            handle.Value = val;
            this._setHandlePosition(handle, true);
            
            if(secondaryHandle)
            {
                secondaryValueControl.value = secondaryVal;
                secondaryHandle.Value = secondaryVal;
                this._setHandlePosition(secondaryHandle, true);
            }
        }                
        return val;
    },
    
    _getNearestStepValue : function(value)
    {
        if(this._steps == 0) return value;
        
        var extent = this._maximum - this._minimum;
        if (extent == 0) return value;
        
        if((this._steps - 1) != 0)
        {
            var delta = extent / (this._steps - 1);
        }
        else
        {
            return value;
        }

        return Math.round(value / delta) * delta;
    },
    
    _setValueControlValue : function(valueControl, value)
    {
        var oldValue = valueControl.OldValue;
        var newValue = value;
        
        if(oldValue == newValue && this._isReadOnly)
        {
            valueControl.value = oldValue;
        }
        else
        {
            if(!this._updating)
            {
                newValue = this._calculateValueControlValue(valueControl);
            }
            
            valueControl.value = newValue.toFixed(valueControl.DecimalPlaces);
            this._ensureBinding(valueControl);
                        
            if(!Number.isInstanceOfType(valueControl.value))
            {
                try
                {
                    valueControl.value = parseFloat(valueControl.value);
                }
                catch(ex)
                {
                    valueControl.value = Number.NaN;
                }
            }
            
            if(this._tooltipText)
            {
                var handle = valueControl.Handle;
                handle.alt = handle.title = String.format(this._tooltipText, valueControl.value);
            }
        
            if(this._initialized)
            {
                valueControl.Handle.Value = newValue;
                this._setHandlePosition(valueControl.Handle, true);
                        
                if(this._updating)
                {
                    if(this._liveUpdate)
                    {
                        this._raiseElementChangedEvent();
                    }
                }
                            
                if(valueControl.value != oldValue)
                {
                    valueControl.OldValue = valueControl.value;
                    this._initializeInnerRail();
                    
                    // Prevent click after drag
                    if(this._innerDrag)
                    {
                        this._blockInnerClick = true;
                    }                
                    this._raiseEvent('valueChanged');
                }
            }
        }
    },
    
    _raiseElementChangedEvent : function()
    {
        var element = this.get_element();
        if (document.createEvent)
        {
            var onchangeEvent = document.createEvent('HTMLEvents');
            onchangeEvent.initEvent('change', true, false);
            element.dispatchEvent(onchangeEvent);
        } 
        else if(document.createEventObject)
        {
            element.fireEvent('onchange');
        }
    },
    
    _ensureBinding : function(valueControl)
    {
        if(valueControl)
        {
            var value = valueControl.value;
            
            if(value >= this._minimum || value <= this._maximum)
            {
                var isInputElement = valueControl && valueControl.nodeName == 'INPUT';
                
                if(isInputElement)
                {
                    valueControl.value = value;
                }
                else if(valueControl)
                {
                    valueControl.innerHTML = value;
                }
            }
        }
    },    
    
    _enforceElementPositioning : function()
    {
        var tbPosition = 
            {
                position: this.get_element().style.position,
                top: this.get_element().style.top,
                right: this.get_element().style.right,
                bottom: this.get_element().style.bottom,
                left: this.get_element().style.left
            };
        
        if(tbPosition.position != '')
        {
           this._railElement.style.position = tbPosition.position;
        }
        if(tbPosition.top != '')
        {
            this._railElement.style.top = tbPosition.top;
        }
        if(tbPosition.right != '')
        {
           this._railElement.style.right = tbPosition.right;
        }
        if(tbPosition.bottom != '')
        {
           this._railElement.style.bottom = tbPosition.bottom;
        }
        if(tbPosition.left != '')
        {
            this._railElement.style.left = tbPosition.left;
        }
    },
    
    _initializeHandlers : function()
    {
        if(!this._isReadOnly)
        {
            // Global Handlers
            this._selectStartHandler = Function.createDelegate(this, this._onSelectStart);
            this._mouseUpHandler = Function.createDelegate(this, this._onMouseUp);
            this._mouseOutHandler = Function.createDelegate(this, this._onMouseOut);
            this._mouseWheelHandler = Function.createDelegate(this, this._onMouseWheel);
            this._mouseOverHandler = Function.createDelegate(this, this._onMouseOver);
            this._keyDownHandler = Function.createDelegate(this, this._onKeyDown)
            
            $addHandler(document, 'mouseup', this._mouseUpHandler);
            $addHandler(document, 'mouseout', this._mouseOutHandler);
            
            // Mouse wheel support
            if(this._outer.addEventListener && this._enableMouseWheel)
            {
                this._outer.addEventListener('DOMMouseScroll', this._mouseWheelHandler, false);
            }
            else
            {
                this._outer.attachEvent('onmousewheel', this._mouseWheelHandler);
            }
            
            for(var i = 0; i < this._handles; i++)
            {
                $addHandlers(this._handleData[i], 
                {
                    'mousedown': this._onMouseDown,
                    'dragstart': this._IEDragDropHandler,
                    'drag': this._IEDragDropHandler,
                    'dragend': this._IEDragDropHandler
                },
                this);
            }
            
            $addHandlers(this._outer, 
            {
                'click': this._onOuterRailClick,
                'mouseover': this._mouseOverHandler,
                'keydown' : this._keyDownHandler
            },
            this);
        
            if(this._inner && this._showInnerRail)
            {
                $addHandlers(this._inner,
                {
                    'click': this._onInnerRailClick,
                    'mousedown': this._onMouseDownInner,
                    'mouseout': this._onMouseOutInner,
                    'dragstart': this._IEDragDropHandler,
                    'drag': this._IEDragDropHandler,
                    'dragend': this._IEDragDropHandler
                },
                this);
            }
        }
    },
    
    _disposeHandlers : function()
    {
        if(!this._isReadOnly)
        {
            // Global Handlers
            $removeHandler(document, 'mouseup', this._mouseUpHandler);
            $removeHandler(document, 'mouseout', this._mouseOutHandler);            
            
            $removeHandler(this._outer, 'click', this._onOuterRailClick);
            $removeHandler(this._outer, 'keydown', this._keyDownHandler);
            $removeHandler(this._outer, 'mouseover', this._keyDownHandler);
            
            if(this._outer.addEventListener)
            {
                this._outer.removeEventListener('DOMMouseScroll', this._mouseWheelHandler, false);
            }
            else
            {
                this._outer.detachEvent('onmousewheel', this._mouseWheelHandler);
            }
            
            
            for(var i = 0; i < this._handles; i++)
            {
                var handle = this._handleData[i];
                
                $removeHandler(handle, 'mousedown', this._onMouseDown);
                $removeHandler(handle, 'dragstart', this._IEDragDropHandler);
                $removeHandler(handle, 'drag', this._IEDragDropHandler);
                $removeHandler(handle, 'dragend', this._IEDragDropHandler);
            }
            
            if(this._inner && this._showInnerRail)
            {
                $removeHandler(this._inner, 'click', this._onInnerRailClick);
                $removeHandler(this._inner, 'mousedown', this._onMouseDownInner);
                $removeHandler(this._inner, 'mouseout', this._onMouseOutInner);
                $removeHandler(this._inner, 'dragstart', this._IEDragDropHandler);
                $removeHandler(this._inner, 'drag', this._IEDragDropHandler);
                $removeHandler(this._inner, 'dragend', this._IEDragDropHandler);
            }
            
            this._mouseUpHandler = null;
            this._mouseOutHandler = null;
            this._keyDownHandler = null;
            this._mouseWheelHandler = null;
            this._selectStartHandler = null;
        }
    },
    
    _cancelDrag : function()
    {
        if(DimebrainExtenders.RangeSliderBehavior.DropPending == this)
        {
            DimebrainExtenders.RangeSliderBehavior.DropPending = null;            
            if(this._selectStartPending)
            {
                $removeHandler(document, 'selectstart', this._selectStartHandler);
            }
        }
    },
    
    _handleDecrement : function()
    {
        // Test the first handle first
        var valueControlID = this._handleData[0].ValueControlID;
        if(this._decrementValueControl(valueControlID))
        {
            // Decrement
            for(var i = 1; i < this._handles; i++)
            {
                valueControlID = this._handleData[i].ValueControlID;
                this._decrementValueControl(valueControlID)
            }
        }                    
        this._initializeInnerRail();
    },
    
    _handleIncrement : function()
    {
        // Test the last handle first
        var valueControlID = this._handleData[this._handles-1].ValueControlID;
        if(this._incrementValueControl(valueControlID))
        {
            // Increment
            for(var i = 0; i < this._handles - 1; i++)
            {
                valueControlID = this._handleData[i].ValueControlID;
                this._incrementValueControl(valueControlID);
            }
        }
        this._initializeInnerRail();
    },
    
    _onMouseOver : function(e)
    {
        this._outer.focus();
    },
    
    _onMouseWheel : function(e)
    {
        var delta = 0;
        if(e.wheelDelta)
        {
            delta = e.wheelDelta / 120;
            if(Sys.Browser.agent == Sys.Browser.Opera)
            {
                delta = -delta;
            }
        }
        else if (e.detail)
        {
            delta = -e.detail / 3;
        }    
        
        if(delta)
        {
            if(delta > 0)
            {
                this._handleIncrement();
            }
            else
            {
                this._handleDecrement();
            }
        }
        
        if(e.preventDefault)
        {
            e.preventDefault();
        }
        return false;
    },
    
    _onMouseUp : function(e)
    {
        var event = new Sys.UI.DomEvent(e);
        window._event = event;    
        event.preventDefault();
        
        this._cancelDrag();
    },
    
    _onMouseOut : function(e)
    {
        var event = new Sys.UI.DomEvent(e);
        window._event = event;    
        event.preventDefault();
        
        if(this._handleUnderDrag)
        {
            this._cancelDrag();
        }
    },
    
    _onMouseOutInner : function(e)
    {
        var event = new Sys.UI.DomEvent(e);
        window._event = event;    
        event.preventDefault();
        
        if(this._innerDrag)
        {
            this._cancelDrag();
        }
    },
    
    _onMouseDown : function(e)
    {
        var event = new Sys.UI.DomEvent(e);
        window._event = event;    
        event.preventDefault();
        
        if(!DimebrainExtenders.RangeSliderBehavior.DropPending)
        {
            DimebrainExtenders.RangeSliderBehavior.DropPending = this;
            
            $addHandler(document, 'selectstart', this._selectStartHandler);
            this._selectStartPending = true;            
            
            var handle = event.target;
            this._startDragDrop(handle);
        }
    },
    
    _onKeyDown : function(e)
    {
        if(this._enableKeyboard)
        {
            this._handleKeyDown(e);
        }
    }, 
    
    _handleKeyDown : function(e)
    {
        var event = new Sys.UI.DomEvent(e);
        window._event = event; 
        
        var handled = false;
        switch(event.keyCode || event.rawEvent.keyCode)
        {
            case Sys.UI.Key.up:
            case Sys.UI.Key.left:
                if(!handled)
                {   
                    this._handleDecrement();
                    event.preventDefault();
                    handled = true;
                }
                return false;
            case Sys.UI.Key.down:
            case Sys.UI.Key.right:
                if(!handled)
                {
                    this._handleIncrement();
                    event.preventDefault();
                    handled = true;
                }
                return false;
            default:
                return false;
        }
    },
    
     _getStepValues : function()
    {
        var steps = new Array(this._steps);
        var extent = this._maximum - this._minimum;
        steps[0] = this._minimum;
        for(var i = 1; i < this._steps; i++)
        {
            steps[i] = (extent / (this._steps - 1)) * i;
        }
        return steps;
    },
    
    _decrementValueControl : function(valueControlID)
    {
        var valueControl = $get(valueControlID);
        var oldValue = valueControl.value;
        var newValue;
        if(this._steps > 0)
        {
            var stepValues = this._getStepValues();
            var oldStep = this._getNearestStepValue(oldValue);
            newValue = oldStep;
            for(var i = this._steps - 1; i > -1; i--)
            {
                if(stepValues[i] < oldStep)
                {
                    newValue = stepValues[i];
                    break;
                }
            }
        }
        else
        {
            newValue = parseFloat(valueControl.value) - parseFloat(this._increment);
        }
        valueControl.value = newValue;
        this._setValueFromValueControl(valueControl);
        return valueControl.value == newValue;
    },
    
    _incrementValueControl : function(valueControlID)
    {
        var valueControl = $get(valueControlID);
        var oldValue = valueControl.value;
        var newValue;
        if(this._steps > 0)
        {
            var stepValues = this._getStepValues();
            var oldStep = this._getNearestStepValue(oldValue);
            newValue = oldStep;    
            for(var i = 0; i < this._steps; i++)
            {
                if(stepValues[i] > oldStep)
                {
                    newValue = stepValues[i];
                    break;
                }
            }
        }
        else
        {
            newValue = parseFloat(valueControl.value) + parseFloat(this._increment);
        }
        valueControl.value = newValue;
        this._setValueFromValueControl(valueControl);
        return valueControl.value == newValue;
    },
    
    _onMouseDownInner : function(e)
    {
        var event = new Sys.UI.DomEvent(e);
        window._event = event;    
        event.preventDefault();
        
        if(this._allowInnerRangeDrag)
        {
            if(!DimebrainExtenders.RangeSliderBehavior.DropPending)
            {
                DimebrainExtenders.RangeSliderBehavior.DropPending = this;
                
                $addHandler(document, 'selectstart', this._selectStartHandler);
                this._selectStartPending = true;            
                
                // Dragging inner handles
                this._innerDrag = true;
               
                // Get nearest primary handle
                var offset = this._calculateInnerRailOffset(event);
                var handle = this._calculateClosestHandle(offset);
                
                // Start drag
                this._startDragDrop(handle);
            }
        }
    },    
    
    // DragDrop
    
    _startDragDrop : function(handle)
    {
        this._resetDragHandle(handle);
        this._handleUnderDrag = handle;
        
        DimebrainExtenders.DragDrop.startDragDrop(this, handle.DragHandle, null);
    },
    
    // IDragSource
    
    get_dragDataType : function()
    {        
        return 'HTML';
    },
    
    getDragData : function()
    {
        return this._handleUnderDrag;
    },
    
    get_dragMode : function()
    {       
        return AjaxControlToolkit.DragMode.Move;
    },
    
    onDragStart : function()
    {
        this._resetDragHandle(this._handleUnderDrag);
        this._raiseEvent('dragStart');
    },
    
    onDrag : function()
    {
        var dragHandleBounds = this._getBoundsInternal(this._handleUnderDrag.DragHandle);
        var handleBounds = this._getBoundsInternal(this._handleUnderDrag);
        var railBounds = this._getOuterBounds();
        
        var handlePosition;
        if(this._isVertical)
        {
            handlePosition = { y:dragHandleBounds.x - railBounds.x, x:0 };
        }
        else
        {
            handlePosition = { x:dragHandleBounds.x - railBounds.x, y:0 };
        }
        
        $common.setLocation(this._handleUnderDrag, handlePosition);        
                
        this._calculateValueControlValue(null, null, true);
        
        if(this._steps > 1)
        {
            this._setHandlePosition(this._handleUnderDrag, false);
        }
        this._raiseEvent('drag');
    },
        
    onDragEnd : function()
    {
        this._initializeInnerRail();
        if(!this._liveUpdate)
        {
            this._raiseElementChangedEvent();
        }
        this._innerDrag = false;
        this._handleUnderDrag = null;
        this._raiseEvent('dragEnd');
    },
    
    // IDropTarget
   
    get_dropTargetElement : function()
    {
        return document.body;
    },
        
    canDrop : function(dragMode, dataType)
    {
        return dataType == 'HTML';
    },
    
    drop : Function.emptyMethod,
    
    onDragEnterTarget : Function.emptyMethod,
    
    onDragLeaveTarget : Function.emptyMethod,
    
    onDragInTarget : Function.emptyMethod,
    
    _resetDragHandle : function(handle)
    {
        var handleBounds = $common.getBounds(handle);        
        $common.setLocation(handle.DragHandle, {x:handleBounds.x, y:handleBounds.y});
    },
    
    _onOuterRailClick : function(e)
    {
        if(this._allowRailClick)
        {
            var event = new Sys.UI.DomEvent(e);
            var target = event.target;
            
            if(target == this._outer)
            {
                this._animationPending = true;
                this._onOuterRailClicked(event);    
            }
        }
    },
    
    _onOuterRailClicked : function(event)
    {
        var offset = this._isVertical ? event.offsetY : event.offsetX;
        
        this._calculateClick(offset);
    },
    
    _onInnerRailClick : function(e)
    {
        if(this._allowRailClick)
        {
            var event = new Sys.UI.DomEvent(e);
            var target = event.target;
            
            if(target == this._inner && !this._blockInnerClick)
            {
                this._animationPending = true;
                this._onInnerRailClicked(event);    
            }
            else
            {
                this._blockInnerClick = false;
            }
        }
    },
    
    _onInnerRailClicked : function(event)
    {
        var offset = this._calculateInnerRailOffset(event);
        this._calculateClick(offset);
    },
    
    _calculateInnerRailOffset : function(event)
    {
        var edge = this._isVertical ? this._inner.style.top : this._inner.style.left;
        var offset = this._isVertical ? event.offsetY : event.offsetX;
        offset += parseInt(edge);
        
        return offset;
    },
    
    _calculateClick : function(offset)
    {
        var railBounds = this._getOuterBounds();
        var closestHandle = this._handleData[0];
        var handleBounds = this._getBoundsInternal(closestHandle);
        closestHandle = this._calculateClosestHandle(offset);
        
        var minOffset = handleBounds.width / 2;
        var maxOffset = railBounds.width - minOffset;
        
        offset = (offset < minOffset) ? minOffset 
               : (offset > maxOffset) ? maxOffset
               : offset;
        
        var valueControl = $get(closestHandle.ValueControlID);
        this._calculateValueControlValue(valueControl, offset, true);
        this._raiseElementChangedEvent();
    },
    
    _calculateClosestHandle : function(offset)
    {
        var closestHandle = this._handleData[0];
        var distances = new Array(this._handles);
        for(var i = 0; i < this._handles; i++)
        {
            var handle = this._handleData[i];
            var bounds = this._getBoundsInternal(handle);
            var pos = this._isVertical? handle.offsetTop : bounds.x;
            distances[i] = Math.abs(pos - offset);
        }
        
        var delta = distances[0];
        for(i = 0; i < this._handles; i++)
        {
            var d = distances[i];
            if(d < delta)
            {
                handle = this._handleData[i];
                delta = d;
                closestHandle = handle;
            }
        }
        
        // Determine precedent inner range
        if(this._innerDrag)
        {
            var index = this._indexOf(this._handleData, closestHandle);
            var location = Sys.UI.DomElement.getLocation(closestHandle);
            var locationOffset = this._isVertical? location.y : location.x;
            
            if(locationOffset >= (offset + distances[index]))
            {
                // Get the handle before the one we chose
                var newHandle = this._handleData[index - 1];
                if(newHandle)
                {
                    closestHandle = newHandle;
                }
            }
        }
        return closestHandle;
    },
    
    _IEDragDropHandler : function(e)
    {
        var event = new Sys.UI.DomEvent(e);
        event.preventDefault();
    },
    
    _onSelectStart : function(e)
    {
        var event = new Sys.UI.DomEvent(e);
        event.preventDefault();
    },    
   
    // Helper Methods
    
    _getOuterBounds : function()
    {
        return this._getBoundsInternal(this._outer);
    },
    
    _getInnerBounds : function()
    {
        return this._getBoundsInternal(this._inner);
    },
    
    _getBoundsInternal : function(element)
    {
        var bounds = $common.getBounds(element);
        if(this._isVertical)
        {
             bounds = { x : bounds.y, 
                        y : bounds.x, 
                        height : bounds.width, 
                        width : bounds.height, 
                        right : bounds.right,
                        bottom : bounds.bottom,
                        location : {x:bounds.y, y:bounds.x},
                        size : {width:bounds.height, height:bounds.width}
                      };
        }
        return bounds;
    },
    
    _raiseEvent : function(eventName, eventArgs)
    {
        var handler = this.get_events().getHandler(eventName);
        if (handler)
        {
            if (!eventArgs)
            {
                eventArgs = Sys.EventArgs.Empty;
            }
            handler(this, eventArgs);
        }
    },
    
    _indexOf : function(array, object)
    {
        // IE doesn't support the indexOf function on arrays
        for(var i = 0; i < array.length; i++)
        {
            if(array[i] == object)
            {
                return i;
            }
        }
        return -1;
    },   

    // Property Accessors
    
    get_Minimum : function()
    {
        return this._minimum;
    },

    set_Minimum : function(value)
    {
        if(value != this._minimum)
        {
            this._minimum = value;
            this.raisePropertyChanged('minimum');
        }
    },
    
    get_Maximum : function()
    {
        return this._maximum;
    },

    set_Maximum : function(value)
    {
        if(value != this._maximum)
        {
            this._maximum = value;
            this.raisePropertyChanged('maximum');
        }
    },
    
    get_Length : function()
    {
        return this._length;
    },

    set_Length : function(value)
    {
        if(value != this._length)
        {
            this._length = value;
            this.raisePropertyChanged('length');
        }
    },
    
    get_Steps : function()
    {
        return this._steps;
    },

    set_Steps : function(value)
    {
        var oldValue = this._steps;
        this._steps = Math.abs(value);
        this._steps = (this._steps == 1) ? 2 : this._steps;
        if(oldValue != this._steps)
        {
            this.raisePropertyChanged('steps');
        }
    },
    
    get_RailInnerCssClass : function()
    {
        return this._railInnerCssClass;
    },

    set_RailInnerCssClass : function(value)
    {
        if(value != this._railInnerCssClass)
        {
            this._railInnerCssClass = value;
            this.raisePropertyChanged('railInnerCssClass');
        }
    },
    
    get_RailOuterCssClass : function()
    {
        return this._railOuterCssClass;
    },

    set_RailOuterCssClass : function(value)
    {
        if(value != this._railOuterCssClass)
        {
            this._railOuterCssClass = value;
            this.raisePropertyChanged('railOuterCssClass');
        }
    },
    
    get_IsVertical : function()
    {
        return this._isVertical;
    },

    set_IsVertical : function(value)
    {
        if(value != this._isVertical)
        {
            this._isVertical = value;
            this.raisePropertyChanged('isVertical');
        }
    },
    
    get_IsAnimated : function()
    {
        return this._isAnimated;
    },

    set_IsAnimated : function(value)
    {
        if(value != this._isAnimated)
        {
            this._isAnimated = value;
            this.raisePropertyChanged('isAnimated');
        }
    },
    
    get_HandleAnimationDuration : function()
    {
        return this._handleAnimationDuration;
    },

    set_HandleAnimationDuration : function(value)
    {
        if(value != this._handleAnimationDuration)
        {
            this._handleAnimationDuration = value;
            this.raisePropertyChanged('handleAnimationDuration');
        }
    },
    
    get_LiveUpdate : function()
    {
        return this._liveUpdate;
    },

    set_LiveUpdate : function(value)
    {
        if(value != this._liveUpdate)
        {
            this._liveUpdate = value;
            this.raisePropertyChanged('liveUpdate');
        }
    },
    
    get_UseCustomStyles : function()
    {
        return this._useCustomStyles;
    },

    set_UseCustomStyles : function(value)
    {
        if(value != this._useCustomStyles)
        {
            this._useCustomStyles = value;
            this.raisePropertyChanged('useCustomStyles');
        }
    },
    
    get_ShowInnerRail : function()
    {
        return this._showInnerRail;
    },

    set_ShowInnerRail : function(value)
    {
        if(value != this._showInnerRail)
        {
            this._showInnerRail = value;
            this.raisePropertyChanged('showInnerRail');
        }
    },
    
    get_ShowHandleHoverStyle : function()
    {
        return this._showHoverStyle;
    },

    set_ShowHandleHoverStyle : function(value)
    {
        if(value != this._showHoverStyle)
        {
            this._showHoverStyle = value;
            this.raisePropertyChanged('showHoverStyle');
        }
    },
    
    get_ShowHandleDragStyle : function()
    {
        return this._showDragStyle;
    },

    set_ShowHandleDragStyle : function(value)
    {
        if(value != this._showDragStyle)
        {
            this._showDragStyle = value;
            this.raisePropertyChanged('showDragStyle');
        }
    },
    
    get_InnerRailView : function()
    {
        return this._innerRailView;
    },

    set_InnerRailView : function(value)
    {
        if(value != this._innerRailView)
        {
            this._innerRailView = value;
            this.raisePropertyChanged('innerRailView');
        }
    },
    
    get_AllowInnerRailDrag : function()
    {
        return this._allowInnerRangeDrag;
    },

    set_AllowInnerRailDrag : function(value)
    {
        if(value != this._allowInnerRangeDrag)
        {
            this._allowInnerRangeDrag = value;
            this.raisePropertyChanged('allowInnerRangeDrag');
        }
    },
    
    get_AllowRailClick : function()
    {
        return this._allowRailClick;
    },

    set_AllowRailClick : function(value)
    {
        if(value != this._allowRailClick)
        {
            this._allowRailClick = value;
            this.raisePropertyChanged('allowRailClick');
        }
    },
    
    get_IsReadOnly : function()
    {
        return this._isReadOnly;
    },

    set_IsReadOnly : function(value)
    {
        if(value != this._isReadOnly)
        {
            this._isReadOnly = value;
            this.raisePropertyChanged('isReadOnly');
        }
    },
    
    get_EnableKeyboard : function()
    {
        return this._enableKeyboard;
    },

    set_EnableKeyboard : function(value)
    {
        if(value != this._enableKeyboard)
        {
            this._enableKeyboard = value;
            this.raisePropertyChanged('enableKeyboard');
        }
    },
    
    get_EnableMouseWheel : function()
    {
        return this._enableMouseWheel;
    },

    set_EnableMouseWheel : function(value)
    {
        if(value != this._enableKeyboard)
        {
            this._enableMouseWheel = value;
            this.raisePropertyChanged('enableMouseWheel');
        }
    },
    
    get_Increment : function()
    {
        return this._increment;
    },

    set_Increment : function(value)
    {
        if(value != this._increment)
        {
            this._increment = value;
            this.raisePropertyChanged('increment');
        }
    },
    
    get_ReferenceValueControlID : function()
    {
        return this._referenceValueControlID;
    },

    set_ReferenceValueControlID : function(value)
    {
        if(value != this._referenceValueControlID)
        {
            this._referenceValueControlID = value;
            this.raisePropertyChanged('referenceValueControlID');
        }
    },
    
    get_TooltipText : function()
    {
        return this._tooltipText;
    },

    set_TooltipText : function(value)
    {
        if(value != this._tooltipText)
        {
            this._tooltipText = value;
            this.raisePropertyChanged('tooltipText');
        }
    },
    
    get_ValueControls : function()
    {
        return this._valueControls;
    },

    set_ValueControls : function(value)
    {
        if(value != this._valueControls)
        {
            this._valueControls = value;
            this.raisePropertyChanged('valueControls');
        }
    },
    
    // Event Accessors
    
    add_load : function(handler)
    {
        this.get_events().addHandler('load', handler);
    },
    remove_load : function(handler)
    {
        this.get_events().removeHandler('load', handler);
    },
    
    add_dragStart : function(handler)
    {
        this.get_events().addHandler('dragStart', handler);
    },
    remove_dragStart : function(handler)
    {
        this.get_events().removeHandler('dragStart', handler);
    },
    
    add_drag : function(handler)
    {
        this.get_events().addHandler('drag', handler);
    },
    remove_drag : function(handler)
    {
        this.get_events().removeHandler('drag', handler);
    },
    
    add_dragEnd : function(handler)
    {
        this.get_events().addHandler('dragEnd', handler);
    },
    remove_dragEnd : function(handler)
    {
        this.get_events().removeHandler('dragEnd', handler);
    },
    
    add_valueChanged : function(handler)
    {
        this.get_events().addHandler('valueChanged', handler);
    },
    remove_valueChanged : function(handler)
    {
        this.get_events().removeHandler('valueChanged', handler);
    },
    
    // Client State
    getClientState : function()
    {
        var value = DimebrainExtenders.RangeSliderBehavior.callBaseMethod(this, 'get_ClientState');                
        if (value == '') value = null;
        return value;
    },
     
    setClientState : function(value)
    {
        return DimebrainExtenders.RangeSliderBehavior.callBaseMethod(this, 'set_ClientState',[value]);                
    }
}

DimebrainExtenders.RangeSliderBehavior.DropPending = null;

DimebrainExtenders.RangeSliderBehavior.registerClass('DimebrainExtenders.RangeSliderBehavior', AjaxControlToolkit.BehaviorBase);








if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();