jQuery.fn.gisTabs = function()
    {
        //Default settings
        var defaults = {
            menuClass: 'tabsMenu',
            speed: 0
        };

        var options = jQuery.extend(defaults, options)

        this.each(function(){
            var container = jQuery(this);
            var tabs = container.children('div.tab');
            var firstToOpen = 0;

            //add menu div
            container.prepend('<div class="' + options.menuClass + '"><ul></ul><div class="clear"></div></div>');
            var tabsMenu = container.children('div.' + options.menuClass);

            tabs.each(function(i, val){
                var tab = jQuery(this);
                if(tab.hasClass('active')) firstToOpen = i;
                tabsMenu.children('ul').append('<li id="' + tab.attr('id') + '_m"><span>' + tab.attr('title') + '</span></li>');
            });



            var buttons = tabsMenu.find('li');
            tabsMenu.find('li:first').addClass('first');
            tabsMenu.find('li:last').addClass('last');

            //click event
            buttons.each(function(i){
                jQuery(this).click(function(){
                    buttons.removeClass('active');
                    buttons.eq(i).addClass('active');
                    tabs.removeAttr('title');
                    tabs.hide(options.speed);
                    tabs.eq(i).show(options.speed);
                });
            });

            //Hide tab loader gif
            jQuery('.TabLoader').hide();
            //Open first tab
            buttons.eq(firstToOpen).click();
        });
    }
