/**/
//var allMetas = document.all.tags('META');
var allMetas = document.getElementsByTagName("META");
var metaCont;
var locurl = location.href;

for (var i=0;i<allMetas.length;i++){
	if (allMetas[i].name && allMetas[i].name == "HITLOG"){
		metaCont = allMetas[i].content;
		break;
	}
}

if (metaCont != null && metaCont != "") { 
	var hitlogArticle = metaCont.split(';');
	if (hitlogArticle.length == 3) {

		///////////////////////////
		// hitweb.chosun.com

		// Á¶¼±´åÄÄ »çÀÌÆ®
		//var url = "http://hitweb.chosun.com/php/In_Newht.php?sitecode=" + hitlogArticle[0] + "&catcode=" + hitlogArticle[1] + "&artcode=" + hitlogArticle[2] + "&ref=" + escape(getURL(document.referrer)) + "&cur=" + escape(getURL(location.href));
		  var url = "http://218.145.28.148/php/In_Newht.php?sitecode=" + hitlogArticle[0] + "&catcode=" + hitlogArticle[1] + "&artcode=" + hitlogArticle[2] + "&ref=" + escape(getURL(document.referrer)) + "&cur=" + escape(getURL(location.href));

		// Á¶¼±´åÄÄ ÀÌ¿ÜÀÇ »çÀÌÆ®
		if (hitlogArticle[0] == "A1" || hitlogArticle[0] == "A2" || hitlogArticle[0] == "A3") {
			//url = "http://218.145.28.148/php/InMainData_SP_2.php?sitecode=" + hitlogArticle[0] + "&catcode=" + hitlogArticle[1] + "&artcode=" + hitlogArticle[2] + "&ref=" + escape(getURL(document.referrer)) + "&cur=" + escape(getURL(location.href));
			  url = "http://hitweb.chosun.com/php/InMainData_SP_2.php?sitecode=" + hitlogArticle[0] + "&catcode=" + hitlogArticle[1] + "&artcode=" + hitlogArticle[2] + "&ref=" + escape(getURL(document.referrer)) + "&cur=" + escape(getURL(location.href));
		}
		else if (hitlogArticle[0] == "5" || hitlogArticle[0] == "10")
			//url = "http://218.145.28.148/php/InMainData_SP.php?sitecode=" + hitlogArticle[0] + "&catcode=" + hitlogArticle[1] + "&artcode=" + hitlogArticle[2] + "&ref=" + escape(getURL(document.referrer)) + "&cur=" + escape(getURL(location.href));
			  url = "http://hitweb.chosun.com/php/InMainData_SP.php?sitecode=" + hitlogArticle[0] + "&catcode=" + hitlogArticle[1] + "&artcode=" + hitlogArticle[2] + "&ref=" + escape(getURL(document.referrer)) + "&cur=" + escape(getURL(location.href));

		(new Image).src = url;

		/////////////////////
		// hitview.chosun.com
		if (locurl.indexOf("site/data/html_dir") != -1 || locurl.indexOf("ViewArticle") != -1 || locurl.indexOf("/html/news/") != -1 || locurl.indexOf("ArticleView") != -1) {
			if (hitlogArticle[0] == "1" || hitlogArticle[0] == 1) {
				(new Image).src = "http://218.145.28.118/nullimage.php?id=" + hitlogArticle[2] + "&code=" + hitlogArticle[1];
			}	
			else if (getSiteCode(hitlogArticle[0]) != null && hitlogArticle[0] != "A2") {
				(new Image).src = "http://hitlog2.chosun.com/hitlog?id=" + hitlogArticle[2] + "&code=" + getSiteCode(hitlogArticle[0]) + "&scode=" + hitlogArticle[1];
			}
			else {
				(new Image).src = "http://hitlog2.chosun.com/hitlog?id=" + hitlogArticle[2] + "&code=" + hitlogArticle[0] + "&scode=" + hitlogArticle[1];
			}
		} 
		else if (locurl == "http://www.chosun.com" || locurl == "http://news.chosun.com" || locurl == "http://www.chosun.com/" || locurl == "http://news.chosun.com/" || locurl == "http://www.chosun.com/index.html" || locurl == "http://news.chosun.com/index.html") {
			(new Image).src = "http://218.145.28.118/main_nullimage.php";
		}

		//(new Image).src = "http://hitweb.chosun.com/php/In_Newht.php?sitecode=" + hitlogArticle[0] + "&catcode=" + hitlogArticle[1] + "&artcode=" + hitlogArticle[2] + "&ref=" + escape(getURL(document.referrer)) + "&cur=" + escape(getURL(location.href));
	}
}

function getURL (str) {
	var domain = "http://";
	var delimiter = "/";
	var url = str;

	if (url.indexOf(domain) != -1) {
		url = str.substring(str.indexOf(domain)+domain.length, str.length);
	}
	if (url.indexOf(delimiter) != -1) {
		url = url.substring(0, url.indexOf(delimiter));
	}

	return url;
}

function getCookieValDz (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookiesDz (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {	//while open
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieValDz (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break; 
	}	//while close
	return null;
}

function getSiteCode(siteid)
{
	if (siteid == "2")		return "kid";
	else if (siteid == "3")		return "books";
	else if (siteid == "4")		return "review";
	else if (siteid == "5")		return "photo";
	else if (siteid == "6")		return "bike";
	else if (siteid == "7")		return "issue";
	else if (siteid == "8")		return "health";
	else if (siteid == "10")	return "se";
	else if (siteid == "11")	return "newsplus";
	else if (siteid == "13")	return "weekly";
	else if (siteid == "16")	return "businesstv";
	else if (siteid == "17")	return "san";
	else if (siteid == "19")	return "boomup";
	else if (siteid == "A1")	return "chn";
	else if (siteid == "A2")	return "chn";
	else if (siteid == "A3")	return "english";
	else if (siteid == "A19")	return "game";
	else if (siteid == "A20")	return "danmee";
	else if (siteid == "A30")	return "fishing";
	else if (siteid == "A34")	return "car";
	else return null;
}
/**/
