var currentContent = 'content1';

function show_content1(obj) {
  $(".itabsel").attr("class", "itab");
  obj.setAttribute("class", "itab itabsel");
  obj.setAttribute("className", "itab itabsel");  

  var current = $("." + currentContent);
  current.fadeOut('slow', function() {
    $(".content1").fadeIn('slow');
  });  
  currentContent = "content1";
}

function show_content2(obj) {
  $(".itabsel").attr("class", "itab");
  obj.setAttribute("class", "itab itabsel");
  obj.setAttribute("className", "itab itabsel");
  var current = $("." + currentContent);
  current.fadeOut('slow', function() {
    $(".content2").fadeIn('slow');
  });  
  currentContent = "content2";
}

function show_content3(obj) {
  $(".itabsel").attr("class", "itab");
  obj.setAttribute("class", "itab itabsel");
  obj.setAttribute("className", "itab itabsel");
  var current = $("." + currentContent);
  current.fadeOut('slow', function() {
    $(".content3").fadeIn('slow');
  });
  currentContent = "content3";
}



var current_assoc_page = 0;

$(document).ready(function() {
    var nb = $(".content3 tr").length;
    for ( i = 2; i < nb; i++ ) {
      var tr = $(".content3 tr:eq(" + i + ")");
      tr.css("display", "none");
    }
    
    $(".content3 .arrows a:eq(0)").click(function() { return idetail_show(--current_assoc_page) });
    $(".content3 .arrows a:eq(1)").click(function() { return idetail_show(++current_assoc_page) });

    idetail_update_arrows();
 });


function idetail_show(page) {
  var nb = $(".content3 tr").length;

  if ( page * 2 >= nb || page < 0 )
    return false; 

  for ( i = 0; i < nb; i++ ) {
    var tr = $(".content3 tr:eq(" + i + ")");
    tr.css('display', 'none');
  }


  var currentElement = (page * 2);
  for ( i = currentElement; i < currentElement + 2; i++ ) {
    var tr = $(".content3 tr:eq(" + i + ")");
    tr.fadeIn("slow");
  }

  idetail_update_arrows();

  return false;
}

function idetail_update_arrows() {
  var nb = $(".content3 tr").length;

  if ( (current_assoc_page + 1) * 2 >= nb )
    $(".content3 .arrows a:eq(1)").css('display', 'none');
  else 
    $(".content3 .arrows a:eq(1)").css('display', 'inline');

  if ( (current_assoc_page * 2) == 0 ) 
    $(".content3 .arrows a:eq(0)").css('display', 'none');
  else 
    $(".content3 .arrows a:eq(0)").css('display', 'inline');
    

}

