
/* ページ開いた時のビューの調整 */
function checkCookie(){
	// ポップアップで出てくるモーダルウィンドウの中身
	if($.cookie('visited') == 'true'){ 	// 過去にサイトに訪れたことがある場合
		$.cookie('visited', 'true',  { expires:365, path:'/', domain:'.astamuse.com' } );
		hmFontSizeSet($.cookie('fontSize'));
	}else{								 // 初めてサイトに訪れた場合
		$.cookie('visited','true',  { expires:365, path:'/', domain:'.astamuse.com' });
		var chk = $.cookie("visited");
	}
}


/* ヘッダーメニュー：フォントサイズ設定 fix */
this.hmFontSizeSet = function(fontSize){
	var hmFontMap = {
		large 		: '120%',
		middle		: '100%',
		small		: '80%'
	};
	
	for(var key in hmFontMap){
		if(fontSize == key){
			$("#middle").css('font-size', hmFontMap[key] );
		}
	}
	
	var tid = fontSize + "Font";
	$("#fontSelect a").each(function(){
		if($(this).attr("id") == tid ){
			$(this).attr("class", "selected");
		}else{
			$(this).attr("class", "");
		}
	});
};

/* ヘッダーメニュー：フォントサイズ変更 fix */
this.hmFontSizeMod = function(){
	$("#fontSelect a").each(function(){
		$(this).click(function(){
			fSize = $(this).attr("id");
			fSize = fSize.replace("Font", "");
	
			$.cookie("fontSize", fSize, { expires:365, path:'/', domain:'.astamuse.com' });
			hmFontSizeSet(fSize);
		});
	});
	
	var fSize = $.cookie("fontSize");
	if(fSize != ""){
		hmFontSizeSet(fSize);
	}
};

this.gadgetClose = function(){
	$("#gadgetCol .gadgetClose").each(function(){
		$(this).click(function(){
			tarId = "#" + $(this).attr("id").replace(/_close/, "");
			gname = $(tarId + " h3").text();
			if(window.confirm(gname + "を非表示にしますか？（「表示」→「ガジェット」から再表示できます）")){
				$(tarId).css("display", "none");
			}
		});
	});
};



$(document).ready(function(){
	gadgetClose();
	checkCookie();
	hmFontSizeMod();
});