function goTab(id,series)          // Swap content on series page
{
    var maxtabs = 4;
    if (id < 1 || id > 4) { return; }
    var arr = ['','','Available Models','Gallery','Buy in Retail Stores']; 

    var newtab = $('#tab'+id);
    newtab.addClass('hereNav').blur();

    for (var i=1; i<=maxtabs; i++) {
        var tabid = '#tab'+i;
        var tabobj  = $(tabid);
        if (tabobj && i != id) {
            var divobj = $(tabid+'_data');
            divobj.css({ display:"none" }); 
            tabobj.removeClass('hereNav');
        }
    }
    $('#tab'+id+'_data').css({ display:"block" }); 
    if (id === 1)
        { $('#series_head')[0].innerHTML = series+' Series Overview'; }
    else
        { $('#series_head')[0].innerHTML = arr[id]; }
}

function goTabSub(id)          // Swap galleries on gallery page
{   
    $('div.thumbs').css({ display:"none" });
    $('div#'+id).css({ display:"block" });
// Set main image
    var f = '/products/series/' + id.substr(0,2) + '/' + id + '/gallery_01.jpg';
    $('img#mainimage').attr('src',f);
    $('#T'+id+' td').removeClass('show');   // In case they click the current series button after different image
    $('#T'+id+' td:first').addClass('show');
}

$(document).ready(function() {
  $('.tn td img').click(function() {
    var f = this.src.replace(/T.gif/,'.jpg');
    $('img#mainimage').attr('src',f);
    $('.tn td').removeClass('show');
    $(this).parent().addClass('show');
  });     

  $("form#main_form").bind("submit", function() { // attach submit testing requirements
      var i, cnt=0, el=$("form#main_form input[@type=checkbox]");
      for (i=0; i < el.length; i++) if (el[i].name.substring(0, 2) == "s_" && el[i].checked) { cnt++; }
      if (cnt < 2 || cnt > 5) {
          alert("To compare systems you must first select the check boxes for the\n" +
                "systems you wish to compare. Select 2 to 5 systems by clicking on\n" +
                "the check boxes located by the information for each system.");
          return false;
      }
      this.submit();
  });

  $('img').attr('title', function(){ return this.alt; }); // FF uses title for tooltip
});     
