function toolbar(id) {
tic=document.createElement("ul");
tbc=document.createElement("div");
tbc.className="toolbar";
tbc.id=id;
tbc.appendChild(tic);
this.tic=tic;
this.tbc=tbc;

this.add=addButton;
this.separator=addSeparator;
this.place=insertToolbar;
}

function createButton(id, title, icon, fn) {
var a=document.createElement("a");
a.href="#";
a.id='tb_'.id;
a.title=title;
a.onclick=function() { try { fn() } catch (e) { } return false };
a.tabIndex=400;
if (icon!="") {
	var img=new Image(24,24);
	img.src="/images/icons/24x24/"+icon+".png";
	img.border=0;
	img.alt=title;
	a.appendChild(img);
} else {
	a.appendChild(document.createTextNode(title));
}
li=document.createElement("li");
li.appendChild(a);
li.className='btn';
return li;
}

function addSeparator()
{
var sep=document.createElement("li");
sep.className='sep';
this.tic.appendChild(sep);
return sep;
}

function addButton(id, title, icon, fn)
{
btn=createButton(id,title,icon,fn);
this.tic.appendChild(btn);
return btn;
}

function insertToolbar(item)
{
item.parentNode.insertBefore(this.tbc, item);
}
