
var oct_url = "/oct/oct.php";

function octReq(site,att1,att2,att3)
{
	if(site)
	{
		var httpObj;	// HTTP通信用オブジェクト

		try
		{
			if(window.XMLHttpRequest) {
				httpObj = new XMLHttpRequest();
			} else if(window.ActiveXObject) {
				httpObj = new ActiveXObject("Microsoft.XMLHTTP");
			} else {
				httpObj = false;
			}
		}
		catch(e)
		{
			httpObj = false;
		}
		if(! httpObj)
		{
			httpObjGenerateFail();
		}

		httpObj.open('GET', oct_url+'?site='+site+'&att1='+att1+'&att2='+att2+'&att3='+att3+'&ref='+escape(getCookie("oct_ref")));

		//httpObj.setRequestHeader("content-type","application/x-www-form-urlencoded;charset=Shift-JIS");
		httpObj.setRequestHeader("content-type","application/x-www-form-urlencoded;");

		httpObj.send(null);
	}
}

function octInit()
{
	var ref = encodeURI(document.referrer);	//文字化け対策
	//alert(ref);
	if(ref.search(/^http\:\/\/2han\./)){ document.cookie = "oct_ref="+ref; }
}

function getCookie(kword)
{
	if(typeof(kword) == "undefined") // キーワードなし
		return "";        // 何もしないで戻る

	kword = kword + "=";
	kdata = "";
	scookie = document.cookie + ";"; // クッキー情報を読み込む
	start = scookie.indexOf(kword);  // キーワードを検索
	if (start != -1){    // キーワードと一致するものあり
		end = scookie.indexOf(";", start);    // 情報の末尾位置を検索
		kdata = unescape(scookie.substring(start + kword.length, end));  // データ取り出し
	}
	return kdata;
}

