/**
 * Breadcrumbs fancy stuff....
 * 
 */

function shrinkBreadcrumbs(breadSize)
{
	var pageWidth = $('breadcrumbs_bar').getWidth();
	var currentWidth = getCurrentWidth(breadSize);

	var i = breadSize;
	//alert(currentWidth);
	while ( currentWidth > pageWidth )
	{
		//How much space are we over
		available = (currentWidth - pageWidth);
		element = 'breadcrumb_' + i.toString();
		
		//Set breadcrumb to fit exaclty, or to 20 if it's too small
		//alert($(element).getWidth());
		if( ($(element).getWidth() - available) > 20 )
			$('breadcrumb_' + i.toString()).setStyle('width',($(element).getWidth() - available - 1)); //-1 here fixes the firefox bug...
		else
			$('breadcrumb_' + i.toString()).setStyle('width','20px');
		i--;
		currentWidth = getCurrentWidth(breadSize);
	}
}

function getCurrentWidth(size)
{
	var graphicsWidth = (size * 32) + 50;
	var currentWidth = 0;
	
	for ( var i = 1 ; i <= size ; i++ )
		currentWidth += $('breadcrumb_' + i.toString()).getWidth();
	currentWidth += graphicsWidth;
	
	return currentWidth;
}
