$(function() {
	// サイドナビの下層項目をマウスオーバーでフェードイン！
    // -------------------------------------------------------------------------
	// 第3階層の背景位置設定
	$('#snav dd .hover-nav ul').each(function(){
		$(this).find('li > a').each(function(index){
			var vpos = -(30 * index) + 'px';
			$(this).css('background-position', '0 ' + vpos);
		});
	});
	$('#snav dd.hover-sub').hover(
		function() { $(this).find('.snav3.hover-nav').fadeIn(); },
		function() { $(this).find('.snav3.hover-nav').fadeOut(); }
	);

	// グローバルナビの下層項目をマウスオーバーで開く！
    // -------------------------------------------------------------------------
    // 第2階層の背景位置設定
    $('ul#gnav > li > ul').each(function(){
    	$(this).children('li').children('a').each(function(index){
    		var vpos = -(30 * index) + 'px';
    		$(this).css('background-position', '0 ' + vpos);
    	});
    });
    // 第3階層の背景位置設定
    $('ul#gnav ul ul').each(function(){
    	$(this).find('li > a').each(function(index){
    		var vpos = -(30 * index) + 'px';
    		$(this).css('background-position', '0 ' + vpos);
    	});
    });
    // マウスオーバー時の下層表示処理
    $("ul#gnav > li").hover(function(){
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    });

    $("ul#gnav li ul li:has(ul)").find("a:first").append(" &raquo; ");
    
    // IE用hover背景のちらつき防止
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
});