/* hitlog stt */
var hitAllMetas = document.getElementsByTagName("META");
var hitMetaCont;
var hitLocUrl = location.href;

for (var i=0;i<hitAllMetas.length;i++){
	if (hitAllMetas[i].name && hitAllMetas[i].name == "HITLOG"){
		hitMetaCont = hitAllMetas[i].content;
		break;
	}
}

if (hitMetaCont != null && hitMetaCont != "") { 
	var hitArticle = hitMetaCont.split(';');
	var hitTime = new Date().getTime();
	var hitUrl = ""; var hitUrl2 = ""; var hitUrl3 = "";
	
	if (hitArticle.length == 3) {
		var hitDepth = "dep00=" + hitGetParameter("Dep0") + "&dep01=" + hitGetParameter("Dep1")  + "&dep02=" + hitGetParameter("Dep2")  + "&dep03=" + hitGetParameter("Dep3");

		/////////////////////
		// hitview.chosun.com
		// ±â»ç
		if (hitLocUrl.indexOf("site/data/html_dir") != -1 || hitLocUrl.indexOf("ViewArticle") != -1 || hitLocUrl.indexOf("/html/news/") != -1 || hitLocUrl.indexOf("ArticleView") != -1 || hitLocUrl.indexOf("http://photo.chosun.com/svc/slideshow/") != -1 || hitLocUrl.indexOf("content_view.html") != -1 || hitLocUrl.indexOf("www.chosunonline.com/article") != -1) {
			if (hitArticle[0] == "1" || hitArticle[0] == 1) {
				hitUrl = "http://hitlog.chosun.com/nullimage.php?id=" + hitArticle[2] + "&code=" + hitArticle[1] + "&time=" + hitTime;
			}	
			else if (hitGetSiteCode(hitArticle[0]) != null && hitArticle[0] != "A1"  && hitArticle[0] != "A2") {
				hitUrl = "http://hitlog2.chosun.com/hitlog?id=" + hitArticle[2] + "&code=" + hitGetSiteCode(hitArticle[0]) + "&scode=" + hitArticle[1] + "&time=" + hitTime;
			}
			else {
				hitUrl = "http://hitlog2.chosun.com/hitlog?id=" + hitArticle[2] + "&code=" + hitArticle[0] + "&scode=" + hitArticle[1] + "&time=" + hitTime;
			}
		}
		// Á¶¼±´åÄÄ ¸ÞÀÎ
		else if (hitLocUrl == "http://www.chosun.com" || hitLocUrl == "http://news.chosun.com" || hitLocUrl == "http://www.chosun.com/" || hitLocUrl == "http://news.chosun.com/" || hitLocUrl == "http://www.chosun.com/index.html" || hitLocUrl == "http://news.chosun.com/index.html") {
			hitUrl = "http://hitlog.chosun.com/main_nullimage.php";
		}
		else {
			hitUrl = "http://hitlog2.chosun.com/hitlog?id=" + hitArticle[2] + "&code=" + hitGetSiteCode(hitArticle[0]) + "&scode=" + hitArticle[1] + "&time=" + hitTime;
			//hitUrl = "http://hitlog2.chosun.com/hitlog?id=" + hitArticle[0] + "^" + hitArticle[2] + "&code=ETC&scode=" + hitArticle[1] + "&time=" + hitTime;
		}
		
		///////////////////////////
		// hitweb.chosun.com

		// Á¶¼±´åÄÄ »çÀÌÆ®
		hitUrl2 = "http://hitweb2.chosun.com/php/In_Newht.php?sitecode=" + hitArticle[0] + "&catcode=" + hitArticle[1] + "&artcode=" + hitArticle[2] + "&ref=" + escape(hitGetURL(document.referrer)) + "&cur=" + escape(hitGetURL(location.href)) + "&time=" + hitTime + "&" + hitDepth + "&curr=" + escape(location.href) + "&reff=" + escape(document.referrer);
		hitUrl3 = "http://218.145.28.194/hitlog/In_Newht.jsp?sitecode=" + hitArticle[0] + "&catcode=" + hitArticle[1] + "&artcode=" + hitArticle[2] + "&ref=" + escape(hitGetURL(document.referrer)) + "&cur=" + escape(hitGetURL(location.href)) + "&time=" + hitTime + "&" + hitDepth;

		// Á¶¼±´åÄÄ ÀÌ¿ÜÀÇ »çÀÌÆ®
		if (hitArticle[0] == "A1" || hitArticle[0] == "A2" || hitArticle[0] == "A3")
			  hitUrl2 = "http://hitweb.chosun.com/php/InMainData_SP_2.php?sitecode=" + hitArticle[0] + "&catcode=" + hitArticle[1] + "&artcode=" + hitArticle[2] + "&ref=" + escape(hitGetURL(document.referrer)) + "&cur=" + escape(hitGetURL(location.href)) + "&time=" + hitTime + "&" + hitDepth;
		else if (hitArticle[0] == "5" || hitArticle[0] == "10")
			  hitUrl2 = "http://hitweb.chosun.com/php/InMainData_SP.php?sitecode=" + hitArticle[0] + "&catcode=" + hitArticle[1] + "&artcode=" + hitArticle[2] + "&ref=" + escape(hitGetURL(document.referrer)) + "&cur=" + escape(hitGetURL(location.href)) + "&time=" + hitTime + "&" + hitDepth;

		//var hitImgObj = new Image();
		//hitImgObj.src = hitUrl;
		//var hitImgObj2 = new Image();	
		//hitImgObj2.src = hitUrl2;		
		document.write("<img id='HITVIEW' src='"+hitUrl+"' border=0 style='display:none'>");
		document.write("<img id='HITWEB' src='"+hitUrl2+"' border=0 style='display:none'>");
		//document.write("<img id='HITWEB2' src='"+hitUrl3+"' border=0 style='display:none'>");
	}
}

