﻿/*
* 	sTabs 0.1 - jQuery plugin
*	written by Martin Srank
*	http://labs.smasty.net/jquery/stabs/
*
*	Copyright (c) 2010 Martin Srank (http://smasty.net)
*	Dual licensed under the MIT (MIT-LICENSE.txt)
*	and GPL (GPL-LICENSE.txt) licenses.
*
*	Built for jQuery library
*	http://jquery.com
*
*/
(function ($) {
    $.fn.sTabs = function (options) {

        var opts = $.extend({}, $.fn.sTabs.defaults, options);

        return this.each(function () {
            $(this).addClass('tabs');
            $(this).find('a').each(function () {
                // Hide all
                $($(this).attr('href')).addClass('tab').hide();
                // Show active
                $(this).click(function () {
                    $(this).addClass('active');
                    opts.animate ? $($(this).attr('href')).fadeIn(opts.duration) : $($(this).attr('href')).show();

                    $($(this).parent().siblings().find('a')).each(function () {
                        $(this).removeClass('active');
                        $($(this).attr('href')).hide();
                    });
                    return false;
                })
            });
            // Show first
            var first = $(this).find('li:nth-child(' + opts.startWith + ')').children('a');
            $(first).addClass('active');
            $($(first).attr('href')).show();
        });
    }
    $.fn.sTabs.defaults = { animate: false, duration: 300, startWith: 1 }
})(jQuery);
