function goTab(id,series)          // Swap content on series page
{
    var maxtabs = 4;
    if (id < 1 || id > 4) { return; }
    var arr = ['','','Modelos disponibles','Galer\u00EDa','Where To Buy']; 

    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 = 'Resumen de la Serie '+series; }
    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("Puedes escoger de 2 a 5 sistemas para compararlos.\n" +
                "Selecciona las casillas de verificaci\u00F3n junto a la\n" +
                "informaci\u00F3n de cada sistema.");
          return false;
      }
      this.submit();
  });

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