jQuery(document).ready(function() {
	var $ = jQuery.noConflict();
	
	//now with cookie suppport
	function myTabs(div){
		
		if ($(div))
		{
			//check if cookie exists
			var cookie = $.cookie(div + '_tabs');
	
			if(cookie != null)
			{
				//if so hide others and add active class to link
				$('.' + div + '_tab:not(#'+cookie+')').hide();
				$('#'+cookie).show();
				$('a[href="#'+cookie+'"]').addClass('active');
				$('a[href="#'+cookie+'"]').parents('li').addClass('active');
			}
			else
			{
				//if this is not the first tab, hide it
				$('.' + div + '_tab:not(:first)').hide();
				//to fix u know who
				$('.' + div + '_tab:first').show();
				//ad active class to first link
				$('ul#' + div + '_htabs li:first').find('a').stop().addClass('active');
				$('ul#' + div + '_htabs li:first').addClass('active');
			}
			
			 //when we click one of the tabs
			 $('#' + div + '_htabs li a').click(function(){
				
				$('#' + div + '_htabs li').removeClass('active');
				$(this).parents('li').addClass('active');
				//add an active class to the links							   
				$(this).parents('ul#' + div + '_htabs').find('li a.active').toggleClass('active');
				$(this).toggleClass('active');
											   
				 //get the ID of the element we need to show
				 stringref = $(this).attr("href").split('#')[1];
				 //write a cookie with the div id name
				 $.cookie(div + '_tabs', stringref);
				 
				 //hide the tabs that doesn't match the ID
				 $('.' + div + '_tab:not(#'+stringref+')').hide();
				 //fix
				 if ($.browser.msie && $.browser.version.substr(0,3) == "6.0") 
				 {
					$('.' + div + '_tab#' + stringref).show();
				 }
				 else
				 {
					 //display our tab fading it in
					 $('.' + div + '_tab#' + stringref).show();
				 }
				 
				 //stay with me
				 return false;
			 });
		}
		else
		{
			return false;	
		}
	}
	//myTabs('featured');
	myTabs('home');
	myTabs('sidebar');
});

