Epson.Category =
{
	tabContents: null,
	catnavigation: null,

	setup: function()
	{
		// set up tab contents and hide all tabs bar the first
		Epson.Category.tabContents = jQuery( '#Content .tabContent' );
		Epson.Category.tabContents.hide();
		var tab = jQuery( '#Content ul.categoryNavigation li > strong' ).parents( 'li' )[0].className.match( /ct-([^\s]+)/ );
		if ( tab ) jQuery( '#Content a[name="' + tab[1] + '"]' ).next( '.tabContent' ).show();

		// setup tabs
		Epson.Category.catnavigation = jQuery( '#Content ul.categoryNavigation a[class!="buttonSmall"]' );
		jQuery( Epson.Category.catnavigation ).bind( 'click', Epson.Category.select );
	},

	select: function(e)
	{
		// hide all tabs
		Epson.Category.tabContents.hide();

		// swap tab
		var tab = jQuery( this ).parents( 'li' )[0].className.match( /ct-([^\s]+)/ );
		if ( tab ) 
		{
			jQuery( '#Content a[name="' + tab[1] + '"]' ).next( '.tabContent' ).show();
	
			// deselect previous tab
			var tab = jQuery( '#Content ul.categoryNavigation li > strong' );
			tab.replaceWith( jQuery( '<a href="#"><span>' + tab.text() + '</span></a>' ).bind( 'click', Epson.Category.select ) );

			// select the right tab
			var text = jQuery( this ).text();
			jQuery( this ).replaceWith( jQuery( '<strong><span>' + text + '</span></strong>' ) );
	
			// display show all tab
//			jQuery('#Content ul.categoryNavigation a[class="buttonSmall"]').css( { visibility:'' } );
		}

		e.preventDefault();
	}
}


