//------------------------------------------------------------------------------
// CheckPostingComment
//	コメント投稿時チェック処理
//	引数	なし
//	戻り値	なし
//------------------------------------------------------------------------------
function CheckPostingComment(){

	if (	GetCookieValue("USER_SESSION")   == null &&
		GetCookieValue("READ_AGREEMENT") == null
	){
		window.open("http://www.keikai.topblog.jp/tc_kiyaku.html","AGREEMENT","toolbar=no,location=no,directories=no, status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=500");
		SetCookieValue("READ_AGREEMENT", "TRUE");
		return null;
	}
	document.comment_form.submit();
	return null;
}

//------------------------------------------------------------------------------
// GetCookieValue
//	Cookie値取得処理
//	引数	[1] Cookie変数名
//	戻り値	[1] Cookie値	(Cookie未設定時 : null)
//------------------------------------------------------------------------------
function GetCookieValue(name){
	var cookie;
	var end;
	var offset;
	var start;
	var value = null;

	cookie = document.cookie + ";";
	name += "=";
	offset = cookie.indexOf(name);
	if ( offset != - 1){
		start = offset + name.length;
		end   = cookie.indexOf(";", offset);
		value = unescape(cookie.substring(start, end));
	}
	return value;
}

//------------------------------------------------------------------------------
// DeleteCookieValue
//	Cookie値削除処理
//	引数	[1] Cookie変数名
//	戻り値	なし
//------------------------------------------------------------------------------
function DeleteCookieValue(name){
	SetCookieValue(name, "", -60);
	return;
}

//------------------------------------------------------------------------------
// SetCookieValue
//	Cookie値設定処理
//	引数	[1] Cookie変数名
//		[2] Cookie値
//		[3] 有効期間(秒)
//	戻り値	なし
//------------------------------------------------------------------------------
function SetCookieValue(name, value, term){
	var cookie;
	var expire = null;

	if ( term != null ){
		expire = new Date();
		expire.setTime(expire.getTime() + (term * 1000));
	}
	cookie = name + "=" + escape(value) + ";";
	if ( expire != null){
		cookie += "expires=" + expire.toGMTString() + ";";
	}
	document.cookie = cookie;

	return;
}
