/*$(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
	
	//$("ul.tabs li").removeClass("active"); //Remove any "active" class
		//$(this.href).addClass("active").show(); //Add "active" class to selected tab
		//$(".tab_content").hide(); //Hide all tab content
		
		//$(this.href).show();


	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

});*/
$(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

//attribute an idea to each of the top tabs so we can manipulate them later
//it is using the href value you enter, in this case #tab1, #tab2 etc and adds _top
$('.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, for instance index.html#tab4

//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, make sure you give that link a class of external_link
//example: Lets go to tab 4 to contact us
//this can be within your content anywhere on the page, remember that it will not jump to the menu!
$(".external_link").click(function() {

//call above function
changeTab($(this).attr("href"));
return false;
});

});
