function showHide(targetID) { //functionの宣言。受けとったIDは変数targetIDに格納。
	if( document.getElementById(targetID)) { //指定のIDのついたオブジェクトがあったら処理する
		//指定されたIDのstyle.displayがnoneなら
		if( document.getElementById(targetID).style.display == "none") {
			//blockに変更する
			document.getElementById(targetID).style.display = "block";
			document.getElementById(targetID + '_navi').style.display = "inline";
			// クッキーに登録
			setCookie(targetID, "block", 30);
		} else { //noneでなければ、つまりblockなら
			//noneにする
			document.getElementById(targetID).style.display = "none";
			document.getElementById(targetID + '_navi').style.display = "none";
			// クッキーから削除
			deleteCookie(targetID);
		}
	}
}

function initShowHide(target_list){
	for(i in target_list){
		if(getCookie(target_list[i])){
			showHide(target_list[i]);
		}
	}
}

function setCookie(theName, theValue, theDay)
{
	if(theName != null && theValue != null){
		expDay = "Wed, 01 Jan 2020 18:56:35 GMT";
		if(theDay != null){
			theDay = eval(theDay);
			setDay = new Date();
			setDay.setTime(setDay.getTime() + (theDay*1000*60*60*24));
			expDay = setDay.toGMTString();
		}
		document.cookie = theName + "=" + escape(theValue) + ";expires=" + expDay;
		return true;
	}
	return false;
}

function deleteCookie(theName)
{
	document.cookie = theName + "=;expires=Thu,01-Jan-70 00:00:01 GMT";
	return true;
}
function getCookie(theName)
{
	theName += "=";
	theCookie = document.cookie + ";";
	start = theCookie.indexOf(theName);
	if(start != -1){
		end = theCookie.indexOf(";", start);
		return unescape(theCookie.substring(start + theName.length, end));
	}
	return false;
}
