//START CoStar.Web.Controls.Resources.ClientScript.NumberOnlyTextBox.js
/// <reference name="MicrosoftAjax.js" />
/// <reference name="MicrosoftAjaxWebForms.js" />
/// <reference name="CoStar.Web.Controls.Resources.ClientScript.ClientRuntime.js" assembly="CoStar.Web.Controls" />

Type.registerNamespace("CoStar.Web.Controls");
CoStar.Web.Controls.WatermarkTextBox = function(element) {
    CoStar.Web.Controls.WatermarkTextBox.initializeBase(this, [element]);
    this._watermarkText = null;
    this._watermarkCssClass = null;
    this._oldClassName = null;

    this._focusDelegate = null;
    this._blurDelegate = null;
    this._keyPressDelegate = null;
    this._onsubmitDelegate = null;
    this._postbackRequestInitializedDelegate = null
};
CoStar.Web.Controls.WatermarkTextBox.prototype = {
    get_watermarkText: function() { return this._watermarkText; },
    set_watermarkText: function(value) {
        if (this._watermarkText != value) {
            this._watermarkText = value;
            var elm = this.get_element();
            if (CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(elm).get_isWatermarked()) {
                this._applyWatermark(elm);
            }
        }
    },

    get_watermarkCssClass: function() { return this._watermarkCssClass; },
    set_watermarkCssClass: function(value) {
        if (this._watermarkCssClass != value) {
            this._watermarkCssClass = value;
            var elm = this.get_element();
            if (CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(elm).get_isWatermarked()) {
                this._applyWatermark(elm);
            }
        }
    },

    initialize: function() {
        CoStar.Web.Controls.WatermarkTextBox.callBaseMethod(this, 'initialize');

        this._focusDelegate = Function.createDelegate(this, this._onFocus);
        this._blurDelegate = Function.createDelegate(this, this._onBlur);
        this._keyPressDelegate = Function.createDelegate(this, this._onKeyPress);
        var elm = this.get_element();

        this._oldClassName = elm.className;
        $addHandler(elm, "focus", this._focusDelegate);
        $addHandler(elm, "blur", this._blurDelegate);
        $addHandler(elm, "keypress", this._keyPressDelegate);

        if (this._watermarkText !== null) {
            var wrapper = CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(elm);
            var currentValue = wrapper.get_current();
            if (("" === currentValue) || (this._watermarkText === currentValue)) {
                wrapper.set_watermark(this._watermarkText)
                wrapper.set_isWatermarked(true);
            }

            elm.blur();
            this._onBlur();
        }

        this._onsubmitDelegate = Function.createDelegate(this, this._onSubmit);
        CoStar.Web.Controls.EventPool.addEvent("SubmissionStarted", this._onsubmitDelegate);

        if (typeof (Sys.WebForms) != 'undefined') {
            this._postbackRequestInitializedDelegate = Function.createDelegate(this, this._postbackRequestInitialized);
            Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(this._postbackRequestInitializedDelegate);
        }
    },
    dispose: function() {
        var elm = this.get_element();
        if (this._focusDelegate !== null) {
            $removeHandler(elm, "focus", this._focusDelegate);
            this._focusDelegate = null;
        }

        if (this._blurDelegate !== null) {
            $removeHandler(elm, "blur", this._blurDelegate);
            this._blurDelegate = null;
        }

        if (this._keyPressDelegate !== null) {
            $removeHandler(elm, "keypress", this._keyPressDelegate);
            this._keyPressDelegate = null;
        }

        if (this._watermarkText !== null) {
            // Clear watermark text to avoid confusion during Refresh/Back/Forward
            if (CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(elm).get_isWatermarked()) {
                this.clearText(false);
            }
        }

        if (this._onsubmitDelegate !== null) {
            CoStar.Web.Controls.EventPool.removeEvent("SubmissionStarted", this._onsubmitDelegate);
            this._onsubmitDelegate = null;
        }

        if (this._postbackRequestInitializedDelegate !== null) {
            Sys.WebForms.PageRequestManager.getInstance().remove_initializeRequest(this._postbackRequestInitializedDelegate);
            this._postbackRequestInitializedDelegate = null;
        }

        CoStar.Web.Controls.WatermarkTextBox.callBaseMethod(this, 'dispose');
    },

    _onSubmit: function() {
        if (this._watermarkText !== null) {
            var element = this.get_element();
            var wrapper = CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(element);

            if (wrapper.get_isWatermarked()) {
                wrapper.set_value("");
                wrapper.set_isWatermarked(false);
            }
        }
    },

    // reformat the text box values after the form body has been built.
    // this is pretty sweet. The user doesn't see a thing.
    _postbackRequestInitialized: function() {
        this.format();
    },

    clearText: function(focusing) {
        var element = this.get_element();
        var wrapper = CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(element);
        wrapper.set_value("");
        wrapper.set_isWatermarked(false);
        if (focusing) {
            element.setAttribute("autocomplete", "off");  // Avoid NS_ERROR_XPC_JS_THREW_STRING error in Firefox
            element.select();  // This fix displays the blinking cursor in a focused, empty text box in IE
        }
    },

    _onKeyPress: function(e) {
        if (this._watermarkText !== null) {
            CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(this.get_element()).set_isWatermarked(false);
        }
    },
    _onFocus: function(e) {
        if (this._watermarkText !== null) {
            this.get_element().className = this._oldClassName;
            CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(this.get_element()).set_isWatermarked(false);
        }
    },

    _applyWatermark: function(elm) {
        var wrapper = CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(elm);
        if (this._watermarkCssClass !== null) {
            elm.className = this._watermarkCssClass;
        }
        wrapper.set_watermark(this._watermarkText);
        wrapper.set_isWatermarked(true);
    },

    _onBlur: function(e) {
        this.format();
    },

    format: function() {
        var elm = this.get_element();
        var value = CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(elm).get_value();
        if (value === '') {
            if (this._watermarkText !== null) {
                this._applyWatermark(elm);
            }
        }
    }
};
CoStar.Web.Controls.WatermarkTextBox.registerClass("CoStar.Web.Controls.WatermarkTextBox", Sys.UI.Control);

