var UIDCK, historyAction = "";
function strictDateTime(){
	date=new Date();
	year = date.getFullYear();
	month = date.getMonth();
	day = date.getDate();
	return new Date( Date.UTC(year,month,day,23-9,59,59,000) );
};
function SetCookie(cookieName,cookieVal){
   document.cookie=cookieName+'='+escape(cookieVal)+'; ';
};
function GetCookie(cookieName){
	var allCookies=document.cookie.split('; ');
	var str="";
	for (i=0;i<allCookies.length;i++){
		cookieArray=allCookies[i].split('=');
		if (cookieName==cookieArray[0]) return unescape(cookieArray[1]);
	};
};
function getRndAlpha(){
	var serial = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	var rtn = "";
	for(i=0; i < 20; i++){
		var randnum =  Math.round(Math.random()*63);
		rtn += serial.substr( randnum, 1);
	};
	return rtn;
};
function activeSendString(){
	var parseStr = "";
	parseStr += "tempid="+ UIDCK ;
	parseStr += "&nhost=" +  encodeURIComponent(document.domain) + "&nurls=" + encodeURIComponent(location.pathname);
	parseStr += "&nparam=" +  encodeURIComponent(location.search.substr(1)) + "&hiscnt="+ encodeURIComponent(history.length);
	parseStr += "&preurls=" + encodeURIComponent(document.referrer) + "&useragent=" + encodeURIComponent(navigator.userAgent);
	parseStr += "&historyaction=" + encodeURIComponent(historyAction) + "&nfullurl="+ encodeURIComponent(location.href);
	return parseStr;
};
function checkQuery(){
	var svc = "http://cs.cucis.co.kr/obitsparser/obitsparser.php?"+activeSendString();
	document.writeln("<script src=\""+ svc  +"\"></script>");
}
UIDCK = GetCookie("UIDCK");
if(typeof(UIDCK) == "undefined"){
	UIDCK = getRndAlpha();
	SetCookie("UIDCK", UIDCK);
};
var HISCNT = GetCookie("HISCNT");
if(typeof(HISCNT) == "undefined"){
	historyAction = "G";
};
if(parseInt(HISCNT) > parseInt(history.length)){
	historyAction = "B";
};
if(parseInt(HISCNT) == parseInt(history.length)){
	historyAction = "R";
};
if(parseInt(HISCNT) < parseInt(history.length)){
	historyAction = "G";
};
SetCookie("HISCNT", history.length);
checkQuery();
