(function($)
{
	$.fn.initTabs = function()
	{
		removeHref();
		if($('a[rel=default]').length > 0){
		    $('a[rel=default]').each(function(){ toggleTabs($(this).parent().attr('id')); });		    
		}

		function removeHref()
		{	
			$('.tabs').each(function()
			{
				$('li', this).each(function(index)
				{
					var id = $(this).attr('id');
					if (index == 0)
					{
						$(this).addClass('selected');
						$('#' + id + '-content').addClass('show');
					}
					else
					{
						$(this).removeClass('selected');
						$('#' + id + '-content').removeClass('show').addClass('hide');
					}
					createClickFunction($(this), id);
					$('a', this).each(function()
					    {
					        $(this).attr('href', '');
					    }
					);
				});
			});
		}
		
		function createClickFunction(t, id)
		{
			$(t).click(function()
			{
				toggleTabs(id);
				return false;
			}).mouseover(function()
			{
				$(this).css({cursor: 'pointer'});
			});
		}
		
		function toggleTabs(id)
		{	
			var parentID = $('#' + id).parent();
			$('li', parentID).each(function()
			{
				var tabID = $(this).attr('id');
						
				if (tabID == id)
				{
					$(this).addClass('selected');
					$('#' + tabID + '-content').removeClass('hide').addClass('show');
				}
				else
				{
					$(this).removeClass('selected');
					$('#' + tabID + '-content').removeClass('show').addClass('hide');
				}
			});
				
			// Set the height of the rounded corner content blocks
			// to fix the left hand border in IE
			// CSS is set to height 100% but IE doesn't refresh its height
			// when the tab content changes.
			$('.content').each(function()
			{
				var height = $(this).height();
				$(this).contents().find('.rc_top:eq(0)').height(height);
			});
		}
	};
})(jQuery);
