(function(){

/*
	Class: BarItem 
	The base class for a collection of navigation components 
*/
function BarItem()
{
	this.contents = new window['SB']['util']['List'];
	this.htmlObj = null;
	this.spacer = null;
}

BarItem.prototype.toString = function() { return "[SB.util.BarItem]"; };

//Group: Basic Methods 
/*
	Function: getWidth
	Returns the dynamic width for the DOMElement
*/
BarItem.prototype.getWidth = function()
{
	return this.htmlObj.offsetWidth;
};

/*
	Function: getHeight
	Returns the dynamic height for the DOMElement
*/
BarItem.prototype.getHeight = function()
{
	return this.htmlObj.offsetHeight;
};

/*
	Function: getX
	Returns the dynamic horizontal position for the DOMElement
*/
BarItem.prototype.getX = function()
{
	return this.htmlObj.offsetLeft;
};

/*
	Function: getY
	Returns the dynamic vertical position for the DOMElement
*/
BarItem.prototype.getY = function()
{
	return this.htmlObj.offsetTop;
};

/*
	Function: destroy 
	Cleans up and frees any data contained by the object	
*/

BarItem.prototype.destroy = function()
{
	if( this.dd ) 
	{
		this.dd.getEl().objLink = null;	
		free( this.dd );
	}

	if( this.htmlObj )
	{
		this.htmlObj = null;
	}

	free( this );
};

function free( obj )
{
	delete obj;
	obj = null;
}


/*
	Function: setConfig
	Establishes the basic setup for the BarItem.
	
	inConfig - A configuration array (key/value)

	Configuration Array Options:
	id - the id of the div to use as a template (default: sb_ui_baritem)
	action - a function associated with clicking on the BarItem
	title - a name associated with the BarItem
*/
BarItem.prototype.setConfig =  function( inConfig )
{
	this.p_config = inConfig;

	if( inConfig.id )
	{
		var tmpHtmlObj = YUIDom.get( inConfig.id );
		if( tmpHtmlObj )
		{
			this.htmlObj = tmpHtmlObj.cloneNode( true );

			var arr = YUIDom.getElementsByClassName( "internal", "div", this.htmlObj );
			if( arr[0] ) this.internalObj = arr[0]; 

			var arr = YUIDom.getElementsByClassName( "internal_active", "div", this.htmlObj );
			if( arr[0] ) this.internalActiveObj = arr[0]; 
		}
	}

	this.name = inConfig.title;

	if( inConfig.action )
		YUIEvent.addListener( this.htmlObj, "click", inConfig.action.func, inConfig.action.obj, true );
};

/*
	Function: getConfig
	Returns a configuration array for the BarItem.

	See <setConfig> for configuration array definition
*/
BarItem.prototype.getConfig = function()
{
	return this.p_config;
};

/*
	Function: setActive
	Sets the BarItem to be in an active state (or not).  	
	This will toggle the css class.
*/
BarItem.prototype.setActive = function( inActive )
{
	this.is_active = inActive;

	if( this.internalActiveObj )
	{
		this.internalObj.style.display = (inActive)?"none":"block";	
		this.internalActiveObj.style.display = (inActive)?"block":"none";	
	}
};

BarItem.prototype.getHtmlObj = function()
{
	return this.htmlObj;
};

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

})();
