(function($)
{
	$.fn.tabs = function(e)
	{
		return this.each
		(
			function()
			{
				$('#' + $(this).attr('id') + ' li a').click
				(
					function(e)
					{
						if(!$(this).hasClass('exception'))
						{
					
							e.preventDefault();
						
							// Check to see if activelink is already set

							if(!$(this).hasClass('activelink'))
							{
								$('#nav .activelink').each
								(
									function()
									{
										$(this).toggleClass('activelink');
										$($(this).attr('href')).css('display', 'none');
									}
								);

								$(this).toggleClass('activelink').children('span').toggleClass('activelink');
								$($(this).attr('href')).css('display', '');
							}
						}
						
						$(this).blur();
					}
				);
				
				var url = window.location;
				var anchor = url.hash;
				var string = '#' + $(this).attr('id') + (anchor ? ' a[href=' + anchor + ']' : ' a:eq(0)');
				var string2 = '#' + $(this).attr('id') + (anchor ? ' a[href!=' + anchor + ']' : ' a:gt(0)');
				
				$(string).toggleClass('activelink').children('span').toggleClass('activelink');
				$(string2).each
				(
					function()
					{
						$($(this).attr('href')).css('display', 'none');
					}
				);
			}
		);
	}

})(jQuery);


