    <!--
    $(function () {       
        $(".bmb-gallery-wrapper a.lightbox").lightBox();

        // hide all gallery tables
        $("div.bmb-gallery-wrapper table").hide();
        // show first table in each gallery
        $("div.bmb-gallery-wrapper table[id$='_table_1']").show();
        // loop through each gallery
        $("div.bmb-gallery-wrapper").each(function() {
          // get the id of the gallery
          gId = $(this).attr("id");
          // count up number of pages in gallery
          gPageCount = $("#" + gId + " table").length;
          // show page x of y for each gallery
          $("div#" + gId + " div.pagecounter").html("Page 1 of " + gPageCount);
          // show paging links for any gallery with gPageCount > 1
          if (gPageCount > 1) {
            gPaging = "";
            for (i=1;i<=gPageCount;i++) {
              // make page 1 active
              if (i==1) {
                pagingClass = " active";
              } 
              else {
                pagingClass = "";
              }
              gPaging = gPaging + '<span class="' + gId.replace("bmb-gallery-id_", "") + '-' + i + pagingClass + '">' + i + '</span> | ';
            }

            gPaging = '<span class="' + gId.replace("bmb-gallery-id_", "") + '-p">< Prev</span> | ' + gPaging + '<span class="' + gId.replace("bmb-gallery-id_", "") + '-n">Next ></span>';
            $("div#" + gId + " div.paging").html(gPaging);
          }
  
        });
  


        $('div.bmb-gallery-wrapper div.paging span').click(function () {
          // work out what was clicked
          //var arrPaging = this.id.split('-');
          var arrPaging = $(this).attr("class").replace(" active", "").split('-');
          var gIdClicked = arrPaging[0];
          var pIdClicked = arrPaging[1];
          // count up number of pages in gallery
          gPageCount = $("#bmb-gallery-id_" + gIdClicked + " table").length;
          // work out active page
          arrCurrent = $("#bmb-gallery-id_" + gIdClicked + " div.paging span.active").attr("class").replace(" active", "").split('-');
          pIdCurrent = arrCurrent[1];
          
          //alert("clicked: " + $(this).attr("class") + "\ngIdClicked: " + gIdClicked + "\npIdClicked: " + pIdClicked + "\ngPageCount: " + gPageCount + "\npIdCurrent: " + pIdCurrent);

          // work out which page to show
          if (pIdClicked >= 1 && pIdClicked <= gPageCount) {
            pIdTarget = pIdClicked;
          }
          if (pIdClicked == "p") {pIdTarget = (pIdCurrent*1) - 1;}
          if (pIdClicked == "n") {pIdTarget = (pIdCurrent*1) + 1;}

          // fix if we have stepped off the ends
          if (pIdTarget > gPageCount) {pIdTarget = gPageCount;}
          if (pIdTarget < 1) {pIdTarget = 1;}

          //alert("pIdTarget: " + pIdTarget);

          $('div#bmb-gallery-id_' + gIdClicked + ' table').hide();
          $('table#bmb-gallery_' + gIdClicked + '_table_' + pIdTarget).show();
          $('div#bmb-gallery-id_' + gIdClicked + ' div.paging span').removeClass('active');
          $('div#bmb-gallery-id_' + gIdClicked + ' div.paging span.' + gIdClicked + "-" + pIdTarget).addClass('active');
          // update page x of y
          $("div#bmb-gallery-id_" + gIdClicked + " div.pagecounter").html("Page " + pIdTarget + " of " + gPageCount);


        });       


    });
    //-->
