
/**
 * initialises the tabbed pane
 *
 * @param string tabContext the tabbed pane context
 * @return void
 * @author Tim Cromwell
 **/
function resizeTabs(tabContext)
{
	// set a list of appropriate widths
	var widths = [60,80,100,120,140,160,180,200,220,240,260,280,300];

	// determine the search string
	var searchString = (tabContext + ' li.tabs ul li');

	// grab a list of tabs and fix them
	$(searchString).each(function(){

		// reset the width of this item to be auto
		$(this).width('auto');
		
		// get the base width of the item
		var itemWidth = $(this).width();
		
		// iterate through the list of widths and determine the appropriate width..
		for (var i = 0; i < widths.length; i++)
		{
			// if the item width is less than an appropriate width - use it and apply it
			if (widths[i] > (itemWidth + 20))
			{
				$(this).css('width', widths[i] + 'px');	
				$(this).css('background-position', ($(this).hasClass('selected') ? '0px' : '-300px') + ' -' + ((widths[i] - 60) * 2) + 'px');
				break;
			}
		}		
	});
}

/**
 * displays the selected tab and hides the rest
 *
 * @param string tabScope the scope in which to search for tabs
 * @param string tabName the name of the tab to show
 * @return void
 * @author Tim Cromwell
 **/
function showTab(tabScope, tabName) 
{
	// iterate through each of the tab items
	$(tabScope + " li.tabs ul li").each(function() {
		$(this).attr('class', ($(this).attr('id') == 'tab_'.concat(tabName)) ? 'selected' : '');
	});
	
	// iterate through each of the content sections to show/hide
	$(tabScope + " li.content ul li.pane").each(function(){
		if ($(this).attr('id') == 'pane_'.concat(tabName))
		{
			$(this).show();
		}
		else
		{
			$(this).hide();
		}
	});
	
	// update the tab backgrounds
	resizeTabs(tabScope);
	
	// update the cufon
	cufonReplace();
}