$(document).ready(function() {
//When page loads…
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content

//add id to the tabs for later manipulation
$('.tabs li').each(function(i) {
var thisId = $(this).find("a").attr("href");
thisId = thisId.substring(1,thisId.length) + '_top';
$(this).attr("id",thisId);
});

function changeTab(activeTab)
{

$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(activeTab + '_top').addClass("active"); //Add "active" class to selected tab, using the id created at document load

$(".tab_content").hide(); //Hide all tab content
$(activeTab).fadeIn(); //Fade in the active content

}

//check to see if a tab is called onload
if (location.hash!=""){changeTab(location.hash);}//if you call the page and want to show a tab other than the first
//On Click Event
$("ul.tabs li").click(function() {

//call above function
changeTab($(this).find("a").attr("href"));
return false;
});

//if you want to open a tab from a link which is not a tab, give that link a class of tab_link
$(".tab_link").click(function() {

//call above function
changeTab($(this).attr("href"));
return false;
});

});
