$(function() {
	var _ua = (function(){//ua判定
    return {
        ltIE6:typeof window.addEventListener == "undefined" && typeof document.documentElement.style.maxHeight == "undefined",
        ltIE7:typeof window.addEventListener == "undefined" && typeof document.querySelectorAll == "undefined",
        ltIE8:typeof window.addEventListener == "undefined" && typeof document.getElementsByClassName == "undefined",
        ie:document.uniqueID,
        firefox:window.globalStorage,
        opera:window.opera,
        webkit:!document.uniqueID && !window.opera && !window.globalStorage && window.localStorage,
        mobile:/android|iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase())
      }
	})();
    if(_ua.mobile){//モバイル端末向けにFLASHを置き換え。
		$('section#topimg').replaceWith('<section id="topimg"><section id="nonfl"></section></section>');
	}
    if(_ua.ltIE6||_ua.ltIE7){//itIE8に警告表示。
      $('body').prepend('<div class="error">あなたは旧式ブラウザをご利用中のため、表示が正しくない可能性がございます。このウェブサイトを快適に閲覧するにはブラウザをアップグレードしてください。</div>');
    }
	var num=0;
    $('nav>ul>li:not(.stuck)')
	.each(function(){
		$(this).css('background', 'url(/lib/img/nav'+num+'_.png) no-repeat').css('background-position','left top');
	  num++;
    })
	.click(function(){
		 window.location=$(this).find("a").attr("href");
		 return false;
	})
    .find('img').hover(
        function(){
          $(this).stop().animate({'opacity' : '0'}, 300);
        },
        function(){
          $(this).stop().animate({'opacity' : '1'}, 600);
        }
    );
	$('nav>ul>li:eq(3), nav>ul>li:eq(1)>ul>li').css('display', 'none');
	$('nav>ul>li>ul>li, header')
	 .click(function(){
	 window.location=$(this).find("a").attr("href");
	 return false;
	})
	.hover(function(){
		$(this).find('a').addClass('ahover');
	},function(){
		$(this).find('a').removeClass('ahover').addClass('aclear');
	});
    $('a[href*=#]').click(function() {
      var $target=$(this.hash);
      var targetY=$target.offset().top;
      $($.browser.opera ? document.compatMode == 'BackCompat' ? 'body' : 'html' :'html,body').animate({scrollTop: targetY},500);
	  return false;
    });
	$('nav>ul>li:eq(7)').css('padding','30px 0px');
});
