﻿/// <reference path="jquery-1.4.2.min.js" />

(function ($) {

    $.fn.pager = function (options) {

        var opts = $.extend({}, $.fn.pager.defaults, options);

        return this.each(function () {

            $this = $(this);

            var wrapper = $(opts.wrapper, $this);
            var menuItems = $(opts.menuItems, $this);

            $(wrapper).each(function () {
                $(this).hide();
            });

            $(wrapper.get(0)).show();
            $(menuItems.get(0)).addClass("aTab");

            menuItems.click(function (e) {

                $(menuItems).removeClass("aTab");
                $(menuItems).addClass("iTab");
                $(this).removeClass("iTab");
                $(this).addClass("aTab");

                wrapper.hide();

                //$(wrapper.get($(this).index())).show();
                $(wrapper.get($(menuItems).index($(this)))).show();

                e.preventDefault();
                e.stopPropagation();
            });
        });
    };


    function debug($obj) {
        if (window.console && window.console.log)
            window.console.log($obj);
    };

    $.fn.pager.defaults = {
        wrapper: '.wrapper',
        menuItems: '.menuItem'
    };

})(jQuery);