CoStar.Web.Controls.NumberOnlyTextBox = function(element) {
    CoStar.Web.Controls.NumberOnlyTextBox.initializeBase(this, [element]);
    this._formatString = 'N0';
    this._unformattedValue = '';
    this._formattedValue = null;
    this._decimalSeparator = null;
    this._negativeSign = null;
    this._groupSeparator = null;
    this._isDecimalAllowed = true;
    this._isNegativeSignAllowed = true;
    this._form = null;
    this._numberOfExtraCharacters = 0;

    this._minimumValue = null; // Number.MAX_VALUE and Number.MIN_VALUE don't really mean much b/c they're exponential.
    this._maximumValue = null;

    this._customFormatMatch = null;
    this._customFormatReplace = null;
    this._customFormatRegEx = null;
    this._numberMask = null;
    this._numericRegEx = new RegExp('[^0-9]*', "g");
};

CoStar.Web.Controls.NumberOnlyTextBox.prototype = {
    get_numberMask: function() { return this._numberMask; },
    set_numberMask: function(value) { this._numberMask = value; },
    get_isNegativeSignAllowed: function() { return this._isNegativeSignAllowed; },
    set_isNegativeSignAllowed: function(value) { this._isNegativeSignAllowed = value; },
    get_customFormatMatch: function() { return this._customFormatMatch; },
    set_customFormatMatch: function(value) { this._customFormatMatch = value; },
    get_customFormatReplace: function() { return this._customFormatReplace; },
    set_customFormatReplace: function(value) { this._customFormatReplace = value; },

    get_form: function() { return this._form; },
    set_form: function(value) { this._form = value; },
    get_formatString: function() { return this._formatString; },
    set_formatString: function(value) {
        if (!this._checkFormatString(value)) {
            throw Error.format(Sys.Res.formatBadFormatSpecifier);
        }
        this._formatString = value;
    },

    get_unformattedValue: function() { return this._unformattedValue; },
    set_unformattedValue: function(value) { this._unformattedValue = value; },
    get_minimumValue: function() { return this._minimumValue; },
    set_minimumValue: function(value) { this._minimumValue = value; },
    get_maximumValue: function() { return this._maximumValue; },
    set_maximumValue: function(value) { this._maximumValue = value; },
    get_isDecimalAllowed: function() { return this._isDecimalAllowed; },
    set_isDecimalAllowed: function(value) { this._isDecimalAllowed = value; },

    _checkFormatString: function(value) {
        switch (value.charAt(0)) {
            case "d":
            case "D":
            case "p":
            case "P":
            case "n":
            case "N":
            case "c":
            case "C":
            case "R":
            case "r":
            case "M":
            case "m":
                return true;
                break;
            default:
                return false;
        }
    },

    initialize: function() {
        if (this._formatString.charAt(0).toUpperCase() === 'C') {
            this._decimalSeparator = Sys.CultureInfo.CurrentCulture.numberFormat.CurrencyDecimalSeparator;
            this._groupSeparator = Sys.CultureInfo.CurrentCulture.numberFormat.CurrencyGroupSeparator;
        }
        else {
            this._decimalSeparator = Sys.CultureInfo.CurrentCulture.numberFormat.NumberDecimalSeparator;
            this._groupSeparator = Sys.CultureInfo.CurrentCulture.numberFormat.NumberGroupSeparator;
        }
        this._negativeSign = Sys.CultureInfo.CurrentCulture.numberFormat.NegativeSign;

        CoStar.Web.Controls.NumberOnlyTextBox.callBaseMethod(this, 'initialize');

        if (this._customFormatMatch !== null) {
            this._customFormatRegEx = new RegExp(this._customFormatMatch, "i");
        }

        var elm = this.get_element();
        if (this._unformattedValue !== null && this._unformattedValue !== '') {
            var formatOutput = this._format(this._unformattedValue, elm, true);
            if (formatOutput.IsFormatted) {
                this._unformattedValue = formatOutput.Unformatted;
            }
            else {
                elm.value = '';
            }
        }
    },

    // override the base _onSubmit
    _onSubmit: function(sender, args) {
        this.unformat();
    },

    /// executed by the submit behavior registered by the server control.
    unformat: function() {
        this.get_element().value = this._unformattedValue;
    },

    _onKeyPress: function(e) {
        CoStar.Web.Controls.NumberOnlyTextBox.callBaseMethod(this, '_onKeyPress', [e]);

        // in FF, the keyCode is present when the arrows, tabs, delete, backspace, etc. is pressed.
        // we want to ignore these. IE does not work like this.
        if (Sys.Browser.agent === Sys.Browser.Firefox) {
            if (e.rawEvent.keyCode !== 0) {
                return true;
            }
        }

        var character = String.fromCharCode(e.charCode);
        var valid = ((e.charCode >= 48 && e.charCode <= 57)
            || (e.charCode === 8)
            || (e.charCode === 127)
            || (this._isDecimalSeparator(character) && this._isDecimalAllowed)
            || (this._isNegativeSign(character) && this._isNegativeSignAllowed));

        if (valid) {
            var value = e.target.value;

            if (value !== null && value !== "") {

                // check to make sure that only one decimal separator
                if (this._isDecimalSeparator(character)) {
                    // don't allow decimals in some cases or if there is a decimal point and it is selected, allow it to be over written.
                    var target = e.target;
                    if ((!this._isDecimalAllowed)
                        || (value.indexOf(this._decimalSeparator) !== -1
                            && value.substring(this._getSelectionStart(target), this._getSelectionEnd(target)).replace(/ /g, '\xa0').indexOf(this._decimalSeparator) === -1)) {
                        valid = false;
                    }
                }

                if (valid && this._isNegativeSign(character)) {
                    // check to make sure only one negative sign and that it's at the first position
                    if (this._isNegativeSignAllowed
                        && (value.length !== 0 || value.indexOf(this._negativeSign) !== -1)) {
                        // allow the negative sign to be "inserted" at the beginning.
                        var startPos = this._getSelectionStart(e.target);
                        if (startPos !== 0) {
                            valid = false;
                        }
                    }
                    else {
                        valid = false;
                    }
                }
            }
        }
        if (!valid) {
            e.preventDefault();
        }
        return valid;
    },

    _getSelectionStart: function(elm) {
        if (elm.createTextRange) {
            var r = document.selection.createRange().duplicate();
            r.moveEnd('character', elm.value.length);
            if (r.text === '') {
                return elm.value.length
            }
            return elm.value.lastIndexOf(r.text);
        }
        else {
            return elm.selectionStart;
        }
    },

    _getSelectionEnd: function(elm) {
        if (elm.createTextRange) {
            var r = document.selection.createRange().duplicate();
            r.moveStart('character', -elm.value.length);
            return r.text.length;
        }
        else {
            return elm.selectionEnd;
        }
    },

    _isNegativeSign: function(character) {
        return (character === this._negativeSign);
    },

    _isDecimalSeparator: function(character) {
        return (character === this._decimalSeparator);
    },

    _onFocus: function(e) {
        CoStar.Web.Controls.NumberOnlyTextBox.callBaseMethod(this, '_onFocus', [e]);
        var elm = this.get_element();
        elm.value = this._unformattedValue;
        if (typeof (elm.maxLength) != 'undefined'
            && elm.maxLength < 2147483647
            && elm.maxLength !== -1) {
            elm.maxLength -= this._numberOfExtraCharacters;
        }
        this._numberOfExtraCharacters = 0;
        elm.select();
    },

    clearValue: function() {
        this.get_element().value = "";
        this.format();
    },

    setValue: function(newValue) {
        if (newValue !== null && newValue !== '') {
            if (newValue != this._unformattedValue) {
                var elm = this.get_element();
                CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(elm).set_isWatermarked(false)
                elm.className = this._oldClassName;
                elm.value = newValue;
                this.format();
            }
        }
        else {
            this.clearValue();
        }
    },

    format: function() {
        CoStar.Web.Controls.NumberOnlyTextBox.callBaseMethod(this, 'format');
        var elm = this.get_element();
        var textBoxValue = elm.value;

        if (textBoxValue !== null && textBoxValue !== "") {
            // handle textbox watermarks if there are any... if there isn't one this doesn't hurt.
            if (this._watermarkText !== null && CoStar.Web.Controls.TextBoxWrapper.get_Wrapper(elm).get_isWatermarked()) {
                this._unformattedValue = '';
            }
            else {
                var formatOutput = this._format(textBoxValue, elm, false);
                if (formatOutput.IsFormatted) {
                    this._unformattedValue = formatOutput.Unformatted;
                }
                else {
                    elm.value = formatOutput.Unformatted;
                }
            }
        }
        else {
            this._unformattedValue = '';
        }
    },

    _getUnformatedValueForSafari: function() {
        var originalValue = this.get_element().value;
        if (isNaN(originalValue)) {
            return this.get_unformattedValue().toString();
        }
        else {
            var unformattedVal = Number.parseLocale(originalValue);
            this.set_unformattedValue(unformattedVal);
            return unformattedVal.toString();
        }
    },

    _format: function(textBoxValue, elm, isInitialFormatting) {
        textBoxValue = textBoxValue.toString()
        if (typeof (isInitialFormatting) == 'undefined') {
            isInitialFormatting = false;
        }

        // initially, the server assigns the invariant format of the number (i.e. English)
        // to the textbox. If we used the parseLocale here, a value like 1.12 would turn 
        // into 1,120 in the Spanish culture, but it needs to be 1.12.
        if (isInitialFormatting) {
            var parsedNumber = Number.parseInvariant(textBoxValue);
        }
        else {
            var parsedNumber = Number.parseLocaleFixed(textBoxValue.toString());
            if (isNaN(parsedNumber)) {
                parsedNumber = Number.parseInvariant(textBoxValue);
            }
        }

        if (isNaN(parsedNumber)) {
            return { "IsFormatted": false, "Unformatted": this._unformattedValue };
        }
        else {
            if (this._minimumValue !== null && parsedNumber < this._minimumValue) {
                parsedNumber = this._minimumValue;
            }
            if (this._maximumValue !== null && parsedNumber > this._maximumValue) {
                parsedNumber = this._maximumValue;
            }

            // _customFormatRegEx will only be set if the type is "R" and there was a customFormatMatch
            // value passed in.
            if (this._customFormatRegEx !== null) {
                var formattedValue = parsedNumber = textBoxValue; // not really a number, but a mask.
                formattedValue = formattedValue.replace(this._customFormatRegEx, this._customFormatReplace)

                // obtain how many characters are not digits. probably could rely on textBoxValue.toString(), but maybe not.
                var numericValue = formattedValue.replace(this._numericRegEx, '');
                this._numberOfExtraCharacters = (formattedValue.length - numericValue.length);
            }
            else if (this._numberMask !== null) {
                var formattedValue = parsedNumber = textBoxValue; // not really a number, but a mask.
                var finalValue = '';
                var maskPos = 0;
                for (var i = 0, il = formattedValue.length; i < il; i++) {
                    var num = formattedValue.charAt(i);
                    while (maskPos < this._numberMask.length && this._numberMask.charAt(maskPos) !== "#") {
                        finalValue += this._numberMask.charAt(maskPos);
                        maskPos++;
                    }
                    maskPos += 1;
                    finalValue += num.toString();
                }

                // only if we've successfully applied the mask to all masked digits, do we use the masked value.
                if (this._numberMask.indexOf("#", maskPos) == -1) {
                    formattedValue = finalValue;
                    var numericValue = formattedValue.replace(this._numericRegEx, '');
                    this._numberOfExtraCharacters = (formattedValue.length - numericValue.length);
                }
            }
            else {
                var formattedValue = parsedNumber.localeFormat(this._formatString);
                var decPos = formattedValue.indexOf(this._decimalSeparator)
                if (decPos === -1) {
                    decPos = formattedValue.length;
                }

                // sometimes after formatting the value has a space in it before the symbol (i.e "234.34 %").
                // need to be careful of countries that use a blank space as a separator.
                var blankPos = formattedValue.lastIndexOf(' ');
                if (blankPos !== -1 && blankPos > decPos) // only care about blank spaces that are after the dec. point.
                {
                    // obtain the number of decimal characters that the formatted value supports. 
                    // update the textboxvalue to the correct number of decimal places.
                    var decimalCharactersLength = formattedValue.substr(decPos, ((formattedValue.length - blankPos) + 1)).length;
                }
                else {
                    var decimalCharactersLength = formattedValue.substr(decPos).length;
                }

                // since we've converted it to a invariant number, we need to replace the decimal
                // point with the culture's.
                parsedNumber = parsedNumber.toString().replace(".", this._decimalSeparator.toString());

                var txtBoxDecPos = parsedNumber.toString().indexOf(this._decimalSeparator);
                if (txtBoxDecPos !== -1) {
                    parsedNumber = parsedNumber.toString().substr(0, txtBoxDecPos + decimalCharactersLength);
                }

                if (typeof (elm.maxLength) != 'undefined'
                && elm.maxLength < 2147483647
                && elm.maxLength !== -1
                && this._numberOfExtraCharacters === 0) {
                    var decSep = this._decimalSeparator.toString();
                    var grpSep = this._groupSeparator.toString();

                    // need to escape . for regex
                    if (decSep === ".") {
                        decSep = "/.";
                    }

                    if (grpSep === ".") {
                        grpSep = "/.";
                    }

                    var numberOfDecimalSeparators = (formattedValue.length - formattedValue.replace(new RegExp(decSep, "g"), '').length) / decSep.length;
                    var numberOfGroupSeparators = (formattedValue.length - formattedValue.replace(new RegExp(grpSep, "g"), '').length) / grpSep.length;
                    this._numberOfExtraCharacters = (numberOfDecimalSeparators + numberOfGroupSeparators);
                }
            }

            // only update the maxLength if it was set to begin with.
            if (typeof (elm.maxLength) != 'undefined'
                && elm.maxLength < 2147483647
                && elm.maxLength !== -1) {
                elm.maxLength += this._numberOfExtraCharacters;
            }

            elm.value = formattedValue;
            
            return { "IsFormatted": true, "Unformatted": parsedNumber };
        }
    }
};
CoStar.Web.Controls.NumberOnlyTextBox.registerClass("CoStar.Web.Controls.NumberOnlyTextBox", CoStar.Web.Controls.WatermarkTextBox);

