$(function() {

  $('h2').each(function() {
    title = $(this).attr('title');
    if (title != ''){
      $(this).html('<img src="/images/head-' + title + '.png" />');
    }
  });

  $('td.nav span[title]').each(function() {
    title = $(this).attr('title');
    if (title != ''){
      $(this).html('<img src="/images/nav-' + title + '-on.png" />');
    }
  });

  $('td.nav-link span[title]').each(function() {
    title = $(this).attr('title');
    if (title != ''){
      $(this).html('<img src="/images/nav-' + title + '-off.png" />');
    }
  });

  $('.splash li').each(function() {
    title = $(this).attr('title');
    if (title != ''){
      $(this).html('<img src="/images/' + title + '.png" />');
    }
  });

  $('.splash h4').each(function() {
    title = $(this).attr('title');
    if (title != ''){
      $(this).html('<img src="/images/' + title + '.png" />');
    }
  });

  $('.splash .mailto').each(function() {
    title = $(this).attr('title');
    if (title != ''){
      $(this).html('<img src="/images/' + title + '.png" />');
    }
  });


  // $('h2.off').nextAll().hide();
  // $('h2:last').siblings('.dots:last').show();
  // 
  // $('h2.off').live("click", function() {
  //   $(this).nextAll().slideDown();
  //   $(this).removeClass('off');
  //   $(this).addClass('on');
  //   return false;
  // });
  // 
  // $('h2.on').live("click", function() {
  //   $('h2:last').siblings('.dots:last').slideDown();
  //   $(this).nextAll().slideUp();
  //   $(this).removeClass('on');
  //   $(this).addClass('off');
  //   $('h2:last').siblings('.dots:last').slideDown();
  //   return false;
  // });

  // $('#top-nav td.nav').each(function(){
  //   $(this).addClass('sifrd');
  // });
  // $('#top-nav td.nav-link').each(function(){
  //   $(this).addClass('sifrd');
  // });

  currentRuleIndex = 1;
  setTimeout('swapRules()', 8000)

  $('#rule-2').hide();
  $('#rule-3').hide();
  
});

function swapRules() {

  if (currentRuleIndex == 3){
    nextIndex = 1
  } else {
    nextIndex = currentRuleIndex + 1;
  }
  $('#rule-' + currentRuleIndex).slideUp(1000);
  $('#rule-' + nextIndex).slideDown(1000);

  currentRuleIndex = nextIndex;
  setTimeout('swapRules()', 8000);
} 
