/**
 * Funktion: tabify
 * Erzeugt Tabs
 *
 * @params  Array  options  
 *            -> int active: tabindex, der aktiv ist
 * @return  bool  erfolg
 */

(function($) { 
    $.fn.extend({  
        tabify: function(options) {
            
            /* den ausgewählten aktivieren */
            var actIndex = options.active - 1;
            $(this).find('li:eq(' + actIndex + ')').addClass('active');
            
            /* alle instanzen durchlaufen und initialisieren */
			return this.each(function() { 
                
                /* alle tabs durchlaufen */
				$(this).find('li').each(function() {
                                        
                    /* den aktiven anzeigen */
                    if($(this).hasClass('active')) {
						$('#'+$(this).attr('class')).show();
                    } else {
						$('#'+$(this).attr('class')).hide();
                    }
                    
                    /* den wechsel einbauen */
                    $(this).click(function() {
                        $(this).parent().find('li').each(function() {
                            $(this).removeClass('active');
                            $('#'+$(this).attr('class')).hide();
                        });
                        $('#'+$(this).attr('class')).show();
                        $(this).addClass('active');
                    });
				});

            }); 
        } 
    }); 
})(jQuery);