// This routine will ensure that when the page validation is called
// the NumberOnlyTextBox control will provide the unformatted value
// to the validation routines. If the control is not a numeric control
// then the original ValidatorGetValue routine will be called.
CoStar.Web.Controls.NumberOnlyTextBox.validatorGetValue = function(id) {
    var elm = $get(id);
    if (elm && elm.control && CoStar.Web.Controls.NumberOnlyTextBox.isInstanceOfType(elm.control)) {
        if (Sys.Browser.agent === Sys.Browser.WebKit) {
            return elm.control._getUnformatedValueForSafari().toString();
        }
        else {
            return elm.control.get_unformattedValue().toString();
        }
    }
    else {
        return CoStar.Web.Controls.NumberOnlyTextBox._originalValidatorGetValue(id);
    }
}

CoStar.Web.Controls.TextBoxWrapper = function(element) {
    CoStar.Web.Controls.TextBoxWrapper.initializeBase(this, [element]);
    this._current = element.value;
    this._watermark = null;
    this._isWatermarked = false;
}
CoStar.Web.Controls.TextBoxWrapper.prototype = {
    dispose: function() {
        this.get_element().AjaxControlToolkitTextBoxWrapper = null;
        CoStar.Web.Controls.TextBoxWrapper.callBaseMethod(this, 'dispose');
    },
    get_current: function() {
        this._current = this.get_element().value;
        return this._current;
    },
    set_current: function(value) {
        this._current = value;
        this._updateElement();
    },
    get_value: function() {
        if (this.get_isWatermarked()) {
            return "";
        }
        else {
            return this.get_current();
        }
    },
    set_value: function(text) {
        this.set_current(text);
        if (!text || (0 === text.length)) {
            this.set_isWatermarked(null != this._watermark);
        }
    },
    get_watermark: function() { return this._watermark; },
    set_watermark: function(value) {
        this._watermark = value;
        this._updateElement();
    },
    get_isWatermarked: function() { return this._isWatermarked; },
    set_isWatermarked: function(isWatermarked) {
        if (this._isWatermarked !== isWatermarked) {
            this._isWatermarked = isWatermarked;
            this._updateElement();
        }
    },
    _updateElement: function() {
        var element = this.get_element();
        if (this._isWatermarked) {
            if (element.value !== this._watermark) {
                element.value = this._watermark;
            }
        }
        else {
            if (element.value !== this._current) {
                element.value = this._current;
            }
        }
    }
}
CoStar.Web.Controls.TextBoxWrapper.get_Wrapper = function(element) {
    if (null == element.AjaxControlToolkitTextBoxWrapper) {
        element.AjaxControlToolkitTextBoxWrapper = new CoStar.Web.Controls.TextBoxWrapper(element);
    }
    return element.AjaxControlToolkitTextBoxWrapper;
}
CoStar.Web.Controls.TextBoxWrapper.registerClass('CoStar.Web.Controls.TextBoxWrapper', Sys.UI.Behavior);

