/* cookieを食べたり吐いたり腐らせたりする関数群 for nifty */

//プロバイダごとの設定
if(location.hostname == "gateway.nifty.com"){
	strPath = "/service/g-way/INTERNAL/seimei3/";
} else if(location.hostname == "check503.nifty.com"){
	strPath = "/service/g-way/INTERNAL_TEST/seimei3/";
} else if(location.hostname == "cgicheck.nifty.com"){
	strPath = "/seimei3/";
} else {
	strPath = "/seimei3/";
}


//食わす関数
function setCookie(name, val){
	var esc = escape( val );
	var strCookie  = name + "=" + esc + "; ";

	// 30日有効なクッキー
	myExp = new Date();
	myExp.setTime(myExp.getTime()+(30*24*60*60*1000));
	myExpires = "expires="+myExp.toGMTString()+"; ";

	strCookie += myExpires;
	strCookie += "path=" + strPath;
	document.cookie = strCookie;

}

//腐らす関数
function delCookie(name){
	var strCookie  = name + "=xxx; ";
	strCookie += "expires=Thu, 01 Jan 1970 00:00:01 GMT; ";
	strCookie += "path=" + strPath;
	document.cookie = strCookie;

}

//吐かす関数
function getCookie(key) {
	key += "=";
	var strCookie = document.cookie + ";";

	var start = strCookie.indexOf(key);
	if(start != -1){
		var end = strCookie.indexOf(";", start);
		return unescape(strCookie.substring(start + key.length, end));
	}
	return false;
}
