/*
 * Ext JS Library 2.1
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.StatusBar=Ext.extend(Ext.Toolbar,{cls:"x-statusbar",busyIconCls:"x-status-busy",busyText:"Loading...",autoClear:5000,activeThreadId:0,initComponent:function(){if(this.statusAlign=="right"){this.cls+=" x-status-right"}Ext.StatusBar.superclass.initComponent.call(this)},afterRender:function(){Ext.StatusBar.superclass.afterRender.call(this);var A=this.statusAlign=="right",B=Ext.get(this.nextBlock());if(A){this.tr.appendChild(B.dom)}else{B.insertBefore(this.tr.firstChild)}this.statusEl=B.createChild({cls:"x-status-text "+(this.iconCls||this.defaultIconCls||""),html:this.text||this.defaultText||""});this.statusEl.unselectable();this.spacerEl=B.insertSibling({tag:"td",style:"width:100%",cn:[{cls:"ytb-spacer"}]},A?"before":"after")},setStatus:function(C){C=C||{};if(typeof C=="string"){C={text:C}}if(C.text!==undefined){this.setText(C.text)}if(C.iconCls!==undefined){this.setIcon(C.iconCls)}if(C.clear){var D=C.clear,B=this.autoClear,A={useDefaults:true,anim:true};if(typeof D=="object"){D=Ext.applyIf(D,A);if(D.wait){B=D.wait}}else{if(typeof D=="number"){B=D;D=A}else{if(typeof D=="boolean"){D=A}}}D.threadId=this.activeThreadId;this.clearStatus.defer(B,this,[D])}return this},clearStatus:function(C){C=C||{};if(C.threadId&&C.threadId!==this.activeThreadId){return this}var B=C.useDefaults?this.defaultText:"",A=C.useDefaults?this.defaultIconCls:"";if(C.anim){this.statusEl.fadeOut({remove:false,useDisplay:true,scope:this,callback:function(){this.setStatus({text:B,iconCls:A});this.statusEl.show()}})}else{this.statusEl.hide();this.setStatus({text:B,iconCls:A});this.statusEl.show()}return this},setText:function(A){this.activeThreadId++;this.text=A||"";if(this.rendered){this.statusEl.update(this.text)}return this},getText:function(){return this.text},setIcon:function(A){this.activeThreadId++;A=A||"";if(this.rendered){if(this.currIconCls){this.statusEl.removeClass(this.currIconCls);this.currIconCls=null}if(A.length>0){this.statusEl.addClass(A);this.currIconCls=A}}else{this.currIconCls=A}return this},showBusy:function(A){if(typeof A=="string"){A={text:A}}A=Ext.applyIf(A||{},{text:this.busyText,iconCls:this.busyIconCls});return this.setStatus(A)}});Ext.reg("statusbar",Ext.StatusBar);