xmlhttp = getXmlHttpObject();
//alert(document.referrer);
if (xmlhttp) {
	xmlhttp.onreadystatechange = setPageData;
	var str = window.document.URL;
	if(str.match("https://ssl.coopervision.jp")){
		xmlhttp.open('GET', "https://ssl.coopervision.jp/ng_access.php?ref=" + document.referrer + "&path=" + str, true);
	}  else {
		xmlhttp.open('GET', "http://www.coopervision.jp/ng_access.php?ref=" + document.referrer + "&path=" + str, true);
	}
	xmlhttp.send("");
}
//else{
//	alert("XMLHttpRequest¸s");
//}

function setPageData() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		var str = xmlhttp.responseText;
		if(str == "ng") {
			window.location.href = "http://www.coopervision.jp/caution.html";
		}
	}
}


function getXmlHttpObject() {
    var xmlhttp;
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	return xmlhttp;

}
