$(document).ready(function(){
  // bind the google map links
  $("table.data td.location a").click(function(){
    var lng = $(this).attr("longt");
    var lat = $(this).attr("latt");

    $.facebox(function() {
      $.facebox.setDimensions({width:"600px", height:"400px"});
      $.facebox.content().geoMarker(lat, lng);
    });
    
    return false;
  })
  
  // bind the team filtering
  $("#view_by_team").change(function() {
    var filter = $(this).val()
    // reset the previous filter
    $(".game-group").show().find("tr").show()
    
    if (filter != "View All") {
      // easier to do this than try to hide items not containing the selected item
      $(".game-group tbody tr").hide()
      $("tbody tr:contains('"+filter+"')").show()
      
      // hide the empty game groups to prevent header dates from showing up
      $.each($(".game-group"), function() {
        if ($(this).find("tbody tr:visible").length == 0)
          $(this).hide()
     })
    }
  })
})
