tabbed = function()
{
	var $tabbed 	= $( 'DIV.tabbed > DIV.tabs' );
	var $tabs		= null;
	var $index		= null;
	var $content	= null;
	
	for( i=0;i<$tabbed.length;i++ )
	{
		$index		= 0;
		
		if( $( $tabbed[i] ).children('.tab.active').length > 0 )
		{
			$index 	= $( $tabbed[i] ).children('.tab').index( $( $tabbed[i] ).children('.tab.active') );
		}
		
		$( $tabbed[i] ).children('.tab:eq('+$index+')').addClass("active");
		$( $tabbed[i] ).parent().children('.tab_content:eq('+$index+')').show();
		
		$( $tabbed[i] ).children('.tab').bind( 'click',function(){
			$tabs		= $(this).parent().children('.tab');
			$index 		= $( $tabs ).index(this);
			
			$( $tabs ).removeClass('active');
			$( this ).addClass("active");
			$_id		= $(this).attr('id');
			if($_id)
			{
				$('#current_tab').val($_id);
			}
			$content 	= $( this ).parent().parent().children('.tab_content');
			$( $content ).hide();
			$( $content[$index] ).show();
		});
	};
};


$(document).ready(function(){
	tabbed();
});
