$(function()        {
       //page load
       Initialize();
});        
Initialize = function()
{
       SetupRollovers();  
	   SetupActiveTab();
};

var tab = ".slides-nav li a";

/* Setup Roll-Over */
SetupRollovers = function() {
       $(tab).hover(function() {
			   if($(this).attr('class') != "active")
					$(this).addClass("rollover");
				},function() {
				if($(this).attr('class') != "active")
					$(this).removeClass("rollover");
	   		}	   
	   );		  
};

/* Setup Active Tab */
SetupActiveTab = function()	{
	//Make the selected tab red.
	$(tab).click(function()	{
		$('.slides-nav li a').each(function(){
			$(this).removeClass('active');									 	
		});
		$(this).removeClass("rollover");
		$(this).addClass("active");
		
		//loop through each tab and hide them
		$(".tab").each(function()	{
			$(this).hide(); 
		});
		
		//find the id of the tab that just been clicked and add '-tab' after it
		var s = $(this).attr("id") + "-tab";
		//show the content of the tab
		$("#" + s).show();
	});
}
