/* 
 * simple tab switcher
 * author:		PablO
 * version:		0.2.2
 * last update:		2009-05-23
 * requires:		jQuery http://jquery.com/
 * usage:		- include this file before </body>
 * 			- style your tabs!
 *
 * html structure:
 * its required for tab to have common parentNode.parentNode
 * its required for tab content to have common parentNode
 *
 *	tab1.active <- active tab
 * 		<a href="#tab1ContentID"/>
 * 	tab2
 * 		<a href="#anch-tab2ContentID"/> <- you can also link to an anchor inside tab
 * 	tab3
 * 		<a href="#tab3ContentID"/>
 *
 * 	#tab1ContentID.target <- visible tab content
 * 	#tab2ContentID
 * 		<a name="anch-tab2ContentID"></a> <- you can use anchor inside tab content
 * 	#tab3ContentID
 *
 *
 */  

(function( tabSwitcher ){
	function tabSwitcher( e ){
		var tabsParent = this.parentNode.parentNode;
		var tabsContentsParent = $( this.hash.replace( /anch-/,'' ) ).parent();

		$( '.active', tabsParent ).removeClass( 'active' );
		$( '.target', tabsContentsParent ).removeClass( 'target' );

		$( this.parentNode ).addClass( 'active' );
		$( this.hash.replace( /anch-/,'' ) ).addClass( 'target' );

		this.hideFocus=1;
		e.preventDefault();
	}
	$( 'a[href^=#]' ).click( tabSwitcher );
})()