if (Sys.CultureInfo.prototype._getAbbrMonthIndex) {
    try {
        Sys.CultureInfo.prototype._getAbbrMonthIndex('');
    }
    catch (ex) {
        Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) {
            if (!this._upperAbbrMonths) {
                this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames);
            }
            return Array.indexOf(this._upperAbbrMonths, this._toUpper(value));
        }
        Sys.CultureInfo.CurrentCulture._getAbbrMonthIndex = Sys.CultureInfo.prototype._getAbbrMonthIndex;
        Sys.CultureInfo.InvariantCulture._getAbbrMonthIndex = Sys.CultureInfo.prototype._getAbbrMonthIndex;
    }
}

// override the ValidatorGetValue function so it pulls unformatted values back.
var fn = function() {
    // make sure we only change it once.
    if ((typeof (ValidatorGetValue) == 'function') && (CoStar.Web.Controls.NumberOnlyTextBox.validatorGetValue !== ValidatorGetValue)) {
        CoStar.Web.Controls.NumberOnlyTextBox._originalValidatorGetValue = ValidatorGetValue;
        ValidatorGetValue = CoStar.Web.Controls.NumberOnlyTextBox.validatorGetValue;
    }
};
Sys.Application.add_load(fn);

// unload the ValidatorGetValue function so it's back to the original method. Not entirely sure if this
// is necessary
var unloadFunction = function() {
    // make sure we only change it once.
    if ((typeof (ValidatorGetValue) == 'function') && (CoStar.Web.Controls.NumberOnlyTextBox.validatorGetValue === ValidatorGetValue)) {
        ValidatorGetValue = CoStar.Web.Controls.NumberOnlyTextBox._originalValidatorGetValue;
    }
};
Sys.Application.add_unload(unloadFunction);

if (typeof (Sys) !== 'undefined') var dummyReplacementNotifyVar = true;
//END CoStar.Web.Controls.Resources.ClientScript.NumberOnlyTextBox.js
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();
(function() {var fn = function() {$get('ctl00_sm_HiddenField').value += ';;CoStar.Web.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null:en-US:bb4178cf-5fdc-49f6-80b4-cb824b1b815f:2dab74fd';Sys.Application.remove_load(fn);};Sys.Application.add_load(fn);})();
