var tid;
var count = 0;
var home = true;

$(function(){
  
  // logo
  $('#logo').click(function(){location.href='/'});
  
  // menu over
  $('.over').hover(
    function(){this.src = "img/menu/" + $(this).attr('id') + "-over.gif"},
    function(){this.src = "img/menu/" + $(this).attr('id') + ".gif"}
  );
  
  $('.shohin-over').hover(
    function(){this.src = "img/shohinShokai/" + $(this).attr('id') + "-over.png"},
    function(){this.src = "img/shohinShokai/" + $(this).attr('id') + ".png"}
  );
  
  // links
  var to;
  $('.menu-link').click(function() {
    to = $(this).attr('rel');
    if (home) {
      norenAnimation();
      wait = 1500;
      home = false;
    } else {
      wait = 0;
    }
    setTimeout(function() {
      $('#display').fadeOut('normal', function() {
        $(this).load(to,'',function(){
          $(this).fadeIn('normal');
        });
      });
    }, wait);
  });
  $('.fadein img:gt(0)').hide();
});

function norenAnimation() {
  tid = setInterval(function(){
    $('.fadein :first-child').fadeOut('normal').next('img').fadeIn('normal').end().appendTo('.fadein');
    if (count++ == 12) clearInterval(tid);
  }, 100);
};

