function hideTr(element)
{
   var next = element.next();
   
   if (next.hasClass('hhider')) return;
   else if (next.hasClass('hider')) {
      next.find("td.janlink").css({'background-color':'#FF0000'});
      next.find("td.janlink").css({'background':'url(i/toggle.gif) no-repeat left center'});
      next.hide();
      next.next().find('div:first-child').hide();
      hideTr(next);
   }
   else if (next.hasClass('hidden')) {
      next.hide();
      hideTr(next);
   }
   else if (next.hasClass('delim')) {
      next.hide();
      hideTr(next);
   }
   else hideTr(next);
}

function showTr(element)
{
   var next = element.next();
   if (next.hasClass('hhider')) return;
   else if (next.hasClass('hider') || next.hasClass('delim')) {
      next.find("td.janlink").css({'background-color':'#FF0000'});
      next.find("td.janlink").css({'background':'url(i/toggle.gif) no-repeat left center'});
      next.show();
      showTr(next);
   }
   else if (next.hasClass('hidden')) {
   next.show();
   showTr(next);
   }
   else if (next.hasClass('delim')) {
      next.show();
      showTr(next);
   }
   else showTr(next);
}

$(document).ready(function() {
$("a.screenshot").click( function(e) { e.stopPropagation(); })
$("td.janlink").hover(
 function () { $(this).css({'cursor':'pointer', 'background-color':'#F4F4F4'}); }, 
 function () { $(this).css({'cursor':'default', 'background-color':'#FFFFFF'});});

$("td.jjanlink").parent().hover(
 function () { $(this).css({'cursor':'pointer'}); }, 
 function () { $(this).css({'cursor':'default'});});
$("td.jjanlink").hover(
 function () { $(this).css({'cursor':'pointer'}); }, 
 function () { $(this).css({'cursor':'default'});});

$("td.jjanlink").parent().css({'background-color':'#F4F4F4'}); 
$("td.jjanlink").css({'background-color':'#F4F4F4'});
    
$('td.janlink').css({'background':'url(i/toggle.gif) no-repeat left center'});
//<->
$('td.jjanlink').css({'background':'url(i/toggled2.gif) no-repeat left center'});

$('tr.hider').click(
 function () {
  if ($(this).find("td.janlink").css("background").indexOf("toggle.gif") > 0) {
   $(this).find("td.janlink").css({'background':'url(i/toggled.gif) no-repeat left center'});
   $(this).next().find('div:first-child').slideDown('fast', function() { });
  }
  else {
   $(this).find("td.janlink").css({'background':'url(i/toggle.gif) no-repeat left center'});
   $(this).next().find('div:first-child').slideUp('fast', function() { });
  }
 }
);

$('tr.hhider').toggle(
 //<->
 function () {
  $(this).removeClass("toggled");
  $(this).find("td.jjanlink").css({'background':'url(i/toggle2.gif) no-repeat left center'});
  hideTr($(this));
 },
 function () {  
  $(this).addClass("toggled");
  $(this).find("td.jjanlink").css({'background':'url(i/toggled2.gif) no-repeat left center'});
  showTr($(this));
  
 }
);

});