function hitGetURL (hitStr) {
	var hitDomain = "http://";
	var hitDelimiter = "/";
	var hitRtnUrl = hitStr;

	if (hitRtnUrl.indexOf(hitDomain) != -1) {
		hitRtnUrl = hitStr.substring(hitStr.indexOf(hitDomain)+hitDomain.length, hitStr.length);
	}
	if (hitRtnUrl.indexOf(hitDelimiter) != -1) {
		hitRtnUrl = hitRtnUrl.substring(0, hitRtnUrl.indexOf(hitDelimiter));
	}

	return hitRtnUrl;
}

function hitGetSiteCode(hitSiteid)
{
	var hitSiteCode = null;
	switch (hitSiteid) {
		case "2":
			hitSiteCode = "kid"; break;
		case "3":
			hitSiteCode = "books"; break;
		case "4":
			hitSiteCode = "review"; break;
		case "5":
			hitSiteCode = "photo"; break;
		case "6":
			hitSiteCode = "bike"; break;
		case "7":
			hitSiteCode = "issue"; break;
		case "8":
			hitSiteCode = "health"; break;
		case "10":
			hitSiteCode = "se"; break;
		case "13":
			hitSiteCode = "weekly"; break;
		case "16":
			hitSiteCode = "businesstv"; break;
		case "17":
			hitSiteCode = "san"; break;
		case "19":
			hitSiteCode = "bomup"; break;
		case "A1":
			hitSiteCode = "jpn"; break;
		case "A2":
			hitSiteCode = "chn"; break;
		case "A3":
			hitSiteCode = "english"; break;
		case "A19":
			hitSiteCode = "game"; break;
		case "A20":
			hitSiteCode = "danmee"; break;
		case "A30":
			hitSiteCode = "fishing"; break;
		case "A34":
			hitSiteCode = "car"; break;
		case "A4":
			hitSiteCode = "blog"; break;
		case "33":
			hitSiteCode = "issue"; break;
		case "34":
			hitSiteCode = "danmee"; break;
		case "41":
			hitSiteCode = "culture"; break;
		case "40":
			hitSiteCode = "careview"; break;
		default:
			hitSiteCode = null; break;
	}
	return hitSiteCode;
}

function hitGetParameter (name) {
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	var value = "";
	
	for ( var i = 0; i < pairs.length; i++ ) {
		var pos = pairs[i].indexOf('=');
		if ( pos != -1 ) {
			var argname = pairs[i].substring( 0, pos );
			value = pairs[i].substring(pos+1);

			if (argname == name) break;
		}
	}
	
	return value;
}
/* hitlog end */