//####################################################################################
//　クッキーファイル書き込み
//       1999 Presented By KaZuhiro FuRuhata
//       This script is free!!
//####################################################################################

//-------------------------------------------------------------------------------
//　一時的にCookieを使用するための関数
//　成功した時はtrue,失敗した時はfalseを返す
//-------------------------------------------------------------------------------
function tempCookie(theName__,theValue__)
{
	if ((theNmae != null) && (theValue__ != null))
	{
		document.cookie = theName__ + "="+theValue__;
	    return true;
	}
	return false;
}

//　Cookieにデータを保存する
//　成功した時はtrue,失敗した時はfalseを返す
function setCookie(theName__,theValue__,theDay__)
{
	if ((theName__ != null) && (theValue__ != null))
	{
		var expDay__ = "Wed, 01 Jan 2020 18:56:35 GMT";	//　指定されない場合とりあえず2020年
		if (theDay__ != null)
		{
			theDay__ = eval(theDay__);	//　文字列の場合でも数値にする（念のため）
			var 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;
}

//-------------------------------------------------------------------------------
//　Cookieのデータを削除する（即座にファイルから消える訳じゃありません）
//　常にtrueを返す
//-------------------------------------------------------------------------------
function deleteCookie(theName__)
{
	document.cookie = theName__ + "=;expires=Thu,01-Jan-70 00:00:01 GMT";
	return true;
}

//-------------------------------------------------------------------------------
//　Cookieから指定されたデータを抜きだす
//　成功した時はnull以外,失敗した時はfalseを返す
//-------------------------------------------------------------------------------
function getCookie(theName__)
{
	theName__ += "=";	//　=を追加して検索の手抜きをする
	theCookie__ = document.cookie+";";	//　検索時最終項目で-1になるのを防ぐ
	start__ = theCookie__.indexOf(theName__);	//　指定された名前を検索する
	if (start__ != -1)
	{
		end__ = theCookie__.indexOf(";",start__);
		return unescape(theCookie__.substring(start__+theName__.length,end__));
	}
	return false;
}



