$(function(){
  var $btn  = $('ul#btn li');
  var $img  = $('#img img');
  var $text = $('#text img');
  var count = 1;
  var time  = 8000;
  var timerID;
  $img.eq(0).delay(500).fadeIn(1800, function() {
    $text.eq(0).css('top', '10px').delay(200).show().animate({ 'opacity' : 1, 'top' : 0 }, 1500);
    slideTimer();
  });
  $btn.click(function() {
    if (count != $btn.index(this) + 1 && !(count == 0 && $img.length == $btn.index(this) + 1)) {
      count = $btn.index(this);
      $img.stop(true, true).css('z-index', 0).fadeOut(800).eq(count).css('z-index', 1).fadeIn(800);
      $text.stop(true, true).hide().css('opacity', 0)
        .eq(count).css('top', '10px').delay(1000).show().animate({ 'opacity' : 1, 'top' : 0 }, 1500);
      $btn.not($(this)).find('span').fadeTo('', 1).removeClass('active').end().end()
        .find('span').eq(count).fadeTo('', 0).addClass('active');
      count = count == $img.length - 1 ? 0 : count + 1;
    }
  }).mouseup(slideTimer);
  function slideTimer() {
    clearInterval(timerID);
    timerID = setInterval(function() {
      $btn.eq(count).click();
    }, time);
  }
  // IE•s‰Â
//  $btn.find('span').hover(
//    function() {
//      $(this).stop(true, false).fadeTo('', 0);
//    },
//    function() {
//      if ($(this).is('.active')) {
//        return false;
//      }
//      $(this).fadeTo('', 1);
//    }
//  );
  $btn.hover(
    function() {
      $(this).find('span').stop(true, false).fadeTo('', 0);
    },
    function() {
      if ($(this).find('span').is('.active')) {
        return false;
      }
      $(this).find('span').fadeTo('', 1);
    }
  );
});
$(function() {
  $('dl.section03, dl.section04')
    .css('cursor', 'pointer')
    .click(function() {
      location.href = $(this).find('dt a').attr('href');
    }).hover(
      function() { $(this).stop(true, false).fadeTo('', 0.7).find('img').stop(true, false).fadeTo('', 0.7); },
      function() { $(this).fadeTo('', 1).find('img').fadeTo('', 1); }
    );
  if (navigator.userAgent.indexOf('MSIE 8') != -1) {
    $('a').focus(function() {
      this.blur();
    });
  }
});

