/* TABS WITH MEMORY BY DAVE REEDER */
(function($){
        memoryTabs = function() {
// ASSIGN A VARIABLE TO COOKIES VALUE
                var currentIndex = $.cookie("tabsMemory");
                
                // SET CURRENT TAB AND CURRENT PANELS
                if (currentIndex > 0) {
                                var currentTab = $('.tabNavigation a').eq(currentIndex-1);              
                                var currentPanel = $('.tabContainer > div').eq(currentIndex-1);
                        }
                else {
                                var currentTab = $('.tabNavigation a:first');
                                var currentPanel = $('.tabContainer > div:first'); 
                        }
                
                // SET CLASS TO MAKE CURRENT TAB STYLED CORRECTLY
                currentTab.addClass("currentTab");
                
                // HIDE ALL CONTENT PANELS, SHOW CURRENT TAB CONTENT PANEL
                $('.tabContainer > div').hide(); // HIDE ALL TABS TO 0
                currentPanel.show(); // SHOW CURRENT TAB
                
                // CLICK EVEN FOR EACH TAB IN NAV
                $('.tabNavigation a').each(            
                function( intIndex ){           // FOR EACH ELEMENT RUN THIS FUNCTION intIndex IS THE LOOP ITERATION INDEX
                    $(this).click(function(event) {
                        $('.tabContainer > div').hide();  /* hide all others out and then hide them */
                        $('.tabContainer > div').eq(intIndex).css("display", "block").show(); /* show required div */
                                                $('.tabNavigation a').removeClass();
                                                $(this).addClass('currentTab');								
                                                // SET COOKIE
                                                var cookieValue = $(this).attr('rel');
                                                //alert(cookieValue);
                                                $.cookie("tabsMemory", cookieValue, { expires: 7 });
												return false;
                    });
                }
            );

};

})(jQuery);
