var tabs = [ 
            [ '#Home', '#home-tab' ],
            [ '#Connect', '#connect-tab' ],
            [ '#Learn', '#learn-tab' ],
            [ '#Share', '#share-tab' ]
           ];
var currentTabIndex = 0;

// Go to defined or next tab
function switchToTab( tabName ) {
    // hide the selected tab
    $(tabs[ currentTabIndex ][ 1 ]).fadeOut(
      250,
      function() {
         $(tabs[ currentTabIndex ][ 0 ]).removeClass('selected');
         $(tabs[ currentTabIndex ][ 1 ]).css('display', 'none');

         // get the tab number
         if( tabName == undefined ) {
             currentTabIndex++;
             if( currentTabIndex == 4 ) currentTabIndex = 0;
         } else {
             // find index for the clicked tab
             for( i = 0; i < 4; i++ ) {
                 if( tabName == tabs[ i ][ 0 ] ) {
                     currentMenuIndex = i;
                 }
             }
             currentTabIndex = currentMenuIndex;
         }
 
         // show tab
         $(tabs[ currentTabIndex ][ 0 ]).addClass('selected');
         $(tabs[ currentTabIndex ][ 1 ]).fadeIn(
                                                250,
                                                function() {
                                                    $(tabs[ currentTabIndex ][ 1 ]).css('display', 'block');
                                                });


      });
              
}


$(function() { 
        $("#second-menu li").click(
          function(){
              var currentMenuName = '#' + $(this).attr("id");
              switchToTab( currentMenuName );
          }
        );
/*
        $("#second-menu").everyTime(
           3000,
           'rotator',
           function() {
               switchToTab();
           }
        );

        $('#second-menu,#text-wrapper-center').mouseover(function() {
                $('#second-menu').stopTime('rotator');
        });     

        $('#second-menu,#text-wrapper-center').mouseout(function() {
                $("#second-menu").everyTime(
                   3000,
                   'rotator',
                   function() {
                     switchToTab();
                   }
                 );
        });     
*/
});

