$(function(){
/*
 * @ スライドナビゲーション
 * @ Cookieを使って開閉をコントロール
*/
// ナビゲーションで使うCookieを読みこんでおく
var cookie = ($.cookie("menu") && $.cookie("menu")!=null) ? $.cookie("menu") : "";
$("ul.sub_nav","div#arealist").each(function(i){
	// 開閉ナビで使う変数定義
	var me = $(this),
		box = me.parent(), // 親要素のdiv.nav
		heading = me.prev().append("<span class='toggle'></span>"),
		// 兄要素のh3にspan.toggleを追加して変数に保存
		toggle = $("span.toggle",heading), // Toggle
		pos = "["+i+"]"; // Cookieに保存する
		
	// クッキーに[i]がある場合はナビを表示する
	if($.cookie("menu")==null
	|| !cookie.match(new RegExp(pos))){
		me.hide();
		toggle.hide();
	}else{
		box.addClass("opened");
		heading.addClass("opened");
	}
	
	// Toggleボタンの表示非表示
	heading.hover(function(){
		toggle.show();
	},function(){
		// h3.openedの場合はToggleを表示したままにする
		if(!heading.hasClass("opened")) toggle.hide();
	});
	
	// Toggleクリック時の動作
	toggle.click(function(){
		heading.toggleClass("opened");
		if(!box.hasClass("opened")){
			box.addClass("opened");
			cookie += pos;
			$.cookie("menu",cookie,{expires:7,path:'/'});
			//パスを指定することで、ページごとの保存ではなくサイト全体で同じcookieを使う。
		}else{
			cookie = cookie.replace(pos,"");
			$.cookie("menu",cookie.length==0 ? null : cookie);
		}
		
		// アニメーション設定
		me.animate({
			height: "toggle"
		},{
			//easing: "easeOutBounce", // jQuery Easing
			easing: "easeInQuad", // jQuery Easing
			duration: 400,
			complete: function(){
				if(!heading.hasClass("opened")) box.removeClass("opened");
			}
		});
	});
});
});

function func(){
    $("#fade").toggle("slow");
}
function func_northjapan(){
    $("#map_northjapan").toggle("slow");
}
function func_tokyo(){
    $("#map_tokyo").toggle("slow");
}
function func_kantou(){
    $("#map_kantou").toggle("slow");
}
function func_shinetsu(){
    $("#map_shinetsu").toggle("slow");
}
function func_tokai(){
    $("#map_tokai").toggle("slow");
}
function func_kansai(){
    $("#map_kansai").toggle("slow");
}
function func_chugoku(){
    $("#map_chugoku").toggle("slow");
}
function func_shikoku(){
    $("#map_shikoku").toggle("slow");
}
function func_kyushu(){
    $("#map_kyushu").toggle("slow");
}
