ASPxClientToolbarComboBox = _aspxCreateClass(ASPxClientComboBox, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.defaultCaption = "";
  this.BeforeFocus = new ASPxClientEvent();
  this.beforeFocusLockCount = 0;
 },
 SetValue: function(value) {
  var isValueEmpty = !value || value == "null"; 
  if (isValueEmpty && this.defaultCaption)
   value = this.defaultCaption;
  ASPxClientComboBox.prototype.SetValue.call(this, value);
  if (this.GetSelectedIndex() == -1) {
   ASPxClientComboBox.prototype.SetText.call(this, value);
  }
 },
 ForceRefocusEditor: function() {
  this.RaiseBeforeFocus();
 },
 RaiseBeforeFocus: function() {
  if(this.beforeFocusLockCount == 0){
   this.beforeFocusLockCount ++;
   var args = new ASPxClientEventArgs();
   this.BeforeFocus.FireEvent(this, args);
  }
 },
 RaiseLostFocus: function(){
  ASPxClientComboBox.prototype.RaiseLostFocus.call(this);
  this.beforeFocusLockCount = 0;
 }
});
ASPxClientNativeToolbarComboBox = _aspxCreateClass(ASPxClientNativeComboBox, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.defaultCaption = "";
 },
 SetValue: function(value){
  if (!value && this.defaultCaption)
   value = this.defaultCaption;
  ASPxClientNativeComboBox.prototype.SetValue.call(this, value);
  if(this.GetSelectedIndex() == -1)
   ASPxClientNativeComboBox.prototype.SetText.call(this, value);
 }
});
ASPxClientToolbarCustomCssComboBox = _aspxCreateClass(ASPxClientToolbarComboBox, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.cssClasses = [];
  this.tagNames = [];
  this.cssClassesValueHashTable = {};
  this.tagNameCssClassesValueHashTable = {};
 },
 Initialize: function(){
  ASPxClientComboBox.prototype.Initialize.call(this);
  this.CreateTagNamesAndCssClassesHashTable();
 },
 GetValue: function() {
  var ret = ASPxClientToolbarComboBox.prototype.GetValue.call(this);  
  if (ret && this.AreCustomTagsExist())
   ret = this.GetExtValueByIndex(ret);
  return ret;
 },
 SetValue: function(value) {
  var newValue = value;
  if (newValue && this.AreCustomTagsExist())
   newValue = this.GetIndexByTagNameAndCssClass(value.tagName, value.cssClass);
  ASPxClientToolbarComboBox.prototype.SetValue.call(this, newValue);
 }
});
ASPxClientNativeToolbarCustomCssComboBox = _aspxCreateClass(ASPxClientNativeToolbarComboBox, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.cssClasses = [];
  this.tagNames = [];
  this.cssClassesValueHashTable = {};
  this.tagNameCssClassesValueHashTable = {};
 },
 Initialize: function(){
  ASPxClientNativeToolbarComboBox.prototype.Initialize.call(this);
  this.CreateTagNamesAndCssClassesHashTable();
 },
 GetValue: function() {
  var ret = ASPxClientNativeToolbarComboBox.prototype.GetValue.call(this);  
  if (ret && this.AreCustomTagsExist())
   ret = this.GetExtValueByIndex(ret);
  return ret;
 },
 SetValue: function(value) {
  var newValue = value;
  if (newValue && this.AreCustomTagsExist())
   newValue = this.GetIndexByTagNameAndCssClass(value.tagName, value.cssClass);
  ASPxClientNativeToolbarComboBox.prototype.SetValue.call(this, newValue);
 }
});
ASPxClientToolbarCustomCssComboBox.prototype.CreateTagNamesAndCssClassesHashTable=
 ASPxClientNativeToolbarCustomCssComboBox.prototype.CreateTagNamesAndCssClassesHashTable= function() {
  for (var i = 0; i < this.tagNames.length; i++) {
   var tagName = this.tagNames[i];
   var cssClass = this.cssClasses[i];
   if (tagName) {
    var key = ASPxClientToolbarCustomCssComboBox.GetKeyByTagNameAndCssClass(tagName, cssClass);
    if (!_aspxIsExists(this.tagNameCssClassesValueHashTable[key]))
     this.tagNameCssClassesValueHashTable[key] = this.GetItem(i).value;
   }
   else if (cssClass) {
    if (!_aspxIsExists(this.cssClassesValueHashTable[cssClass]))
     this.cssClassesValueHashTable[cssClass] = this.GetItem(i).value;
   }
  }
}
ASPxClientToolbarCustomCssComboBox.prototype.GetIndexByTagNameAndCssClass =
 ASPxClientNativeToolbarCustomCssComboBox.prototype.GetIndexByTagNameAndCssClass = function(tagName, cssClass) {
  var ret = null;
  if (tagName) {
   var key = ASPxClientToolbarCustomCssComboBox.GetKeyByTagNameAndCssClass(tagName, cssClass);
   ret = _aspxIsExists(this.tagNameCssClassesValueHashTable[key]) ? this.tagNameCssClassesValueHashTable[key] : null;
  }
  if (cssClass && (ret == null))
   ret = _aspxIsExists(this.cssClassesValueHashTable[cssClass]) ? this.cssClassesValueHashTable[cssClass] : null;
  return ret;
 }
