ASPxClientButton=_aspxCreateClass(ASPxClientControl,{constructor:function(name){this.constructor.prototype.constructor.call(this,name);this.allowFocus=true;this.autoPostBackFunction=null;this.causesValidation=true;this.enabled=true;this.checked=false;this.groupName="";this.focused=false;this.focusElementSelected=false;this.isNative=false;this.pressed=false;this.validationGroup="";this.buttonCell=null;this.contentDiv=null;this.checkedInput=null;this.buttonImage=null;this.internalButton=null;this.textElement=null;this.textControl=null;this.CheckedChanged=new ASPxClientEvent();this.GotFocus=new ASPxClientEvent();this.LostFocus=new ASPxClientEvent();this.Click=new ASPxClientEvent();},Initialize:function(){this.constructor.prototype.Initialize.call(this);this.InitializeEvents();this.SetEnabledInternal(this.enabled,true);this.SetCheckedInternal(this.checked,true);if(!this.isNative){this.AttachNativeHandlerToMainElement("focus","SetFocus");this.AttachNativeHandlerToMainElement("click","OnClick");}},AttachNativeHandlerToMainElement:function(handlerName,correspondingMethodName){var mainElement=this.GetMainElement();if(!_aspxIsExistsElement(mainElement))return;eval("mainElement."+handlerName+" = function() { _aspxBCallButtonMethod('"+this.name+"', '"+correspondingMethodName+"'); }");},InitializeEvents:function(){if(!this.isNative){var element=this.GetInternalButton();if(_aspxIsExists(element))_aspxRemoveAttribute(element,"onfocus");var textControl=this.GetTextControl();if(_aspxIsExists(textControl)){if(__aspxIE)_aspxAttachEventToElement(textControl,"onmouseup",_aspxClearSelection);_aspxPreventElementDragAndSelect(textControl,false);}}
var name=this.name;this.onClick=function(){return aspxBClick(name);};this.onGotFocus=function(){aspxBGotFocus(name);};this.onLostFocus=function(){aspxBLostFocus(name);};this.onKeyUp=function(evt){aspxBKeyUp(evt,name);};this.onKeyDown=function(evt){aspxBKeyDown(evt,name);};},GetContentDiv:function(){if(!_aspxIsExistsElement(this.contentDiv))this.contentDiv=this.GetChild("_T");return this.contentDiv;},GetButtonCell:function(){if(!_aspxIsExistsElement(this.buttonCell))this.buttonCell=this.GetChild("_B");return this.buttonCell;},GetButtonCheckedInput:function(){if(!_aspxIsExistsElement(this.checkedInput))this.checkedInput=_aspxGetElementById(this.name+"_CH");return this.checkedInput;},GetButtonImage:function(){if(!_aspxIsExistsElement(this.buttonImage))this.buttonImage=_aspxGetChildByTagName(this.GetButtonCell(),"IMG",0);return this.buttonImage;},GetInternalButton:function(){if(!_aspxIsExistsElement(this.internalButton))this.internalButton=this.isNative?this.GetMainElement():_aspxGetChildByTagName(this.GetMainElement(),"INPUT",0);return this.internalButton;},GetTextElement:function(){if(!_aspxIsExistsElement(this.textElement)){var contentDiv=this.GetContentDiv();if(this.GetButtonImage()==null)this.textElement=contentDiv;else{this.textElement=_aspxGetChildByTagName(contentDiv,"TD",0);var img=_aspxGetChildByTagName(this.textElement,"IMG",0);if(_aspxIsExists(img))this.textElement=_aspxGetChildByTagName(contentDiv,"TD",1);}}return this.textElement;},GetTextControl:function(){if(!_aspxIsExistsElement(this.textControl))this.textControl=_aspxGetParentByTagName(this.GetTextElement(),"table");if(!_aspxIsExistsElement(this.textControl)||(this.textControl.id==this.name))this.textControl=this.GetTextElement();return this.textControl;},GetPostfixes:function(){return this.isNative?[""]:["_B"];},IsHovered:function(){var hoverElement=this.isNative?this.GetMainElement():this.GetButtonCell();return aspxGetStateController().currentHoverItemName==hoverElement.id;},ChangeEnabledEventsAttributes:function(method){var element=this.GetMainElement();method(element,"click",this.onClick);if(this.allowFocus){if(!this.isNative)element=this.GetInternalButton();method(element,"focus",this.onGotFocus);method(element,"blur",this.onLostFocus);if(!this.isNative){method(element,"keyup",this.onKeyUp);method(element,"blur",this.onKeyUp);method(element,"keydown",this.onKeyDown);}}},SetEnabledInternal:function(enabled,initialization){this.enabled=enabled;if(!initialization||!enabled){if(!this.isNative){if(!enabled)aspxGetStateController().DisableElement(this.GetButtonCell());else aspxGetStateController().EnableElement(this.GetButtonCell());this.UpdateFocusedStyle();}else this.GetMainElement().disabled=!enabled;}
this.ChangeEnabledEventsAttributes(enabled?_aspxAttachEventToElement:_aspxDetachEventFromElement);},OnFocus:function(){if(!this.allowFocus)return false;this.focused=true;if(this.isInitialized&&_aspxIsExists(this.RaiseFocus))this.RaiseFocus();this.UpdateFocusedStyle();},OnLostFocus:function(){if(!this.allowFocus)return false;this.focused=false;if(this.isInitialized&&_aspxIsExists(this.RaiseLostFocus))this.RaiseLostFocus();this.UpdateFocusedStyle();},OnClick:function(){if(this.groupName!=""){var list=this.GetCheckedGroupList();if(list.length>1&&this.checked)return;}
this.SetFocus();var processOnServer=this.autoPostBack||this.IsServerEventAssigned("Click");if(_aspxIsExists(this.RaiseClick))processOnServer=this.RaiseClick();if(this.causesValidation&&_aspxIsExistsType(typeof(ASPxClientEdit)))processOnServer=ASPxClientEdit.ValidateGroup(this.validationGroup)&&processOnServer;if(processOnServer)this.SendPostBack();else if(this.groupName!=""){var list=this.GetCheckedGroupList();if(list.length==1)this.SetCheckedInternal(!this.checked,false);else{this.SetCheckedInternal(true,false);this.ClearButtonGroupChecked(true);}if(_aspxIsExists(this.RaiseCheckedChanged))processOnServer=this.RaiseCheckedChanged();if(processOnServer)this.SendPostBack();}},OnKeyUp:function(evt){if(this.pressed)this.SetUnpressed();},OnKeyDown:function(evt){if((evt.keyCode==13)||(evt.keyCode==32))this.SetPressed();},GetChecked:function(){return this.groupName!=""?this.GetButtonCheckedInput().value=="1":false;},GetCheckedGroupList:function(){var collection=aspxGetControlCollection();var result=new Array();for(var name in collection.elements){var element=collection.elements[name];if(element!=null&&ASPxClientButton.prototype.isPrototypeOf(element)&&(element.groupName==this.groupName))_aspxArrayPush(result,element);}return result;},ClearButtonGroupChecked:function(raiseCheckedChanged){var list=this.GetCheckedGroupList();for(var i=0;i<list.length;i++){if(list[i]!=this&&list[i].checked){list[i].SetCheckedInternal(false,false);if(raiseCheckedChanged&&_aspxIsExists(this.RaiseCheckedChanged))this.RaiseCheckedChanged();}}},ApplyCheckedStyle:function(){if(this.IsHovered())aspxGetStateController().SetCurrentHoverElement(null);aspxGetStateController().SelectElementBySrcElement(this.GetButtonCell());},ApplyUncheckedStyle:function(){if(this.IsHovered())aspxGetStateController().SetCurrentHoverElement(null);aspxGetStateController().DeselectElementBySrcElement(this.GetButtonCell());},SetCheckedInternal:function(checked,initialization){if(initialization&&checked||(this.checked!=checked)){this.checked=checked;var inputElement=this.GetButtonCheckedInput();if(_aspxIsExists(inputElement))inputElement.value=checked?"1":"0";if(checked)this.ApplyCheckedStyle();else this.ApplyUncheckedStyle();}},ApplyPressedStyle:function(){aspxGetStateController().OnMouseDownOnElement(this.GetButtonCell());},ApplyUnpressedStyle:function(){aspxGetStateController().OnMouseUpOnElement(this.GetButtonCell());},SetPressed:function(){this.pressed=true;this.ApplyPressedStyle();},SetUnpressed:function(){this.pressed=false;this.ApplyUnpressedStyle();},SetFocus:function(){if(this.allowFocus){var element=this.GetInternalButton();if(_aspxIsFocusable(element)&&_aspxGetActiveElement()!=element)element.focus();}},ApplyFocusedStyle:function(){if(this.focusElementSelected)return;aspxGetStateController().SelectElementBySrcElement(this.GetContentDiv());this.focusElementSelected=true;},ApplyUnfocusedStyle:function(){if(!this.focusElementSelected)return;aspxGetStateController().DeselectElementBySrcElement(this.GetContentDiv());this.focusElementSelected=false;},UpdateFocusedStyle:function(){if(this.isNative)return;if(this.enabled&&this.allowFocus&&this.focused)this.ApplyFocusedStyle();else this.ApplyUnfocusedStyle();},SendPostBack:function(){if(_aspxIsExists(this.autoPostBackFunction))this.autoPostBackFunction();else ASPxClientControl.prototype.SendPostBack.call(this,"");}});function _aspxBCallButtonMethod(name,methodName){var button=aspxGetControlCollection().Get(name);if(button!=null)eval("button."+methodName+"()");}
function aspxBGotFocus(name){var button=aspxGetControlCollection().Get(name);if(button!=null)return button.OnFocus();}
function aspxBLostFocus(name){var button=aspxGetControlCollection().Get(name);if(button!=null)return button.OnLostFocus();}
function aspxBClick(name){var button=aspxGetControlCollection().Get(name);if(button!=null)button.OnClick();return false;}
function aspxBKeyDown(evt,name){var button=aspxGetControlCollection().Get(name);if(button!=null)button.OnKeyDown(evt);}
function aspxBKeyUp(evt,name){var button=aspxGetControlCollection().Get(name);if(button!=null)button.OnKeyUp(evt);} 