
//carousel function definition
function initCarousel(object, numScroll, isWrap){$(object).jcarousel({ wrap: isWrap , initCallback: mycarousel_initCallback, scroll: numScroll });}

$(document).ready(function(){  
  var results = new Array(); // for caching

  initCarousel('#team_tracker_carousel', 4);
  
  $('.team_nav_item').click(function(){
    tab   = $(this);
    team  = tab.attr("id").split('_')[2];

    /* set the tabs */
    $('.team_nav_item').removeClass('current');
    tab.addClass('current');

    if(results[team]==undefined){
      /* set loading */
      $('.team_tracker').html('<img src="/rw/SysConfig/WebPortal/nypost/images/loading_white.gif" alt="loading&hellip;" /> Loading');
      /* get the data */
      $.get('/Fragment/nypost/web/webpages/sports/blocks/team_tracker/' + team + '.dwc?style=/SysConfig/WebPortal/nypost/blocks/_sports/team_tracker/team_tracker_panel.jpt', {team: team }, function(result){
        $('.team_tracker').html(result);
        results[team] = result;
      });
    }else{
      $('.team_tracker').html(results[team]);
    }
  });
  $('.team_nav_item.first').click();
});	