ASPxClientToolbarCustomCssComboBox.prototype.GetExtValueByIndex =
 ASPxClientNativeToolbarCustomCssComboBox.prototype.GetExtValueByIndex = function(index) {
 return { tagName: this.tagNames[index], cssClass: this.cssClasses[index] };
}
ASPxClientToolbarCustomCssComboBox.prototype.AreCustomTagsExist =
 ASPxClientNativeToolbarCustomCssComboBox.prototype.AreCustomTagsExist = function() {
 return (this.tagNames.length > 0) && (this.cssClasses.length > 0);
}
ASPxClientToolbarCustomCssComboBox.GetKeyByTagNameAndCssClass = 
 ASPxClientNativeToolbarCustomCssComboBox.GetKeyByTagNameAndCssClass = function(tagName, cssClass) {
 return tagName + "|" + cssClass;
}
ASPxClientToolbarParagraphFormattingComboBox = _aspxCreateClass(ASPxClientToolbarComboBox, {
 SetValue: function(value) {
  if(this.GetIndexByValue(value) == -1)
   value = this.TryGetDefaultFormatValue();
  ASPxClientToolbarComboBox.prototype.SetValue.call(this, value);
 }
});
ASPxClientNativeToolbarParagraphFormattingComboBox = _aspxCreateClass(ASPxClientNativeToolbarComboBox, {
 SetValue: function(value) {
  if(this.GetIndexByValue(value) == -1)
   value = this.TryGetDefaultFormatValue();
  ASPxClientNativeToolbarComboBox.prototype.SetValue.call(this, value);
 }
});
ASPxClientToolbarParagraphFormattingComboBox.prototype.TryGetDefaultFormatValue =
 ASPxClientNativeToolbarParagraphFormattingComboBox.prototype.TryGetDefaultFormatValue = function() {
  var newValue = "";
  var defaultTags = ["p", "span"];
  for(var i = 0; i < defaultTags.length && newValue == ""; i++)
   if(this.GetIndexByValue(defaultTags[i]) != -1)
    newValue = defaultTags[i];
  return newValue;
}
ASPxClientToolbarParagraphFormattingComboBox.prototype.GetIndexByValue =
 ASPxClientNativeToolbarParagraphFormattingComboBox.prototype.GetIndexByValue = function(value) {
  var lb = this.GetListBoxControl();
  for(var i = 0; i < lb.GetItemCount(); i ++){
   if(lb.GetItem(i).value == value)
    return i;
  }
  return -1;
}
ASPxClientToolbarListBox = _aspxCreateClass(ASPxClientListBox, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
 },
 GetItem: function(index){
  var item = ASPxClientListBox.prototype.GetItem.call(this, index);
  if(item){
   item.text = _aspxTrim(item.text);
   return item;
  }
  return null;
 }
});
ASPxClientNativeToolbarListBox = _aspxCreateClass(ASPxClientNativeListBox, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
 },
 GetItem: function(index){
  var item = ASPxClientNativeListBox.prototype.GetItem.call(this, index);
  if(item){
   item.text = _aspxTrim(item.text);
   return item;
  }
  return null;
 }
});

