(function($){

$.fn.simpletabs = function(options) {

    var settings = $.extend({
        tab_container: '.js_tab_container',
        tab_navigation: '.js_tab_navigation a',
        tab_content: '.js_tab_content',
        top_anchor: '#container',
        active_class: 'active',
        show: '0'
    }, options);

    return this.each(function () {

        var $hash = window.location.hash.replace('-content','');

        var tab_container = settings.tab_container,
            tab_content = $(settings.tab_content);

        if($hash && $hash != settings.top_anchor) {

            tab_content.hide().filter($hash).show();
            $what = 'a[href*='+$hash+']';

        } else {

            tab_content.hide().filter(':eq('+ settings.show +')').show();
            $what = ':eq('+ settings.show +')';

        }

        $(settings.tab_navigation).click(function () {

            tab_content.hide().filter(this.hash).show();
            $(tab_container+' .'+settings.active_class).removeClass(settings.active_class);
            $(this).parent().addClass(settings.active_class);

            $hash = $(this).attr('href');

            window.location.hash = $hash + '-content';

            return false;

        }).filter($what).click();

    });

};

})(jQuery);
