/**
 * @author carsten
 */
(function() {
    jQuery.fn.pxTabs = function(settings) {

        var wizContainer 	= this;
		var navList 		= $('ul', wizContainer);
		var containers		= $('div.wizcontent', this);		
		
        // define defaults and override with options, if available
        settings = jQuery.extend({ /* header: "h3"  --> any default setting here */  }, settings);
		
		// register clickHanlder
		$('a', navList).not("#tabFluege").not("#tabSki").click(function(){ onTabClick( this );return false;});
		
		function onTabClick( clickedTab )
		{
			// switch tab-classes
			$('a', navList).not(clickedTab).removeClass('active');
			$(clickedTab).addClass('active').blur();			
			
			// find next/clicked index to show
			var newIndex;
			var i = 0;
			$('li',navList).each(function(){
				if ( $('a', this).hasClass('active') ) newIndex = i;
				i++;
			});	

			var nextContent = $(containers)[newIndex] ;
			// hide other containers
			$(containers).not(nextContent).hide();
			// .. and show next container
			$(nextContent).fadeIn('slow');			
			
			if (typeof(onTabOn) != 'undefined')
			{
			    onTabOn(nextContent);
			}
		}
    };
})(jQuery);

