/*
 * YUI Extensions 0.33 RC2
 * Copyright(c) 2006, Jack Slocum.
 */


YAHOO.ext.Toolbar=function(container){this.el=getEl(container,true);var div=document.createElement('div');div.className='ytoolbar';var tb=document.createElement('table');tb.border=0;tb.cellPadding=0;tb.cellSpacing=0;div.appendChild(tb);var tbody=document.createElement('tbody');tb.appendChild(tbody);var tr=document.createElement('tr');tbody.appendChild(tr);this.el.dom.appendChild(div);this.tr=tr;};YAHOO.ext.Toolbar.prototype={add:function(){for(var i=0;i<arguments.length;i++){var el=arguments[i];var td=document.createElement('td');this.tr.appendChild(td);if(el instanceof YAHOO.ext.ToolbarButton){el.init(td);}else if(el instanceof Array){this.addButton(el);}else if(typeof el=='string'){var span=document.createElement('span');if(el=='separator'){span.className='ytb-sep';}else{span.innerHTML=el;span.className='ytb-text';}
td.appendChild(span);}else if(typeof el=='object'){td.appendChild(el);}}},getEl:function(){return this.el;},addSeparator:function(){var td=document.createElement('td');this.tr.appendChild(td);var span=document.createElement('span');span.className='ytb-sep';td.appendChild(span);},addButton:function(config){if(config instanceof Array){var buttons=[];for(var i=0,len=config.length;i<len;i++){buttons.push(this.addButton(config[i]));}
return buttons;}
var b=config;if(!(config instanceof YAHOO.ext.ToolbarButton)){b=new YAHOO.ext.ToolbarButton(config);}
this.add(b);return b;},addText:function(text){var td=document.createElement('td');this.tr.appendChild(td);var span=document.createElement('span');span.className='ytb-text';span.innerHTML=text;td.appendChild(span);return span;},insertButton:function(index,config){if(config instanceof Array){var buttons=[];for(var i=0,len=config.length;i<len;i++){buttons.push(this.insertButton(index+i,config[i]));}
return buttons;}
var b=new YAHOO.ext.ToolbarButton(config);var td=document.createElement('td');var nextSibling=this.tr.childNodes[index];if(nextSibling)
this.tr.insertBefore(td,nextSibling);else
this.tr.appendChild(td);b.init(td);return b;}};YAHOO.ext.ToolbarButton=function(config){YAHOO.ext.util.Config.apply(this,config);};YAHOO.ext.ToolbarButton.prototype={init:function(appendTo){var element=document.createElement('span');element.className='ytb-button';if(this.id){element.id=this.id;}
this.disabled=(this.disabled===true);var inner=document.createElement('span');inner.className='ytb-button-inner '+this.className;inner.unselectable='on';if(this.tooltip){element.setAttribute('title',this.tooltip);}
if(this.style){YAHOO.ext.DomHelper.applyStyles(inner,this.style);}
element.appendChild(inner);appendTo.appendChild(element);this.el=getEl(element,true);this.el.unselectable();inner.innerHTML=(this.text?this.text:'&#160;');this.inner=inner;this.el.mon('click',this.onClick,this,true);this.el.mon('mouseover',this.onMouseOver,this,true);this.el.mon('mouseout',this.onMouseOut,this,true);},setHandler:function(click,scope){this.click=click;this.scope=scope;},setText:function(text){this.inner.innerHTML=text;},setTooltip:function(text){this.el.dom.title=text;},show:function(){this.el.dom.parentNode.style.display='';},hide:function(){this.el.dom.parentNode.style.display='none';},disable:function(){this.disabled=true;if(this.el){this.el.addClass('ytb-button-disabled');}},enable:function(){this.disabled=false;if(this.el){this.el.removeClass('ytb-button-disabled');}},isDisabled:function(){return this.disabled===true;},setDisabled:function(disabled){if(disabled){this.disable();}else{this.enable();}},onClick:function(){if(!this.disabled&&this.click){this.click.call(this.scope||window,this);}},onMouseOver:function(){if(!this.disabled){this.el.addClass('ytb-button-over');if(this.mouseover){this.mouseover.call(this.scope||window,this);}}},onMouseOut:function(){this.el.removeClass('ytb-button-over');if(!this.disabled){if(this.mouseout){this.mouseout.call(this.scope||window,this);}}}};