$(document).ready(function() {
	$(".tab_content").hide(); 												// Hide all content
	$("ul.tabs li:first").addClass("tabsActive"); 		// Activate first tab
	$(".tab_content:first").show(); 									// Show first tab content

	if(window.location.search.indexOf("?tab") > -1) {
		var tabTrigg = parseInt(window.location.search.substring(5,6),10);
		if(tabTrigg <= 0 || tabTrigg > 3){tabTrigg=1;}
		$(".tabs li").each(function(i){
			if($(this).attr('class')== "tabsActive") {
				$(this).removeClass("tabsActive");
			}
			if(i===(tabTrigg-1)) {
				$(this).addClass("tabsActive");
				$(".tab_content").hide();
				$("#tab" + tabTrigg).fadeIn();
			}
		});
	}
	
	$(".tabs li").click(function() {
		$(".tabs li").removeClass("tabsActive"); 	//Remove any "active" class
		$(this).addClass("tabsActive"); 					// Add "active" class to selected tab
		$(".tab_content").hide(); 								// Hide all tab content

		var activeTab = $(this).find("a").attr("rel"); 	// Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); 													// Fade in the active ID content
		return false;
	});	
});
