var __aspxSpindButtonIdPostfix = "_B";
var __aspxNumberDecimalSeparator = ",";
var __aspxPossibleNumberDecimalSeparators = [",", "."];
__aspxSERepeatBtnMinIntervalDelay = 5;
__aspxSERepeatBtnMaxIntervalDelay = 300;
ASPxClientSpinEditBase = _aspxCreateClass(ASPxClientButtonEditBase, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.largeDecButtonIndex = -1;
  this.incButtonIndex = -2;
  this.decButtonIndex = -3;
  this.largeIncButtonIndex = -4;
  this.allowMouseWheel = true;
  this.valueChangedDelay = 0;
  this.valueChangedTimerID = -1;
  this.repeatButtonTimerID = -1;
  this.buttonsHeightCorrected = false;
  this.loadedSpinButtonImageCount = 0;
  this.spinButtonImageCount = 0;
  aspxGetSpinEditCollection().Add(this);
 },
 Initialize: function() {
  this.AssignButtonAttributes();
  ASPxClientButtonEditBase.prototype.Initialize.call(this);
 },
 AssignButtonAttributes: function() {
  var buttons = [
   this.GetIncrementButton(),
   this.GetDecrementButton(),
   this.GetLargeIncrementButton(),
   this.GetLargeDecrementButton()
  ];
  for (var i = 0; i < buttons.length; i++) {
   var button = buttons[i];
   if (!_aspxIsExistsElement(button)) continue;
   _aspxPreventElementDragAndSelect(button, true);
   button.needClearSelection = true;
   if (!__aspxNetscapeFamily)
    button.unselectable = "on";
  }
 },
 GetIncrementButton: function() { return this.GetButton(this.incButtonIndex); },
 GetDecrementButton: function() { return this.GetButton(this.decButtonIndex); },
 GetLargeIncrementButton: function() { return this.GetButton(this.largeIncButtonIndex); },
 GetLargeDecrementButton: function() { return this.GetButton(this.largeDecButtonIndex); },
 GetButtonNumber: function(id) {
  var pos = id.lastIndexOf(__aspxSpindButtonIdPostfix);
  if (pos > -1)
   return id.substring(pos + __aspxSpindButtonIdPostfix.length, id.length);
  return null;
 },
 GetSpinButtonCell: function() {
  return this.GetChild("_SPBtnCell");
 },
 GetMainTableCellSpacing: function() {
  var cell = this.GetSpinButtonCell();
  var tableElem = _aspxGetParentByTagName(cell, "table");
  return __aspxNetscapeFamily ? tableElem.attributes["cellspacing"].value : tableElem.cellSpacing;
 },
 AdjustControlCore: function() {
  ASPxClientButtonEditBase.prototype.AdjustControlCore.call(this);
  this.CorrectButtonsHeight();
 },
 CorrectButtonsHeight: function() {
  var cell = this.GetSpinButtonCell();
  if (_aspxIsExists(cell)) {
   var incButton = this.GetIncrementButton();
   var decButton = this.GetDecrementButton();
   if (_aspxIsExists(incButton) && _aspxIsExists(decButton)) {
    var incImg = _aspxGetElementsByTagName(incButton, "img")[0];
    var decImg = _aspxGetElementsByTagName(decButton, "img")[0];
    if (__aspxOpera) {
     if (_aspxIsExists(decImg.isLoaded) || _aspxIsExists(incImg.isLoaded))
      this.CorrectSpinButtonsHeightWithImage();
     else {
      if (_aspxIsExists(incImg) && !_aspxIsExists(incImg.isLoaded)) {
       this.spinButtonImageCount++;
       _aspxAttachEventToElement(incImg, "load", _aspxCreateEventHandlerFunction("aspxSpinImageOnLoad", this.name, false));
      }
      if (_aspxIsExists(decImg) && !_aspxIsExists(decImg.isLoaded)) {
       this.spinButtonImageCount++;
       _aspxAttachEventToElement(decImg, "load", _aspxCreateEventHandlerFunction("aspxSpinImageOnLoad", this.name, false));
      }
     }
    }
    else
     this.CorrectSpinButtonsHeightWithImage();
   }
   else {
    var largeIncButton = this.GetLargeIncrementButton();
    var largeDecButton = this.GetLargeDecrementButton();
    if (_aspxIsExists(largeIncButton) && _aspxIsExists(largeDecButton)) {
     var h = largeIncButton.offsetHeight;
     var mainCellHeight = this.CalcMainCellHeight();
     if (__aspxOpera || __aspxWebKitFamily || __aspxIE && h < mainCellHeight)
      this.SetActualElementHeigth(_aspxGetChildByTagName(cell, "table", 0), mainCellHeight);
    }
   }
  }
  this.buttonsHeightCorrected = true;
 },
 CalcMainCellHeight: function() {
  var ret = 0;
  var cell = this.GetSpinButtonCell();
  if (_aspxIsExists(cell)) {
   ret = __aspxWebKitFamily ? cell.offsetHeight : cell.clientHeight;
   var cellSpacing = this.GetMainTableCellSpacing();
   if (__aspxOpera) {
    if (cellSpacing == 0) 
     ret = ret - 1;
   }
  }
  return ret;
 },
 CorrectSpinButtonsHeightWithImage: function() {
  var cell = this.GetSpinButtonCell();
  var mainCellHeight = this.CalcMainCellHeight();
  var incButton = this.GetIncrementButton();
  var decButton = this.GetDecrementButton();
  var h = incButton.offsetHeight + decButton.offsetHeight;
  if (__aspxOpera || __aspxWebKitFamily || __aspxIE && h < mainCellHeight)
   this.SetActualElementHeigth(_aspxGetChildByTagName(cell, "table", 0), mainCellHeight);
  if (!__aspxNetscapeFamily)
   this.CorrectIncrementButtonsHeight();
  var cell = this.GetSpinButtonCell();
  var cellSpacing = 1;
  if (_aspxIsExists(cell))
   cellSpacing = this.GetMainTableCellSpacing();
  if ((cellSpacing == 0) && _aspxIsExists(_aspxGetElementsByTagName(incButton, "img"))) {
   var incImg = _aspxGetElementsByTagName(incButton, "img")[0];
   incImg.style.marginTop = "1px"; 
  }
 },
 CorrectIncrementButtonsHeight: function() {
  var incButton = this.GetIncrementButton();
  var decButton = this.GetDecrementButton();
  if (_aspxIsExistsElement(incButton) && _aspxIsExistsElement(decButton) && !__aspxIE && !__aspxWebKitFamily) {
   var incBtnHeight = incButton.clientHeight;
   var dcBtnHeight = decButton.clientHeight;
   var absDif = Math.abs(incBtnHeight - dcBtnHeight);
   if (absDif > 1) {
    var difHeight = Math.floor(absDif / 2);
    if (incBtnHeight > dcBtnHeight) {
     incBtnHeight -= difHeight;
     dcBtnHeight += difHeight;
    }
    else {
     dcBtnHeight -= difHeight;
     incBtnHeight += difHeight;
    }
   }
   if (__aspxOpera) {
    var d = decButton.offsetHeight - incButton.offsetHeight;
    dcBtnHeight = dcBtnHeight - d;
    incBtnHeight = incBtnHeight + d;
   }
   incButton.style.height = incBtnHeight + "px";
   decButton.style.height = dcBtnHeight + "px";
  }
 },
 OnSpinButtonImageLoad: function() {
  this.loadedSpinButtonImageCount++;
  if (this.loadedSpinButtonImageCount == this.spinButtonImageCount)
   this.CorrectSpinButtonsHeightWithImage();
 },
 GetNextTimerInterval: function(iterationIndex) {
  var coef = 1 / iterationIndex;
  if (coef < 0.13)
   coef = 0.13;
  return coef * __aspxSERepeatBtnMaxIntervalDelay;
 },
 DoRepeatButtonClick: function(num, iterationIndex) {
  this.ProcessInternalButtonClick(num);
  var timerInterval = this.GetNextTimerInterval(iterationIndex);
  if (iterationIndex < 50)
   iterationIndex++;
  this.SetButtonRepeatClickTimer(num, timerInterval, iterationIndex);
 },
 SetButtonRepeatClickTimer: function(num, timerInterval, iterationIndex) {
  var str = "aspxSRepeatButtonClick(\"" + this.name + "\"," +
     num.toString() + "," + iterationIndex.toString() + ")";
  this.repeatButtonTimerID = _aspxSetTimeout(str, timerInterval);
 },
 ClearButtonRepeatClickTimer: function() {
  this.repeatButtonTimerID = _aspxClearTimer(this.repeatButtonTimerID);
 },
 ProcessInternalButtonClick: function(number) {
 },
 OnAfterSetPressed: function(id) {
  var num = this.GetButtonNumber(id);
  if (num != null)
   this.SetButtonRepeatClickTimer(num, 300, 1);
 },
 OnAfterClearPressed: function(id) {
  this.ClearButtonRepeatClickTimer();
 },
 OnButtonMouseDown: function(evt) { 
  if (__aspxNetscapeFamily)
   evt.preventDefault();
 },
 OnValueChanged: function() {
  if (this.valueChangedDelay == 0)
   this.OnValueChangedTimer();
  else {
   if (this.valueChangedTimerID > -1) {
    window.clearTimeout(this.valueChangedTimerID);
    this.valueChangedTimerID = -1;
   }
   this.valueChangedTimerID = window.setTimeout("aspxSEValueChanged(\"" + this.name + "\")", this.valueChangedDelay);
  }
 },
 OnValueChangedTimer: function() {
  if (this.valueChangedTimerID > -1) {
   window.clearTimeout(this.valueChangedTimerID);
   this.valueChangedTimerID = -1;
  }
  this.RaisePersonalStandardValidation();
  ASPxClientButtonEditBase.prototype.OnValueChanged.call(this);
 },
 ChangeEnabledAttributes: function(enabled) {
  ASPxClientButtonEditBase.prototype.ChangeEnabledAttributes.call(this, enabled);
  var btnElement = this.GetIncrementButton();
  if (_aspxIsExists(btnElement))
   this.ChangeButtonEnabledAttributes(btnElement, _aspxChangeAttributesMethod(enabled));
  btnElement = this.GetDecrementButton();
  if (_aspxIsExists(btnElement))
   this.ChangeButtonEnabledAttributes(btnElement, _aspxChangeAttributesMethod(enabled));
  btnElement = this.GetLargeIncrementButton();
  if (_aspxIsExists(btnElement))
   this.ChangeButtonEnabledAttributes(btnElement, _aspxChangeAttributesMethod(enabled));
  btnElement = this.GetLargeDecrementButton();
  if (_aspxIsExists(btnElement))
   this.ChangeButtonEnabledAttributes(btnElement, _aspxChangeAttributesMethod(enabled));
 },
 ChangeEnabledStateItems: function(enabled) {
  this.ClearButtonRepeatClickTimer();
  ASPxClientButtonEditBase.prototype.ChangeEnabledStateItems.call(this, enabled);
  var btnElement = this.GetIncrementButton();
  if (_aspxIsExists(btnElement))
   aspxGetStateController().SetElementEnabled(btnElement, enabled);
  btnElement = this.GetDecrementButton();
  if (_aspxIsExists(btnElement))
   aspxGetStateController().SetElementEnabled(btnElement, enabled);
  btnElement = this.GetLargeIncrementButton();
  if (_aspxIsExists(btnElement))
   aspxGetStateController().SetElementEnabled(btnElement, enabled);
  btnElement = this.GetLargeDecrementButton();
  if (_aspxIsExists(btnElement))
   aspxGetStateController().SetElementEnabled(btnElement, enabled);
 }
});
ASPxClientSpinEdit = _aspxCreateClass(ASPxClientSpinEditBase, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.NumberChanged = new ASPxClientEvent();
  this.decimalPlaces = 0;
  this.number = 0;
  this.inc = 1;
  this.largeInc = 10;
  this.minValue = 0;
  this.maxValue = 0;
  this.allowNull = true;
  this.numberType = "f";
  this.maxLength = 0;
  this.inputValueBeforeFocus = null;
  this.valueChangedProcsCalledBeforeLostFocus = false;
  this.pasteTimerID = -1;
  this.keyUpProcessing = false;
  this.isChangingCheckProcessed = false;
 },
 Initialize: function() {
  ASPxClientSpinEditBase.prototype.Initialize.call(this);
  this.GenerateValidationRegExp();
 },
 InlineInitialize: function() {
  ASPxClientSpinEditBase.prototype.InlineInitialize.call(this);
  this.UpdateLastCorrectValueString();
 },
 GenerateValidationRegExp: function() {
  var decimalSeparator = "";
  var allowDecimalSeparatorSymbols = "";
  if (this.IsFloatNumber()) {
   decimalSeparator = this.GetDecimalSeparatorRegExpString(__aspxNumberDecimalSeparator);
   for (var i = 0; i < __aspxPossibleNumberDecimalSeparators.length; i++)
    allowDecimalSeparatorSymbols += this.GetDecimalSeparatorRegExpString(__aspxPossibleNumberDecimalSeparators[i]);
  }
  this.allowSymbolRegExp = new RegExp("[-0-9" + allowDecimalSeparatorSymbols + "]");
  this.validNumberRegExp = new RegExp("^[-]?[0-9]+[" + decimalSeparator + "]?[0-9]*([0-9]+)?$");
  var validFormattedNumberRegExpString = "^[-]?[0-9]+[" + decimalSeparator + "]?[0-9]";
  if (this.decimalPlaces != 0)
   validFormattedNumberRegExpString += "{0," + this.decimalPlaces + "}$";
  else
   validFormattedNumberRegExpString += "*([0-9]+)?$";
  this.validFormattedNumberRegExp = new RegExp(validFormattedNumberRegExpString);
 },
 GetDecimalSeparatorRegExpString: function(decimalSeparator) {
  return decimalSeparator == "." ? "\\." : decimalSeparator;
 },
 ChangeNumber: function(offset) {
  if (!this.readOnly) {
   var precisionNum = this.GetToPrecisionNumber(this.number + offset);
   var newNumber = this.GetValidNumber(this.ParseNumber((this.number + offset).toPrecision(precisionNum), "Decimal"), this.number);
   if (newNumber != this.number) {
    this.SetNumberInternal(newNumber);
    this.OnValueChanged();
   }
   this.SelectInputElement();
  }
 },
 GetToPrecisionNumber: function(number) {
  var ret = 21; 
  var numString = number.toPrecision(21);
  var integerDigitsCount = numString.indexOf(__aspxPossibleNumberDecimalSeparators[0]);
  if (integerDigitsCount < 0)
   integerDigitsCount = numString.indexOf(__aspxPossibleNumberDecimalSeparators[1]);
  if (integerDigitsCount > 0)
   ret = integerDigitsCount + 14;
  return Math.min(ret, 21);
 },
 ProcessInternalButtonClick: function(number) {
  var ret = false;
  this.ParseValueAfterPaste();
  if (this.largeDecButtonIndex == number) {
   this.ChangeNumber(-this.largeInc);
   ret = true;
  } else if (this.incButtonIndex == number) {
   this.ChangeNumber(this.inc);
   ret = true;
  } else if (this.decButtonIndex == number) {
   this.ChangeNumber(-this.inc);
   ret = true;
  } else if (this.largeIncButtonIndex == number) {
   this.ChangeNumber(this.largeInc);
   ret = true;
  }
  return ret;
 },
 GetCorrectNumberInRange: function(number) {
  if (this.UseRestrictions() && number > this.maxValue)
   number = this.maxValue;
  if (this.UseRestrictions() && number < this.minValue)
   number = this.minValue;
  return number;
 },
 GetValidNumber: function(number, oldNumber) {
  var validNumber = 0;
  if (this.UseRestrictions() && number < this.minValue && (this.number == null || number > this.number))
   validNumber = this.minValue;
  else if (this.UseRestrictions() && number > this.maxValue && (this.number == null || number < this.number))
   validNumber = this.maxValue;
  else if ((!this.UseRestrictions() || number <= this.maxValue) &&
   (!this.UseRestrictions() || number >= this.minValue))
   validNumber = number;
  else
   validNumber = this.number;
  if (!this.IsFloatNumber())
   validNumber = Math.round(validNumber);
  if ((this.maxLength > 0) && (validNumber.toString().length > this.maxLength))
   validNumber = oldNumber;
  return validNumber;
 },
 GetValueType: function() {
  return this.IsFloatNumber() ? "Decimal" : "Int";
 },
 GetFormattedNumber: function(number) {
  if (number == null)
   return "";
  var value = String(number);
  if (__aspxNumberDecimalSeparator != ".") {
   if (value.indexOf(".") != -1)
    value = value.replace(".", __aspxNumberDecimalSeparator);
  }
  value = this.GetCorrectFormattedNumberString(value);
  return value;
 },
 IsFloatNumber: function() {
  return this.numberType == "f";
 },
 ParseValue: function(withSelection) {
  if (!_aspxIsExists(withSelection))
   withSelection = true;
  var inputElement = this.GetInputWithNumber();
  if (_aspxIsExistsElement(inputElement)) {
   var valueString = inputElement.value;
   var newNumber = (valueString != "") ? this.ParseValueInternal(valueString) : null;
   if ((newNumber != null) && !isNaN(newNumber)) {
    if (newNumber != this.number) {
     newNumber = this.GetCorrectNumberInRange(newNumber);
     var isEqual = newNumber == this.number;
     this.SetNumberInternal(newNumber, withSelection);
     if (!isEqual)
      this.OnValueChanged();
    }
   }
   else {
    if (this.allowNull)
     this.SetNumberInternal(null, withSelection);
    else
     this.SetNumberInternal(this.GetCorrectNumberInRange(0), withSelection);
    this.OnValueChanged();
   }
  }
 },
 ParseValueAfterPaste: function() {
  if (this.isChangingCheckProcessed) {
   this.ParseValue();
   this.isChangingCheckProcessed = false;
  }
 },
 ParseValueOnPaste: function() {
  var inputElement = this.GetInputElement();
  if (_aspxIsExistsElement(inputElement)) {
   var valueString = inputElement.value;
   if (valueString != "") {
    if (!this.IsValidNumberString(valueString)) {
     valueString = this.lastValue;
     inputElement.value = this.lastValue;
    }
    else
     this.lastValue = valueString;
   }
   var newNumber = (valueString != "") ? this.ParseValueInternal(valueString) : null;
   if (newNumber != null)
    this.SetFormattedNumberInInput(newNumber);
  }
 },
 ParseValueInternal: function(value) {
  if (value == null || value.toString() == "")
   return null;
  if (__aspxNumberDecimalSeparator != ".") {
   if (value.indexOf(__aspxNumberDecimalSeparator) != -1)
    value = value.replace(__aspxNumberDecimalSeparator, ".");
  }
  if (typeof (value) == "number")
   return value;
  return this.ParseNumber(value.toString(), this.GetValueType());
 },
 ParseNumber: function(value, type) {
  if (type == "Decimal")
   return parseFloat(value, 10);
  return parseInt(value, 10);
 },
 RaiseValueChangedEvent: function() {
  return this.OnNumberChanged();
 },
 SetNumberInternal: function(value, withSelection) {
  if (!_aspxIsExists(withSelection))
   withSelection = true;
  this.number = this.RoundNumber(value);
  this.SetFormattedNumberInInput(this.number, withSelection);
  if (this.HasTextDecorators())
   this.SyncRawInputValue();
 },
 RoundNumber: function(number) {
  if(this.decimalPlaces <= 0)
   return number;
  var factor = Math.pow(10, this.decimalPlaces);
  return Math.round(factor * number) / factor;
 },
 SetFormattedNumberInInput: function(number, withSelection) {
  if (!_aspxIsExists(withSelection))
   withSelection = true;
  var inputElement = this.GetInputElement();
  if (inputElement != null) {
   if (withSelection)
    this.UpdateSelectionStartAndEndPosition(inputElement); 
   var formattedNumber = this.GetFormattedNumber(number);
   if (formattedNumber.toString() != inputElement.value) {
    inputElement.value = formattedNumber;
    if (this.HasTextDecorators())
     this.SyncRawInputValue();
   }
   if (withSelection)
    _aspxSetSelectionCore(inputElement, inputElement.selectionStart, inputElement.selectionEnd); 
   this.UpdateLastCorrectValueString();
  }
 },
 UseRestrictions: function() {
  return (this.maxValue != 0 || this.minValue != 0);
 },
 UpdateLastCorrectValueString: function() {
  this.lastValue = this.GetInputWithNumber().value;
 },
 GetValue: function() {
  var input = this.GetInputWithNumber();
  if (!_aspxIsExistsElement(input))
   return null;
  if (this.allowNull && input.value == "")
   return null;
  else if (!this.allowNull && this.number == null)
   return this.GetCorrectNumberInRange(0);
  else
   return this.number;
 },
 SetValue: function(number) {
  this.number = this.RoundNumber(number);
  ASPxClientSpinEditBase.prototype.SetValue.call(this, this.GetFormattedNumber(this.number));
 },
 OnKeyPress: function(evt) {
  ASPxClientSpinEditBase.prototype.OnKeyPress.call(this, evt);
  var inputElement = this.GetInputElement();
  if (!_aspxIsExists(inputElement)) {
   if (this.pasteTimerID != -1)
    this.ClearTextChangingTimer();
   return;
  }
  this.keyUpProcessing = true;
  if (!__aspxIE && this.IsPasteShortcut(evt))
   this.keyUpProcessing = false;
  if (evt.altKey || evt.ctrlKey)
   return true;
  if (this.IsSpecialKey(evt, false)) {
   this.keyUpProcessing = true;
   return true;
  }
  var keyCode = _aspxGetKeyCode(evt);
  this.UpdateSelectionStartAndEndPosition(inputElement);
  var selectionStart = inputElement.selectionStart;
  var selectionEnd = inputElement.selectionEnd;
  var pressed = String.fromCharCode(keyCode);
  if (!this.IsAllowableSymbol(pressed)) {
   this.keyUpProcessing = false;
   return _aspxPreventEvent(evt); 
  }
  if (this.IsSignSymbol(pressed)) {
   var isAllowTypeNumberSignSymbol = this.IsAllowTypeNumberSignSymbol(selectionStart, selectionEnd);
   this.keyUpProcessing = isAllowTypeNumberSignSymbol;
   return isAllowTypeNumberSignSymbol ? true : _aspxPreventEvent(evt);  
  }
  if (this.IsDecimalSeparatorSymbol(pressed)) {
   var isAllowTypeDecimalSeparator = this.IsAllowTypeDecimalSeparatorSymbol(selectionStart, selectionEnd);
   if (isAllowTypeDecimalSeparator)
    this.TypeDecimalSeparator(selectionStart, selectionEnd);
   this.keyUpProcessing = isAllowTypeDecimalSeparator;
   return _aspxPreventEvent(evt);
  }
  if (!this.IsAllowTypeDigitToCurrentPosition(selectionStart, selectionEnd, pressed)) {
   this.keyUpProcessing = false;
   return _aspxPreventEvent(evt); 
  }
  return true;
 },
 OnKeyUp: function(evt) {
  ASPxClientSpinEditBase.prototype.OnKeyUp.call(this, evt);
  if (this.keyUpProcessing) {
   this.UpdateLastCorrectValueString();
   this.keyUpProcessing = false;
  }
  if (this.IsPageOrArrowKey(evt))
   this.OnPageOrArrowKeyUp();
 },
 OnKeyDown: function(evt) {
  if (evt.keyCode == ASPxKey.Enter)
   this.OnTextChanged();
  ASPxClientSpinEditBase.prototype.OnKeyDown.call(this, evt);
  if (this.IsPageOrArrowKey(evt))
   this.OnPageOrArrowKeyDown(evt);
  if ((__aspxIE || __aspxWebKitFamily) && this.IsSpecialKey(evt, true))
   this.keyUpProcessing = true;
 },
 OnPageOrArrowKeyDown: function(evt) {
  var btnIndex = this.GetButtonIndexByKeyCode(_aspxGetKeyCode(evt), evt.ctrlKey);
  if (__aspxOpera)
   this.SetButtonRepeatClickTimer(btnIndex, 60, 1);
  else {
   this.ProcessInternalButtonClick(btnIndex);
   _aspxPreventEvent(evt);
  }
 },
 OnPageOrArrowKeyUp: function(evt) {
  if (__aspxOpera)
   this.ClearButtonRepeatClickTimer();
 },
 OnFocus: function() {
  if (__aspxIE || __aspxFirefox && __aspxBrowserVersion == 2)
   this.SaveIEOnValueChangedEmulationData();
  ASPxClientSpinEditBase.prototype.OnFocus.call(this);
  this.SetTextChangingTimer();
 },
 OnLostFocus: function() {
  if (__aspxFirefox && __aspxBrowserVersion == 2)
   this.EmulateIEOnValueChanged();
  ASPxClientSpinEditBase.prototype.OnLostFocus.call(this);
  this.ClearTextChangingTimer();
  if (__aspxIE)
   this.EmulateIEOnValueChanged();
 },
 OnNumberChanged: function() {
  var processOnServer = ASPxClientSpinEditBase.prototype.RaiseValueChangedEvent.call(this);
  processOnServer = this.RaiseNumberChanged(processOnServer);
  if (this.focused)
   this.valueChangedProcsCalledBeforeLostFocus = true;
  return processOnServer;
 },
 OnMouseOver: function(evt) {
  if (_aspxGetIsLeftButtonPressed(evt) && !this.HasTextDecorators())
   this.OnTextChangingCheck();
 },
 OnMouseWheel: function(evt) {
  if (!this.allowMouseWheel)
   return;
  this.ParseValue();
  var wheelDelta = _aspxGetWheelDelta(evt);
  if (wheelDelta > 0)
   this.ChangeNumber(this.inc);
  else if (wheelDelta < 0)
   this.ChangeNumber(-this.inc);
  _aspxPreventEvent(evt);
 },
 OnTextChangingCheck: function(evt) {
  var input = this.GetInputWithNumber();
  if (!_aspxIsExists(input))
   return;
  var curValueString = input.value.toString();
  this.isChangingCheckProcessed = true;
  if ((this.lastValue != curValueString) && !this.keyUpProcessing)
   this.OnPaste();
 },
 OnPaste: function() {
  this.ParseValueOnPaste();
 },
 OnTextChanged: function() {
  this.ParseValue(!__aspxWebKitFamily);
 },
 GetButtonIndexByKeyCode: function(keyCode, ctrl) {
  var ret = 0;
  switch (keyCode) {
   case ASPxKey.Up:
    ret = ctrl ? this.largeIncButtonIndex : this.incButtonIndex;
    break;
   case ASPxKey.Down:
    ret = ctrl ? this.largeDecButtonIndex : this.decButtonIndex;
    break;
   case ASPxKey.PageUp:
    ret = this.largeIncButtonIndex;
    break;
   case ASPxKey.PageDown:
    ret = this.largeDecButtonIndex;
    break;
  }
  return ret;
 },
 SaveIEOnValueChangedEmulationData: function() {
  this.valueChangedProcsCalledBeforeLostFocus = false;
  var input = this.GetInputWithNumber();
  if (_aspxIsExistsElement(input))
   this.inputValueBeforeFocus = input.value;
 },
 EmulateIEOnValueChanged: function() {
  if (!this.valueChangedProcsCalledBeforeLostFocus) {
   var input = this.GetInputWithNumber();
   if (_aspxIsExistsElement(input) && input.value != this.inputValueBeforeFocus) {
    this.OnTextChanged();
    this.RaiseValidationInternal();
    this.RaisePersonalStandardValidation();
   }
  }
 },
 SetTextChangingTimer: function() {
  var str = "aspxSETextChangingCheck(\"" + this.name + "\")";
  this.pasteTimerID = _aspxSetInterval(str, __aspxPasteCheckInterval);
 },
 ClearTextChangingTimer: function() {
  this.pasteTimerID = _aspxClearInterval(this.pasteTimerID);
 },
 IsAllowableSymbol: function(symbol) {
  return this.allowSymbolRegExp.test(symbol);
 },
 IsAllowTypeNumberSignSymbol: function(selectionStart, selectionEnd) {
  var curValueString = this.GetInputElement().value.toString();
  if ((curValueString != null) && this.IsSignSymbol(curValueString.charAt(0)))
   return (selectionStart == 0) && (selectionEnd > 0);
  else
   return (selectionStart == 0);
 },
 IsAllowTypeDecimalSeparatorSymbol: function(selectionStart, selectionEnd) {
  var curValueString = this.GetInputElement().value.toString();
  var decimalSepIndex = curValueString.indexOf(__aspxNumberDecimalSeparator);
  if ((this.decimalPlaces != 0) && (decimalSepIndex == -1)) {
   var possibleValueString = this.GetPossibleValueString(selectionStart, selectionEnd, __aspxNumberDecimalSeparator);
   return this.IsValidFormattedNumberString(possibleValueString);
  }
  return decimalSepIndex == -1;
 },
 IsAllowTypeDigitToCurrentPosition: function(selectionStart, selectionEnd, pressedSymbol) {
  var possibleValueString = this.GetPossibleValueString(selectionStart, selectionEnd, pressedSymbol);
  var decimalSepIndex = possibleValueString.indexOf(__aspxNumberDecimalSeparator);
  if ((this.decimalPlaces != 0) && (decimalSepIndex != -1))
   return this.IsValidFormattedNumberString(possibleValueString);
  return true;
 },
 IsValidNumberString: function(numString) {
  return this.validNumberRegExp.test(numString);
 },
 IsValidFormattedNumberString: function(numString) {
  return this.validFormattedNumberRegExp.test(numString);
 },
 GetCorrectFormattedNumberString: function(numString) {
  var ret = numString;
  if (!this.IsValidFormattedNumberString(numString)) {
   if (numString.toLowerCase().indexOf("e") > -1)
    numString = ASPxClientSpinEdit.RemoveExponentialNotation(numString);
   var decimalSepIndex = numString.indexOf(__aspxNumberDecimalSeparator);
   if (decimalSepIndex > -1) {
    ret = numString.substring(0, decimalSepIndex);
    if (this.IsFloatNumber()) {
     if (this.decimalPlaces > 0)
      ret += numString.substr(decimalSepIndex, this.decimalPlaces + 1);
     else
      ret += numString.substr(decimalSepIndex);
    }
   }
   else
    ret = numString;
  }
  return ret;
 },
 GetPossibleValueString: function(selectionStart, selectionEnd, pressedSymbol) {
  var curValueString = this.GetInputElement().value.toString();
  var newValueString = curValueString.substring(0, selectionStart);
  newValueString += pressedSymbol;
  var selectionLength = selectionEnd - selectionStart;
  newValueString += curValueString.substr(selectionEnd, curValueString.length - selectionLength);
  return newValueString;
 },
 IsDecimalSeparatorSymbol: function(symbol) {
  for (var i = 0; i < __aspxPossibleNumberDecimalSeparators.length; i++)
   if (__aspxPossibleNumberDecimalSeparators[i] == symbol)
   return true;
  return false;
 },
 IsPasteShortcut: function(evt) {
  var keyCode = _aspxGetKeyCode(evt);
  return (evt.ctrlKey && (keyCode == 118  || (keyCode == 86))) ||
      (evt.shiftKey && !evt.ctrlKey && !evt.altKey &&
    (keyCode == ASPxKey.Insert));
 },
 IsValidMinMaxValue: function(minValue, maxValue) {
  if (typeof (maxValue) != "number")
   maxValue = this.ParseValueInternal(maxValue.toString());
  if (typeof (minValue) != "number")
   minValue = this.ParseValueInternal(minValue.toString());
  return (isNaN(maxValue) || isNaN(minValue)) ? false : (maxValue >= minValue);
 },
 IsSpecialKey: function(evt, inKeyDown) {
  var keyCode = _aspxGetKeyCode(evt);
  return keyCode == 0 || keyCode == ASPxKey.Backspace || keyCode == ASPxKey.Tab ||
   (inKeyDown && keyCode == ASPxKey.Delete) || keyCode > 60000 ;
 },
 IsPageOrArrowKey: function(evt) {
  var keyCode = _aspxGetKeyCode(evt);
  if (__aspxOpera && evt.ctrlKey && (keyCode == ASPxKey.Up || keyCode == ASPxKey.Down))
   return false;
  else
   return keyCode == ASPxKey.Up || keyCode == ASPxKey.Down ||
       keyCode == ASPxKey.PageUp || keyCode == ASPxKey.PageDown;
 },
 IsSignSymbol: function(symbol) {
  return _aspxIsExists(symbol) && (symbol == "-");
 },
 TypeDecimalSeparator: function(selectionStart, selectionEnd) {
  var possibleValueString = this.GetPossibleValueString(selectionStart, selectionEnd, __aspxNumberDecimalSeparator);
  var inputElement = this.GetInputElement();
  inputElement.value = possibleValueString;
  var decimalSepIndex = possibleValueString.indexOf(__aspxNumberDecimalSeparator);
  _aspxSetCaretPosition(inputElement, decimalSepIndex + 1); 
 },
 UpdateSelectionStartAndEndPosition: function(inputElement) {
  if (__aspxIE && _aspxIsExists(document.selection)) {
   inputElement.selectionStart = 0;
   inputElement.selectionEnd = 0;
   var curRange = document.selection.createRange();
   var copyRange = curRange.duplicate();
   curRange.move('character', -inputElement.value.length);
   curRange.setEndPoint('EndToStart', copyRange);
   inputElement.selectionStart = curRange.text.length;
   inputElement.selectionEnd = inputElement.selectionStart + copyRange.text.length;
  }
 },
 SetActualElementHeigth: function(element, expectedHeight) {
  element.style.height = expectedHeight + "px";
  if (__aspxIE) {
   var actualHeight = element.clientHeight;
   var d = actualHeight - expectedHeight;
   if (d > 0) {
    expectedHeight = expectedHeight - d;
    element.style.height = expectedHeight + "px";
   }
  }
 },
 GetInputWithNumber: function() {
  if (!this.focused && this.HasTextDecorators())
   return this.GetRawInputElement();
  return this.GetInputElement();
 },
 GetDecoratedText: function(value) {
  if (typeof value == "string")
   value = this.ParseValueInternal(value);
  return ASPxClientSpinEditBase.prototype.GetDecoratedText.call(this, value);
 },
 RaiseNumberChanged: function(processOnServer) {
  if (!this.NumberChanged.IsEmpty()) {
   var args = new ASPxClientProcessingModeEventArgs(processOnServer);
   this.NumberChanged.FireEvent(this, args);
   processOnServer = args.processOnServer;
  }
  return processOnServer;
 },
 SetNumber: function(number) {
  this.SetValue(number);
 },
 GetNumber: function() {
  return this.number;
 },
 GetText: function() {
  return ASPxClientSpinEditBase.prototype.GetValue.call(this);
 },
 SetText: function(text) {
  ASPxClientSpinEditBase.prototype.SetValue.call(this, text);
  this.ParseValue(false);
 },
 SetMinValue: function(value) {
  if (this.IsValidMinMaxValue(value, this.maxValue)) {
   this.minValue = this.ParseValueInternal(value.toString());
   this.EnsureCurrentNumberInBoundries();
  }
 },
 GetMinValue: function() {
  return this.minValue;
 },
 SetMaxValue: function(value) {
  if (this.IsValidMinMaxValue(this.minValue, value)) {
   this.maxValue = this.ParseValueInternal(value.toString());
   this.EnsureCurrentNumberInBoundries();
  }
 },
 GetMaxValue: function() {
  return this.maxValue;
 },
 EnsureCurrentNumberInBoundries: function() {
  var value = this.GetValue();
  if (value != null)
   this.SetNumber(this.GetCorrectNumberInRange(value));
 },
 GetParsedNumber: function() {
  var inputElement = this.GetInputElement();
  var valueString = inputElement.value;
  var newNumber = valueString != "" ? this.ParseValueInternal(valueString) : null;
  if ((newNumber != null) && !isNaN(newNumber)) {
   if (newNumber != this.number)
    newNumber = this.GetCorrectNumberInRange(newNumber);
  } else
   newNumber = this.GetCorrectNumberInRange(0);
  return newNumber;
 },
 RestoreSelectionStartAndEndPosition: function() {
  var inputElement = this.GetInputElement();
  _aspxSetSelectionCore(inputElement, inputElement.selectionStart, inputElement.selectionEnd);
 },
 SaveSelectionStartAndEndPosition: function() {
  this.UpdateSelectionStartAndEndPosition(this.GetInputElement());
 }
});
ASPxClientSpinEdit.RemoveExponentialNotation = function(numString) {
 var mantissaPossition = numString.toLowerCase().indexOf("e");
 var ret = numString;
 if (mantissaPossition > -1) {
  var isNegative = numString.indexOf("-") == 0;
  var isNegativeMantissa = numString.lastIndexOf("-") > 0;
  var mantissa = numString.replace(new RegExp('^[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?)'), "");
  var numberBase = numString.replace(new RegExp('([eE][+-]?[0-9]+)'), "");
  numberBase = numberBase.replace("+", "");
  numberBase = numberBase.replace("-", "");
  var decimalDecimalSeparator = ".";
  if (numberBase.indexOf(decimalDecimalSeparator) == -1) {
   numberBase = numberBase.replace(decimalDecimalSeparator, __aspxNumberDecimalSeparator);
   decimalDecimalSeparator = __aspxNumberDecimalSeparator;
  }
  var numberParts = numberBase.split(decimalDecimalSeparator);
  if (numberParts.length == 1)
   numberParts[1] = "";
  var zeroNumbers = parseInt(mantissa, 10);
  if (isNegativeMantissa) {
   zeroNumbers -= 1;
   ret = "0" + __aspxNumberDecimalSeparator + ASPxClientSpinEdit.GetZeros(zeroNumbers) +
     numberParts[0] + numberParts[1];
  }
  else {
   zeroNumbers -= numberParts[0].length + numberParts[1].length - 1;
   ret = numberParts[0] + numberParts[1] + ASPxClientSpinEdit.GetZeros(zeroNumbers);
  }
  if (isNegative)
   ret = _aspxInsert(ret, "-", 0);
 }
 return ret;
}
ASPxClientSpinEdit.GetZeros = function(length) {
 var zeros = [];
 for (var i = 0; i < length; i++)
  zeros.push('0');
 return zeros.join("");
}
function aspxSEMouseOver(name, evt) {
 var edit = aspxGetControlCollection().Get(name);
 if (edit != null) edit.OnMouseOver(evt);
}
function aspxSETextChangingCheck(name) {
 var edit = aspxGetControlCollection().Get(name);
 if (edit != null) edit.OnTextChangingCheck();
}
function aspxSEValueChanged(name) {
 var spinEdit = aspxGetControlCollection().Get(name);
 if (spinEdit != null) spinEdit.OnValueChangedTimer();
}
function aspxBEMouseDown(name, evt) {
 var edit = aspxGetControlCollection().Get(name);
 if (edit != null) edit.OnButtonMouseDown(evt);
}
function aspxSRepeatButtonClick(name, buttonIndex, iterationIndex) {
 var spinEdit = aspxGetControlCollection().Get(name);
 if (spinEdit != null) spinEdit.DoRepeatButtonClick(buttonIndex, iterationIndex);
}
function aspxSpinImageOnLoad(name) {
 var spinEdit = aspxGetControlCollection().Get(name);
 if (spinEdit != null) spinEdit.OnSpinButtonImageLoad();
}
aspxAddAfterSetPressedState(aspxAfterSetPressed);
aspxAddAfterClearPressedState(aspxAfterClearPressed);
function aspxAfterSetPressed(source, args) {
 var item = args.item;
 var spinEdit = aspxGetSpinEditCollection().GetSpinEdit(item.name);
 if (spinEdit != null && item.enabled) spinEdit.OnAfterSetPressed(item.name);
}
function aspxAfterClearPressed(source, args) {
 var spinEdit = aspxGetSpinEditCollection().GetSpinEdit(args.item.name);
 if (spinEdit != null) spinEdit.OnAfterClearPressed(args.item.name);
}
var __aspxSpinEditCollection = null;
function aspxGetSpinEditCollection() {
 if (__aspxSpinEditCollection == null)
  __aspxSpinEditCollection = new ASPxClientSpinEditCollection();
 return __aspxSpinEditCollection;
}
ASPxClientSpinEditCollection = _aspxCreateClass(ASPxClientControlCollection, {
 constructor: function() {
  this.constructor.prototype.constructor.call(this);
 },
 GetSpinEdit: function(id) {
  return this.Get(this.GetSpinEditName(id));
 },
 GetSpinEditName: function(id) {
  var pos = id.lastIndexOf(__aspxSpindButtonIdPostfix);
  if (pos > -1)
   return id.substring(0, pos);
  pos = id.lastIndexOf(__aspxTEInputSuffix);
  if (pos > -1)
   return id.substring(0, pos);
  return id;
 }
});
