//**********************************************************
// 同意画面用
//**********************************************************

//---------------------------------------------------------
// cookieをセットして、コンテンツ概要画面へ遷移する。
//---------------------------------------------------------
function goDetail()
{
	key = "agree" + getContentsNoAtAgree();
	
	setCookie(key,"true");
	
	detailURL = "detail" + getContentsNoAtAgree() + "lite.html";
	
//	location.href(detailURL);  // location.hrefだとNN4.7で移動しない。
	location.replace(detailURL);
}

//---------------------------------------------------------
// コンテンツNoを取得する。(同意画面用)
//---------------------------------------------------------
function getContentsNoAtAgree()
{
	qStr = location.search;
	no = qStr.substr(1,qStr.length-1);
	
	return no;
}

//---------------------------------------------------------
// cookieをセットする。有効期限は指定しない。
//---------------------------------------------------------
function setCookie(key,value)
{
	cookie = key + "=" + escape(value) + ";";
	
	document.cookie = cookie;
	
}

//**********************************************************
// コンテンツ画面用
//**********************************************************

var detaillite = "detaillite";  // コンテンツ概要画面のファイル名
var detail     = "detail";      // コンテンツ詳細画面のファイル名

//---------------------------------------------------------
// cookieをチェックする。なかったら、同意画面へ遷移させる。
//---------------------------------------------------------
function checkCookie()
{
	matchStr = getCookieKey() + "=";
	
	if(document.cookie.match(matchStr) == null)
	{
		// 同意画面へリダイレクト
		location.replace("indiv_agreement.html?" + getContentsNo());
	}
	else
	{
		return true;
	}
}

//---------------------------------------------------------
// cookieのkeyを取得する。
//---------------------------------------------------------
function getCookieKey()
{
	return "agree" + getContentsNo();
}

//---------------------------------------------------------
// コンテンツNoを取得する。(コンテンツ画面用)
//---------------------------------------------------------
function getContentsNo()
{
	serchStr = detail;
	pathname = location.pathname;
	
	startPosition = pathname.indexOf(serchStr,0) + serchStr.length;
	
	endPosition = pathname.indexOf("lite",0);
	if (endPosition == -1) {
		endPosition = pathname.indexOf(".htm",0);
	}
	
	no = pathname.substring(startPosition,endPosition);
	
	return no;
}








// 不使用
function getAgreeURL()
{
	pathname = location.pathname;
	
	end = pathname.lastIndexOf("/") + 1;
	
	agreeFile = "indiv_agreement.html";
	agreeURL = location.protocol + location.host + pathname.substring(0,end) + agreeFile;
	
	return agreeURL;
}

