////////////////////////////////////////////////////////////////////////////////
//
// common.js
//
////////////////////////////////////////////////////////////////////////////////
/**
* init
*/
$(document).ready(function() {
	/**
	* pngfix
	*/
	$(document).pngFix();
	/**
	* fontsize changer
	*/
	$("#fontChangeS").click(function() {
		resetFontsizeButton();
		$(this).removeClass("defaultS");
		$(this).addClass("activeS");
		//
		resetFontsize();
		$("div#container").addClass("fontS");
		//
		$.cookie("fontSize","small",{ expires:30 , path:'/' });
    });
	$("#fontChangeM").click(function() {
		resetFontsizeButton();
		$(this).removeClass("defaultM");
		$(this).addClass("activeM");
		//
		resetFontsize();
		$("div#container").addClass("fontM");
		//
		$.cookie("fontSize","mideum",{ expires:30 , path:'/' });
    });
	$("#fontChangeL").click(function() {
		resetFontsizeButton();
		$(this).removeClass("defaultL");
		$(this).addClass("activeL");
		//
		resetFontsize();
		$("div#container").addClass("fontL");
		//
		$.cookie("fontSize","large",{ expires:30 , path:'/' });
    });
	/**
	* image preload
	*/
	// フォントサイズ変更ボタン画像
	jQuery.preLoadImages(getThisPath() + "common/img/fontsizeChanger_buttonS.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/fontsizeChanger_buttonS_active.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/fontsizeChanger_buttonM.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/fontsizeChanger_buttonM_active.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/fontsizeChanger_buttonL.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/fontsizeChanger_buttonL_active.gif");
	// フッターリンク画像
	jQuery.preLoadImages(getThisPath() + "common/img/footerNavigation_label_01_on.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/footerNavigation_label_02_on.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/footerNavigation_label_03_on.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/footerNavigation_label_04_on.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/footerNavigation_label_05_on.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/footerNavigation_label_06_on.gif");
	jQuery.preLoadImages(getThisPath() + "common/img/footerNavigation_label_07_on.gif");
	//
	initFontSize();
	setGlobalNavigation();
	initGlobalNavigation();
});
//
/**
* globalNavigation
*/
function setGlobalNavigation() {
	$("#nav > dl").hover(function() {
		if($(this).children("dd").length != 0) {
			$(this).children("dd:not(:animated)").slideDown("fast");
		}
    },function() {
		if($(this).children("dd").length != 0) {
			$(this).children("dd").slideUp("fast");
		}
    });
}
function initGlobalNavigation() {
	$(window).unload(function() {
		$("#nav > dl dd").hide();
	});
}
//
/**
* fontsize changer function
*/
function resetFontsize() {
	$("div#container").removeClass("fontS");
	$("div#container").removeClass("fontM");
	$("div#container").removeClass("fontL");
}
function resetFontsizeButton() {
	$("#fontChangeS").removeClass("activeS");
	$("#fontChangeM").removeClass("activeM");
	$("#fontChangeL").removeClass("activeL");
	$("#fontChangeS").addClass("defaultS");
	$("#fontChangeM").addClass("defaultM");
	$("#fontChangeL").addClass("defaultL");
}
function initFontSize() {
	var _fontSize = $.cookie("fontSize");
	if(_fontSize != null) {
		switch(_fontSize) {
			case "small":
				resetFontsizeButton();
				$("#fontChangeS").removeClass("defaultS");
				$("#fontChangeS").addClass("activeS");
				//
				resetFontsize();
				$("div#container").addClass("fontS");
			break;
			case "medium":
				resetFontsizeButton();
				$("#fontChangeM").removeClass("defaultM");
				$("#fontChangeM").addClass("activeM");
				//
				resetFontsize();
				$("div#container").addClass("fontM");
			break;
			case "large":
				resetFontsizeButton();
				$("#fontChangeL").removeClass("defaultL");
				$("#fontChangeL").addClass("activeL");
				//
				resetFontsize();
				$("div#container").addClass("fontL");
			break;
		}
	} else {
		$("div#container").addClass("fontM");
	}
}
