function getCookie(pName) {
	pName += "=";
	myCookie = document.cookie + ";";
	stPos = myCookie.indexOf(pName);
	tgtCk = "";
	if ( stPos != (-1) ) {
		enPos = myCookie.indexOf(";",stPos);
		tgtCk = myCookie.substring( (stPos + pName.length),enPos );
	}
	return tgtCk;
}
function setCookie(pName) {
	ranval = Math.random();
	tgtCK = pName + "=" + ranval + ";path=/";
	document.cookie = tgtCK;
}
function setCookieVal(pName,pVal) {
	tgtCK = pName + "=" + pVal + ";path=/";
	document.cookie = tgtCK;
}
function checkCookie(pName) {
	//alert(getCookie(pName));
	retVal = 0;
	ckVal = getCookie(pName)
	if ( ckVal == "" ) {
		retVal = 1;
	} else {
		retVal = parseInt(ckVal) + 1;
	}
	setCookieVal(pName,retVal);
	return(retVal);
}
function getReferrer() {
	if (document.referrer == parent.frames.location) { 
		if (parent.document.referrer == parent.parent.frames.location) { 
			return(parent.parent.document.referrer); 
		} else {
			return(parent.document.referrer); 
		}
	} else { 
		return(document.referrer); 
	} 
}
function getHostName() {
	ret = location.hostname;
	return(ret); 
}
function setlpg(pSrno,pPrno) {
	ranval = Math.random();
	ckName = pSrno + pPrno;
	algPath = "http://accessvision.a2media.co.jp/access/access.asp"
	tgtUrl = algPath+"?srno="+pSrno+"&prno="+pPrno+"&hide="+ranval+"&uniq="+checkCookie(ckName)+"&hnm="+escape(getHostName())+"&reff="+escape(getReferrer());
	tgtStr="<img src='"+tgtUrl+"' width='0%' height='0%' border='0' alt=' '>";
	document.write(tgtStr);
}

function do_get(url){
	var xmlhttp = false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e1) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			xmlhttp = false;
		}
	}
	if(!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	if(!xmlhttp){
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.send('');
}
function setlpg_frame(dir,pSrno,pPrno) {
	ranval = Math.random();
	ckName = pSrno + pPrno;
	algPath = dir + "alog.php"
	tgtUrl = algPath+"?srno="+pSrno+"&prno="+pPrno+"&hide="+ranval+"&uniq="+checkCookie(ckName)+"&hnm="+escape(getHostName())+"&reff="+escape(getReferrer());
	do_get(tgtUrl);
}
