function setCookie(theName,theValue,theDay)
{
	if ((theName != null) && (theValue != null))
	{
//		expDay = "Wed, 01 Jan 2020 18:56:35 GMT";	//　指定されない場合とりあえず2020年
		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;
		}else{
			document.cookie = theName + "=" + escape(theValue);
		}
		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+";";	//　検索時最終項目で-1になるのを防ぐ
	start = theCookie.indexOf(theName);	//　指定された名前を検索する
	if (start != -1) {
		end = theCookie.indexOf(";",start);
		return unescape(theCookie.substring(start+theName.length,end));
	}
	return false;
}


function refer_Cookie()
{
	CK_name  = "CW_HTTP_REFER";
	CK_name01  = "CW_ACS_URL";

// 2004.10.04 ADD K.Kuwano		テスト環境時
//	CW_SRCHP = "hanabi.e-joho.co.jp";

	//referrerの綴りに注意してください。Javascriptでは「r」を重ねます。
	if (escape(document.referrer) != "") {
		CK_Value = unescape(document.referrer);
		CK_Value = escape(CK_Value);
	}else{
// 2004.09.13 MOD tanaka
//		CK_Value = "ブックマーク/メールソフト";
		CK_Value = "bookmark/mailsoft";
//		CK_Value = escape(CK_Value);
	}
	CK_Value01 = escape(document.URL);

	CK_Value2 = getCookie(CK_name);

	if ((! CK_Value2) || (CK_Value.indexOf(CW_SRCHP,0) == -1)) {
		CK_exp   = null;
		setCookie(CK_name, CK_Value, CK_exp);
		setCookie(CK_name01, CK_Value01, CK_exp);
	}else{
		CK_Value = CK_Value2;
	}
	return CK_Value;
}

	CK_Value = refer_Cookie();

