/*
 * yui-ext 0.33
 * Copyright(c) 2006, Jack Slocum.
 */


YAHOO.ext.Button=function(renderTo,config){YAHOO.ext.util.Config.apply(this,config);this.events={'click':true};if(renderTo){this.render(renderTo);}};YAHOO.extendX(YAHOO.ext.Button,YAHOO.ext.util.Observable,{render:function(renderTo){var btn;if(!this.dhconfig){if(!YAHOO.ext.Button.buttonTemplate){YAHOO.ext.Button.buttonTemplate=new YAHOO.ext.DomHelper.Template('<a href="#" class="ybtn-focus"><table border="0" cellpadding="0" cellspacing="0" class="ybtn-wrap"><tbody><tr><td class="ybtn-left">&#160;</td><td class="ybtn-center" unselectable="on">{0}</td><td class="ybtn-right">&#160;</td></tr></tbody></table></a>');}
btn=YAHOO.ext.Button.buttonTemplate.append(getEl(renderTo).dom,[this.text],true);this.tbl=getEl(btn.dom.firstChild,true);}else{btn=YAHOO.ext.DomHelper.append(this.footer.dom,this.dhconfig,true);}
this.el=btn;this.autoWidth();btn.addClass('ybtn');btn.mon('click',this.onClick,this,true);btn.on('mouseover',this.onMouseOver,this,true);btn.on('mouseout',this.onMouseOut,this,true);btn.on('mousedown',this.onMouseDown,this,true);btn.on('mouseup',this.onMouseUp,this,true);},getEl:function(){return this.el;},autoWidth:function(){if(this.tbl){this.el.setWidth('auto');this.tbl.setWidth('auto');if(this.minWidth){if(this.tbl.getWidth()<this.minWidth){this.tbl.setWidth(this.minWidth);}}
this.el.setWidth(this.tbl.getWidth());}},setHandler:function(handler,scope){this.handler=handler;this.scope=scope;},setText:function(text){this.el.dom.firstChild.firstChild.firstChild.childNodes[1].innerHTML=text;this.autoWidth();},show:function(){this.el.setStyle('display','');},hide:function(){this.el.setStyle('display','none');},setVisible:function(visible){if(visible){this.show();}else{this.hide();}},focus:function(){this.el.focus();},disable:function(){this.el.addClass('ybtn-disabled');this.disabled=true;},enable:function(){this.el.removeClass('ybtn-disabled');this.disabled=false;},onClick:function(e){e.preventDefault();if(!this.disabled){this.fireEvent('click',this,e);this.handler.call(this.scope||window,this,e);}},onMouseOver:function(e){if(!this.disabled){this.el.addClass('ybtn-over');}},onMouseOut:function(e){this.el.removeClass('ybtn-over');},onMouseDown:function(){if(!this.disabled){this.el.addClass('ybtn-click');}},onMouseUp:function(){this.el.removeClass('ybtn-click');}});