//source: http://www.sohtanaka.com/web-design/simple-tabs-w-css-jquery/	
		
jQuery(document).ready(function() {

/*
	//topar se há tab escolhida via url..
	var myFile = document.location.toString();
	if (myFile.match('#')) {
		// the URL contains an anchor
		// click the navigation item corresponding to the anchor
		var myAnchor = myFile.split('#')[1];
	}else{
		var myAnchor = 'first';
	}

	alert(myAnchor);
*/


//Default Action
jQuery('.tab_content').hide(); //Hide all content
if(location.hash != '') {
	//APANHO A ANCHOR VIA URL..
	var target = location.hash.split('#')[1];
	//MOSTRO O CONTEÚDO DA TAB
	jQuery(location.hash).show(); //Show selected tab content
	//APANHO O ELEMENTO LI PELO NOME E MUDO A CLASSE
	jQuery('#'+target+'_li').addClass("active").show(); //Activate the tab

} else {
	jQuery('ul.tabs li:first').addClass('active').show(); //Activate first tab
	jQuery('.tab_content:first').show(); //Show first tab content
}

//On Click Event
jQuery('ul.tabs li').click(function() {
	jQuery('ul.tabs li').removeClass('active'); //Remove any 'active' class
	jQuery(this).addClass('active'); //Add 'active' class to selected tab
	jQuery('.tab_content').hide(); //Hide all tab content
	var activeTab = jQuery(this).find('a').attr('href'); //Find the rel attribute value to identify the active tab + content
	jQuery(activeTab).fadeIn(); //Fade in the active content
	//return false;
});

/*

	//When page loads...
	jQuery(".tab_content").hide(); //Hide all content
	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
	jQuery(".tab_content:first").show(); //Show first tab content

	//On Click Event
	jQuery("ul.tabs li").click(function() {

		//window.location = jQuery(this).find("a").attr("href");
		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery(".tab_content").hide(); //Hide all tab content


		var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		jQuery(activeTab).fadeIn(1000); //Fade in the active ID content
		return false;
	});
*/
});