(function(){

/*
	Class: BoxBar
	*Subclass of <SliderBar>*

	Description:
	The main Bar for holding Container <BarItem>s	
*/
function BoxBar()
{
	this.classname = "SB.ui.BoxBar";

	SBui.BoxBar.superclass.constructor.call(this);

	SButil.EventManager.addListener("BoxAdded", onBoxAdded, this);
}

//ContainerItem extends BarItem.  
YAHOO.lang.extend( BoxBar, window['SB']['ui']['SliderBar']);

function onBoxAdded(inEvent, inArgs)
{
	var box = new SBCore.Box();
	var config = { id:inArgs[0].id, 
			name:inArgs[0].name,
		  owner_username:window["sb_username"],
			container_id:inArgs[0].container.id };

	if( inArgs[0].share === true )
	{
		config.num_shared = 1;
		config.shared = "1";
	}

	box.setConfig(config);

	var boxItem = new SBui.BoxItem();
	boxItem.setConfig( {  id:"sb_ui_baritem_box", 
			   title:inArgs[0].name,
			 box_obj:box
			 } );

	SButil.StateManager.currentContainer.addBoxItem( boxItem );

	if( inArgs[0].tofront === true )
	{
		this.addItemToFront( boxItem );
		this.pageLeft(1);
	}
	else
	{
		this.addItem( boxItem );
	}
}

window['SB']['ui']['BoxBar'] = BoxBar;

})();
