///////////////////////////////////////////////////////////////////
//	BHToolBar Version 0.40                    //  N E W  L O O K //
//  (c) Copyright 2006-2008 Howard Brown      ///////////////////
//                                           /////
//                                          //
/////////////////////////////////////////////

function BHToolBar(bh)
{
	var wrap;
	bhUI.createObject('ToolBar',this);
	if(!bh.id)bh={id:bh};
	wrap=(bh.id&&bh.id.nodeName)?bh.id:bhUI.element(bh.id);
	if(wrap==null){
		wrap=bhUI.createElement();
		wrap.style.position='absolute';
		wrap.style.visibility='hidden';
		wrap.style.top='0px';
		wrap.id=id;
		document.body.appendChild(wrap);
	}
	wrap.className='base-toolbar toolbar-h toolbar';
	this.wrap=wrap;
	this.ul=wrap.addElement({'class':'tb-outer'},{'class':'tb-middle'},
	{'class':'tb-inner'},{name:'UL','class':'tb-ul'})[3];
	this.flags=bh.flags?bh.flags:0;
	this.tools=0;
	this.itemClick=bh.onclick?bh.onclick:__DF;
}

BHToolBar.prototype.show=function(node)
{	
	if(node){
		while(e.offsetParent){
			top+=e.offsetTop;
			left+=e.offsetLeft;
			e=e.offsetParent;
		}
		this.wrap.style.top=top+'px';
		this.wrap.style.left=left+'px';
	}
	this.wrap.style.visibility='inherit';
}


BHToolBar.prototype.event_click=function(e,i)
{
	var f;
	if((f=e.bh_item.action)){
		f();
	}else
	this.itemClick(i);
}

BHToolBar.prototype.addButton=function()
{
	var a,e,li,b=[],i,t;
	for(i=0;i<arguments.length;i++){
		bh=arguments[i];
		e=this.ul.addElement({name:'LI','class':'tb-item'},{name:'A','class':'tb-wrap',href:''},
		{name:'SPAN','class':'tb-out'},{name:'SPAN','class':'tb-mid'},{name:'SPAN','class':'tb-in'});
		li=e[0];a=e[1];e=e[4];
		if(bh.id){
			e.id=bh.id;
		}
		if(bh.width){
			var u=[bh.width+'px','auto'];
			if(this.flags&0x01)u.reverse();
			li.style.width=u[0];
			li.style.height=u[1];
		}
		if(bh.icon){
			img=e.addElement('IMG');
			if(bh.flags&0x10){
				img.src='/newlook/img/clear.gif';
				img.className='tb-icon tb-icon-'+(bh.icon.toLowerCase());
			}else{
				img.src=bh.icon;
				img.className='tb-icon';
			}
		}
		
		if(bh.caption){
			e.addElement({name:'SPAN','class':'tb-caption',text:bh.caption});
		}
			
		if(bh.flags&0x08){
			a.className='tb-spacer';
		}
		
				
		if(bh.flags&0x02){
			if(bh.onclick){
				a.bh_onclick=bh.onclick;
				a.onclick=function(){this.bh_onclick();return false;};
			}else{
			t=this.tools++;
			a.bh_item={action:bh.action,tool:t};
			a.onclick=new Function(this.Tx+".event_click(this,"+t+");return false;");
			}
		}else
		{
			a.onclick=__EP;
			a.className='tb-spacer';
		}
		b.push(e);
	}
	if(b.length < 2)return b[0];
	else return b;
}







