////////////////////////////////////////////////////////////////////////////////////////
//																											//
//		Author : Yuki																					//
//		Position : Intergrated Search Platform team, Daum Communications	//
//		Date : 20 Aug, 2007																		//
//																											//
////////////////////////////////////////////////////////////////////////////////////////

// to get a new Object
function getRtObj(tgt, nn, wn, sn, qr) {
	// 서비스 이름
	this.rtsn = "tot";
	if (sn != "" && sn != null) this.rtsn = sn;

	// 롤링되는 키워드 개수
	if (nn == "" || nn == null) this.rtnum = 10;
	else this.rtnum = nn;

	// 보여지는 키워드 길이
	if (wn == "" || wn == null) this.rtwn = 8;
	else this.rtwn = wn;

	switch(this.rtsn){
		case "alldic" : this.rtfn = "ALLDIC";
		if (this.rtnum == "" || this.rtnum == null || this.rtnum > 10 || this.rtnum < 2) this.rtnum = 10;
		break;
		case "dic100" : this.rtfn = "ALLDIC";
		if (this.rtnum == "" || this.rtnum == null || this.rtnum > 10 || this.rtnum < 2) this.rtnum = 10;
		break;
		case "diccu" : this.rtfn = "ALLDIC";
		if (this.rtnum == "" || this.rtnum == null || this.rtnum > 10 || this.rtnum < 2) this.rtnum = 10;
		break;
		case "dicen" : this.rtfn = "ALLDIC";
		if (this.rtnum == "" || this.rtnum == null || this.rtnum > 10 || this.rtnum < 2) this.rtnum = 10;
		break;
		case "dicee" : this.rtfn = "ALLDIC";
		if (this.rtnum == "" || this.rtnum == null || this.rtnum > 10 || this.rtnum < 2) this.rtnum = 10;
		break;
		case "dickr": this.rtfn = "ALLDIC";
		if (this.rtnum == "" || this.rtnum == null || this.rtnum > 10 || this.rtnum < 2) this.rtnum = 10;
		break;
		case "dicha" : this.rtfn = "ALLDIC";
		if (this.rtnum == "" || this.rtnum == null || this.rtnum > 10 || this.rtnum < 2) this.rtnum = 10;
		break;
		case "dicjp" : this.rtfn = "ALLDIC";
		if (this.rtnum == "" || this.rtnum == null || this.rtnum > 10 || this.rtnum < 2) this.rtnum = 10;
		break;
		case "diccn" : this.rtfn = "ALLDIC";
		if (this.rtnum == "" || this.rtnum == null || this.rtnum > 10 || this.rtnum < 2) this.rtnum = 10;
		tab = "board";
		break;
		default : this.rtsn = "alldic"; this.rtfn = "ALLDIC";
		break;
	}

	this.localTgt = "target=_self";
	// 모듈 감싸는 레이어명
	if (tgt == "" || tgt == null) {
		return false;
	}
	else this.rtgtLayer = tgt;
	
	if (qr != "" && qr != null) this.rtquery = qr;
	
	this.rtloadTime = 0;
	this.rtchkTime = 0;
	this.rtscriptTimeGap = 0;

	this.getScriptInfo();

	this.aLayerNum = 0;
	// 스크립트 랜덤 ID
	this.scRandNum = Math.random().toString();
	this.scRandId = "rtinfodata_" + this.scRandNum;
}

getRtObj.prototype.getScriptInfo = function() {
	this.cgurl = "http://img.search.daum-img.net/jumpkeyword/" + this.rtfn + "/UTF8_top10_" + this.rtsn + ".js";
}

// to start Rolling
getRtObj.prototype.rtRollingLoader = function() {
	this.rtrenewData("rtdrawLayer()");
}

// to renew the realtime data
getRtObj.prototype.rtrenewData = function(func) {
	this.renew_script("text/javascript", true, this.cgurl, func);
}

// to make or update the data script
getRtObj.prototype.renew_script = function(type, defer, src, func) {
	var loader = this;

	this.rtchkTime = new Date();
	if (this.rtloadTime == 0) this.rtscriptTimeGap = 1000 * 60 * 3;
	else this.rtscriptTimeGap = this.rtchkTime.getTime() - this.rtloadTime.getTime();

	// 로딩 후 2분이 지났을 경우 reload data
	if (this.rtscriptTimeGap > 1000 * 60 * 2) {
		// append 된 스크립트 있으면 생성 전에 삭제
		if (document.getElementById(this.scRandId)) {
			//Memory Leaking 방지
			document.getElementsByTagName("head")[0].removeChild(document.getElementById(this.scRandId));
		}

		var rtscript = document.createElement("script");
		rtscript.id = this.scRandId;
		rtscript.type = type;
		rtscript.defer = defer;
		rtscript.src = src;
		rtscript.charset = "utf-8";
		if (this.rtgetBrowser() == "IE") {
			rtscript.onreadystatechange = function () {
				if (rtscript.readyState == "complete" || rtscript.readyState == "loaded") {
					// 실시간 검색어 정보 배열 저장
					loader.arr_info = eval("obj_" + loader.rtsn);
					eval("loader." + func);
				}
			}
		} else {
			rtscript.onload = function () {
				loader.arr_info = eval("obj_" + loader.rtsn);
				eval("loader." + func);
			}
		}
		document.getElementsByTagName("head")[0].appendChild(rtscript);
		this.rtloadTime = new Date();
	}
	// 로딩 후 2분이 지나지 않았을 경우
	else eval("loader." + func);
}

// to get a browser type
getRtObj.prototype.rtgetBrowser = function() {
	if (navigator.appName == "Microsoft Internet Explorer") return "IE";
	else return "nonIE";
}

// to draw the entire layer
getRtObj.prototype.rtdrawLayer = function() {
	var loader = this;
	var divClr;
	// 말풍선 레이어 배열 생성
	var divBalloon = [];
	// 디스플레이 되는 검색어와 검색수
	var schWord, schNum, schWordS, schNumS;
	// 검색어의 길이가 길 경우 줄여서 보여주는 검색어
	var schWordShort, schWordShortS;
	this.divCreB = new Array();
	this.divCre = new Array();
	this.divCreL = new Array();
	this.divCreR = new Array();
	this.divCreS = new Array();
	this.divCreSL = new Array();
	this.divCreSR = new Array();

	this.divRtBody = document.createElement("div");
	this.divRtBody.id = "rtbody_" + this.scRandNum;
	this.divRtBody.style.font = "12px 굴림,Gulim";
	this.divRtBody.style.color = "#000";
	this.divRtBody.style.padding = 0;
	this.divRtBody.style.margin = 0;
	this.divRtBody.style.zIndex = 1;
	document.getElementById(this.rtgtLayer).appendChild(this.divRtBody);

	// 검색어 리스팅을 감싸는 레이어
	this.divRtMid = document.createElement("div");
	this.divRtMid.id = "rtdivMid_" + this.scRandNum;
	this.divRtMid.style.margin = 0;
	this.divRtMid.style.padding = 0;
	this.divRtMid.style.zIndex = 1;
	this.divRtMid.style.overflow = "hidden";
	document.getElementById(this.divRtBody.id).appendChild(this.divRtMid);

	// Layer wrapping an entire box
	this.divRtWrap = document.createElement("div");
	this.divRtWrap.id = "rtdivWrap_" + this.scRandNum;
	this.divRtWrap.style.position = "relative";
	this.divRtWrap.style.margin = 0;
	this.divRtWrap.style.padding = 0;
	this.divRtWrap.style.zIndex = 1;
	this.divRtWrap.style.overflow = "hidden";
	document.getElementById(this.divRtMid.id).appendChild(this.divRtWrap);

	// 디스플레이 개수 전역변수 만큼 레이어 디스플레이
	for (var i=0; i<this.rtnum; i++) {
		schWord = this.arr_info[i].K;
		schNum = this.arr_info[i].V;

		// 검색어가 길 경우 shorten
		if (schWord.length > this.rtwn) schWordShort = schWord.substr(0, this.rtwn) + " ...";
		else schWordShort = schWord;

		// 현재 검색 쿼리와 같은 검색어일 경우 bold 처리
		if (schWord == this.rtquery) {
			schWordShort = "<b>" + schWordShort + "</b>";
		}

		// 각 라인 감싸는 레이어
		this.divCreB[i] = document.createElement("div");
		this.divCreB[i].id = "rtdivSchB" + (i + 1) + "_" + this.scRandNum;
		this.divCreB[i].style.position = "relative";
		this.divCreB[i].style.top = 0;
		this.divCreB[i].style.left = 0;
		this.divCreB[i].style.height = "13px";
		this.divCreB[i].style.margin = 0;
		this.divCreB[i].style.marginBottom = "9px";
		this.divCreB[i].style.padding = 0;
		this.divCreB[i].style.overflow = "hidden";
		this.divCreB[i].style.clear = "both";
		document.getElementById(this.divRtWrap.id).appendChild(this.divCreB[i]);

		// 스크롤 되기 전에 보여주는 레이어를 감싸는 레이어
		this.divCre[i] = document.createElement("div");
		this.divCre[i].id = "rtdivSch" + (i + 1) + "_" + this.scRandNum;
		this.divCre[i].style.position = "relative";
		this.divCre[i].style.top = 0;
		this.divCre[i].style.left = 0;
		this.divCre[i].style.height = "13px";
		this.divCre[i].style.margin = 0;
		this.divCre[i].style.padding = 0;
		this.divCre[i].style.overflow = "hidden";
		document.getElementById(this.divCreB[i].id).appendChild(this.divCre[i]);

		// 스크롤 되기 전에 보여주는 검색어 이름 레이어
		this.divCreL[i] = document.createElement("div");
		this.divCreL[i].id = "rtdivSchL" + (i + 1) + "_" + this.scRandNum;
		if (i < 9) this.divCreL[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/dic/2008/blue_00" + (i + 1) + ".gif)";
		if (i >= 9) this.divCreL[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/dic/2008/blue_0" + (i + 1) + ".gif)";
		this.divCreL[i].style.backgroundRepeat = "no-repeat";
		this.divCreL[i].style.height = "13px";
		this.divCreL[i].style.margin = 0;
		this.divCreL[i].style.padding = 0;
		this.divCreL[i].style.paddingLeft = "17px";
		if (this.rtgetBrowser() == "IE") this.divCreL[i].style.styleFloat = "left";
		else this.divCreL[i].style.cssFloat = "left";
		if (this.rtgetBrowser() == "IE") this.divCreL[i].style.lineHeight = "13px";
		else this.divCreL[i].style.lineHeight = "13px";
		this.divCreL[i].style.verticalAlign = "middle";
		this.divCreL[i].innerHTML = "<a class=\"rtlink\" href=\"" + this.getLink(this.arr_info[i].P, schWord) + "\" onmouseover=\"javascript:showBalloon(" + i + ", '" + schWord + "', " + this.rtwn + ", " + this.rtnum + ", " + this.scRandNum + ");\" onmouseout=\"javascript:hideBalloon(" + this.scRandNum + ");\"" + this.localTgt + ">" + schWordShort + "</a>";
		document.getElementById(this.divCre[i].id).appendChild(this.divCreL[i]);

		// 스크롤 되기 전에 보여주는 검색수 레이어
		this.divCreR[i] = document.createElement("div");
		this.divCreR[i].id = "rtdivSchR" + (i + 1) + "_" + this.scRandNum;
		this.divCreR[i].style.font = "11px 돋움,Dotum";
		this.divCreR[i].style.color = "#666";
		this.divCreR[i].style.margin = 0;
		this.divCreR[i].style.padding = 0;
		this.divCreR[i].style.width = "28px";
		this.divCreR[i].style.verticalAlign = "middle";
		if (this.rtgetBrowser() == "IE") this.divCreR[i].style.styleFloat = "right";
		else this.divCreR[i].style.cssFloat = "right";
		if (this.arr_info[i].S == "new") {
			this.divCreR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/new.gif)";
			this.divCreR[i].style.backgroundRepeat = "no-repeat";
			this.divCreR[i].style.backgroundPosition = "left 2px";
			this.divCreR[i].style.paddingLeft = "8px";
			if (this.rtgetBrowser() != "IE") this.divCreR[i].innerHTML = "&nbsp;";
		}
		else {
			if (this.arr_info[i].S == "++") {
				this.divCreR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/uprush.gif)";
				this.divCreR[i].style.backgroundRepeat = "no-repeat";
				this.divCreR[i].style.backgroundPosition = "left center";
				this.divCreR[i].style.paddingLeft = "13px";
			}
			else if (this.arr_info[i].S == "+") {
				this.divCreR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/up.gif)";
				this.divCreR[i].style.backgroundRepeat = "no-repeat";
				this.divCreR[i].style.backgroundPosition = "left center";
				this.divCreR[i].style.paddingLeft = "13px";
			}
			else if (this.arr_info[i].S == "--") {
				this.divCreR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/downrush.gif)";
				this.divCreR[i].style.backgroundRepeat = "no-repeat";
				this.divCreR[i].style.backgroundPosition = "left center";
				this.divCreR[i].style.paddingLeft = "13px";
			}
			else if (this.arr_info[i].S == "-") {
				this.divCreR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/down.gif)";
				this.divCreR[i].style.backgroundRepeat = "no-repeat";
				this.divCreR[i].style.backgroundPosition = "left center";
				this.divCreR[i].style.paddingLeft = "13px";
			}
			else if (this.arr_info[i].S == "0") {
				this.divCreR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/rank_0.gif)";
				this.divCreR[i].style.backgroundRepeat = "no-repeat";
				this.divCreR[i].style.backgroundPosition = "left center";
				this.divCreR[i].style.paddingLeft = "13px";
			}
			this.divCreR[i].innerHTML = this.arr_info[i].V;
		}
		document.getElementById(this.divCre[i].id).appendChild(this.divCreR[i]);

		divClr = document.createElement("div");
		divClr.style.clear = "both";
		document.getElementById(this.divCre[i].id).appendChild(divClr);

		// 다운 스크롤 되는 배경 레이어를 감싸는 레이어
		this.divCreS[i] = document.createElement("div");
		this.divCreS[i].id = "rtdivSchS" + (i + 1) + "_" + this.scRandNum;
		this.divCreS[i].style.position = "relative";
		this.divCreS[i].style.top = 0;
		this.divCreS[i].style.left = 0;
		this.divCreS[i].style.height = "13px";
		this.divCreS[i].style.margin = 0;
		this.divCreS[i].style.padding = 0;
		this.divCreS[i].style.overflow = "hidden";
		this.divCreS[i].style.opacity = 0.6;
		this.divCreS[i].style.MozOpacity = 0.6;
		this.divCreS[i].style.KhtmlOpacity = 0.6;
		this.divCreS[i].style.filter = "alpha(opacity=60)";
		document.getElementById(this.divCreB[i].id).appendChild(this.divCreS[i]);

		// 다운 스크롤 되는 검색어 이름 레이어
		this.divCreSL[i] = document.createElement("div");
		this.divCreSL[i].id = "rtdivSchSL" + (i + 1) + "_" + this.scRandNum;
		if (i < 9) this.divCreSL[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/dic/2008/blue_00" + (i + 1) + ".gif)";
		if (i >= 9) this.divCreSL[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/dic/2008/blue_0" + (i + 1) + ".gif)";
		this.divCreSL[i].style.backgroundRepeat = "no-repeat";
		this.divCreSL[i].style.height = "13px";
		this.divCreSL[i].style.margin = 0;
		this.divCreSL[i].style.padding = 0;
		this.divCreSL[i].style.paddingLeft = "17px";
		if (this.rtgetBrowser() == "IE") this.divCreSL[i].style.styleFloat = "left";
		else this.divCreSL[i].style.cssFloat = "left";
		if (this.rtgetBrowser() == "IE") this.divCreSL[i].style.lineHeight = "13px";
		else this.divCreSL[i].style.lineHeight = "13px";
		this.divCreSL[i].style.verticalAlign = "middle";
		this.divCreSL[i].innerHTML = "<a class=\"rtlink\" href=\"" + this.getLink(this.arr_info[i].P, schWord) + "\" onMouseover=\"javascript:showBalloon(" + i + ", '" + schWord + "', " + this.rtwn + ", " + this.rtnum + ", " + this.scRandNum + ");\" onMouseout=\"javascript:hideBalloon(" + this.scRandNum + ");\"" + this.localTgt + ">" + schWordShort + "</a>";
		document.getElementById(this.divCreS[i].id).appendChild(this.divCreSL[i]);

		// 다운 스크롤 되는 검색수 레이어
		this.divCreSR[i] = document.createElement("div");
		this.divCreSR[i].id = "rtdivSchSR" + (i + 1) + "_" + this.scRandNum;
		this.divCreSR[i].style.font = "11px 돋움,Dotum";
		this.divCreSR[i].style.color = "#666";
		this.divCreSR[i].style.margin = 0;
		this.divCreSR[i].style.padding = 0;
		this.divCreSR[i].style.width = "28px";
		this.divCreSR[i].style.verticalAlign = "middle";
		if (this.rtgetBrowser() == "IE") this.divCreSR[i].style.styleFloat = "right";
		else this.divCreSR[i].style.cssFloat = "right";
		if (this.arr_info[i].S == "new") {
			this.divCreSR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/new.gif)";
			this.divCreSR[i].style.backgroundRepeat = "no-repeat";
			this.divCreSR[i].style.backgroundPosition = "left 2px";
			this.divCreSR[i].style.paddingLeft = "8px";
			if (this.rtgetBrowser() != "IE") this.divCreSR[i].innerHTML = "&nbsp;";
		}
		else {
			if (this.arr_info[i].S == "++") {
				this.divCreSR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/uprush.gif)";
				this.divCreSR[i].style.backgroundRepeat = "no-repeat";
				this.divCreSR[i].style.backgroundPosition = "left center";
				this.divCreSR[i].style.paddingLeft = "13px";
			}
			else if (this.arr_info[i].S == "+") {
				this.divCreSR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/up.gif)";
				this.divCreSR[i].style.backgroundRepeat = "no-repeat";
				this.divCreSR[i].style.backgroundPosition = "left center";
				this.divCreSR[i].style.paddingLeft = "13px";
			}
			else if (this.arr_info[i].S == "--") {
				this.divCreSR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/downrush.gif)";
				this.divCreSR[i].style.backgroundRepeat = "no-repeat";
				this.divCreSR[i].style.backgroundPosition = "left center";
				this.divCreSR[i].style.paddingLeft = "13px";
			}
			else if (this.arr_info[i].S == "-") {
				this.divCreSR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/down.gif)";
				this.divCreSR[i].style.backgroundRepeat = "no-repeat";
				this.divCreSR[i].style.backgroundPosition = "left center";
				this.divCreSR[i].style.paddingLeft = "13px";
			}
			else if (this.arr_info[i].S == "0") {
				this.divCreSR[i].style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/rank_0.gif)";
				this.divCreSR[i].style.backgroundRepeat = "no-repeat";
				this.divCreSR[i].style.backgroundPosition = "left center";
				this.divCreSR[i].style.paddingLeft = "13px";
			}
			this.divCreSR[i].innerHTML = this.arr_info[i].V;
		}
		document.getElementById(this.divCreS[i].id).appendChild(this.divCreSR[i]);

		divClr = document.createElement("div");
		divClr.style.clear = "both";
		document.getElementById(this.divCreS[i].id).appendChild(divClr);
	}
	// End Layer wrapping an entire box
	// 정보 갱신 함수 호출
	this.scrBreaktime = setTimeout(function(){loader.initLayer(loader.aLayerNum)}, 100);

}

// 각 라인의 레이어 스크롤 하기 전에 정보 갱신하는 함수
getRtObj.prototype.initLayer = function(pLayerNum) {
	// 현재 걸려 있는 타임아웃 삭제
	clearTimeout(this.scrBreaktime);

	var schWord = this.arr_info[pLayerNum].K;
	var schNum = this.arr_info[pLayerNum].V;

	// 검색어의 길이가 길 경우 줄여서 보여주는 검색어
	var schWordShort;

	// 검색어가 길 경우 shorten
	if (schWord.length > this.rtwn) schWordShort = schWord.substr(0, this.rtwn) + " ...";
	else schWordShort = schWord;

	// 현재 검색 쿼리와 같은 검색어일 경우 bold 처리
	if (schWord == this.rtquery) {
		schWordShort = "<b>" + schWordShort + "</b>";
	}

	// 기본 레이어와 스크롤 되는 레이어 Object 변수 설정
	var pLayerL, pLayerR, pLayerSL, pLayerSR;

	// 실시간 검색어 정보로 각 레이어 갱신
	pLayerSL = document.getElementById("rtdivSchSL" + (pLayerNum + 1) + "_" + this.scRandNum);
	pLayerSR = document.getElementById("rtdivSchSR" + (pLayerNum + 1) + "_" + this.scRandNum);
	pLayerL = document.getElementById("rtdivSchL" + (pLayerNum + 1) + "_" + this.scRandNum);
	pLayerR = document.getElementById("rtdivSchR" + (pLayerNum + 1) + "_" + this.scRandNum);
	
	pLayerSL.innerHTML = "<a class=\"rtlink\" href=\"" + this.getLink(this.arr_info[pLayerNum].P, schWord) + "\" onMouseover=\"javascript:showBalloon(" + pLayerNum + ", '" + schWord + "', " + this.rtwn + ", " + this.rtnum + ", " + this.scRandNum + ");\" onMouseout=\"javascript:hideBalloon(" + this.scRandNum + ");\"" + this.localTgt + ">" + schWordShort + "</a>";
	pLayerL.innerHTML = "<a class=\"rtlink\" href=\"" + this.getLink(this.arr_info[pLayerNum].P, schWord) + "\" onMouseover=\"javascript:showBalloon(" + pLayerNum + ", '" + schWord + "', " + this.rtwn + ", " + this.rtnum + ", " + this.scRandNum + ");\" onMouseout=\"javascript:hideBalloon(" + this.scRandNum + ");\"" + this.localTgt + ">" + schWordShort + "</a>";

	// 새로운 검색어일 경우 이미지 디스플레이
	if (this.arr_info[pLayerNum].S == "new") {
		pLayerSR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/new.gif)";
		pLayerSR.style.backgroundRepeat = "no-repeat";
		pLayerSR.style.backgroundPosition = "left 2px";
		pLayerSR.style.paddingLeft = "8px";

		pLayerR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/new.gif)";
		pLayerR.style.backgroundRepeat = "no-repeat";
		pLayerR.style.backgroundPosition = "left 2px";
		pLayerR.style.paddingLeft = "8px";

		pLayerSR.innerHTML = "";
		pLayerR.innerHTML = "";
		if (this.rtgetBrowser() != "IE") pLayerSR.innerHTML = "&nbsp;";
		if (this.rtgetBrowser() != "IE") pLayerR.innerHTML = "&nbsp;";
	}
	else {
		if (this.arr_info[pLayerNum].S == "++") {
				pLayerSR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/uprush.gif)";
				pLayerSR.style.backgroundRepeat = "no-repeat";
				pLayerSR.style.backgroundPosition = "left center";
				pLayerSR.style.paddingLeft = "13px";
				pLayerR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/uprush.gif)";
				pLayerR.style.backgroundRepeat = "no-repeat";
				pLayerR.style.backgroundPosition = "left center";
				pLayerR.style.paddingLeft = "13px";
		}
		else if (this.arr_info[pLayerNum].S == "+") {
				pLayerSR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/up.gif)";
				pLayerSR.style.backgroundRepeat = "no-repeat";
				pLayerSR.style.backgroundPosition = "left center";
				pLayerSR.style.paddingLeft = "13px";
				pLayerR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/up.gif)";
				pLayerR.style.backgroundRepeat = "no-repeat";
				pLayerR.style.backgroundPosition = "left center";
				pLayerR.style.paddingLeft = "13px";
		}
		else if (this.arr_info[pLayerNum].S == "--") {
				pLayerSR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/downrush.gif)";
				pLayerSR.style.backgroundRepeat = "no-repeat";
				pLayerSR.style.backgroundPosition = "left center";
				pLayerSR.style.paddingLeft = "13px";
				pLayerR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/downrush.gif)";
				pLayerR.style.backgroundRepeat = "no-repeat";
				pLayerR.style.backgroundPosition = "left center";
				pLayerR.style.paddingLeft = "13px";
		}
		else if (this.arr_info[pLayerNum].S == "-") {
				pLayerSR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/down.gif)";
				pLayerSR.style.backgroundRepeat = "no-repeat";
				pLayerSR.style.backgroundPosition = "left center";
				pLayerSR.style.paddingLeft = "13px";
				pLayerR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/down.gif)";
				pLayerR.style.backgroundRepeat = "no-repeat";
				pLayerR.style.backgroundPosition = "left center";
				pLayerR.style.paddingLeft = "13px";
		}
		else if (this.arr_info[pLayerNum].S == "0") {
				pLayerSR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/rank_0.gif)";
				pLayerSR.style.backgroundRepeat = "no-repeat";
				pLayerSR.style.backgroundPosition = "left center";
				pLayerSR.style.paddingLeft = "13px";
				pLayerR.style.backgroundImage = "url(http://imgsrc.search.daum-img.net/search_all/2007_right/rank_0.gif)";
				pLayerR.style.backgroundRepeat = "no-repeat";
				pLayerR.style.backgroundPosition = "left center";
				pLayerR.style.paddingLeft = "13px";
		}
		pLayerSR.innerHTML = schNum;
		pLayerR.innerHTML = schNum;
	}

	// 0.04 seconds 간격으로 다운 스크롤;
	var loader = this;
	if (navigator.appName == "Microsoft Internet Explorer") this.scrInterval = window.setInterval(function(){loader.scrollLayer(loader.aLayerNum)}, 40);
	else this.scrInterval = window.setInterval(function(){loader.scrollLayer(loader.aLayerNum)}, 100);
}

// 각 라인의 레이어 스크롤 하는 함수
getRtObj.prototype.scrollLayer = function(num) {
	// 기본 레이어와 스크롤 되는 레이어 Object 변수 설정
	var pLayer, pLayerS;

	pLayerS = document.getElementById("rtdivSchS" + (num + 1) + "_" + this.scRandNum);
	pLayer = document.getElementById("rtdivSch" + (num + 1) + "_" + this.scRandNum);
	
	// 각 레이어 Top +1 만큼 다운 스크롤
	if (navigator.appName == "Microsoft Internet Explorer") {
		pLayerS.style.top = (parseInt(pLayerS.style.top.replace("px", "")) - 1) + "px";
		pLayer.style.top = (parseInt(pLayer.style.top.replace("px", "")) - 1) + "px";
	}
	else {
		// to let the keyword get blinked because of the performance issue in Firefox
		clearInterval(this.scrInterval);
		pLayer.style.opacity = 0;
		pLayer.style.MozOpacity = 0;
		pLayer.style.KhtmlOpacity = 0;
		pLayer.style.filter = "alpha(opacity=0)";

		this.blinkKwdinFF(pLayer,pLayerS);
		//pLayerS.style.top = (parseInt(pLayerS.style.top.replace("px", "")) - 3) + "px";
		//pLayer.style.top = (parseInt(pLayer.style.top.replace("px", "")) - 3) + "px";
	}

	// 기본 레이어가 13px(각 레이어의 Height값) 이동되면, 처음 Top 위치로 복원
	if (parseInt(pLayer.style.top.replace("px", "")) <= -13) {
		pLayerS.style.top = 0;
		pLayer.style.top = 0;

		// Clear setInterval
		clearInterval(this.scrInterval);

		// 다음 라인 레이어로 이동
		this.aLayerNum++;

		// 보여주는 라인 개수가 모두 스크롤 되면, 다시 맨 처음 정보부터 스크롤
		if (this.aLayerNum > this.rtnum - 1) {
			this.aLayerNum = 0;

			// 5 seconds 후에 정보 갱신 함수 호출
			var loader = this;
			this.scrBreaktime = setTimeout(function(){loader.rtrenewData("initLayer(" + loader.aLayerNum + ")")}, 5000);
		}

		// 보여주는 라인 개수가 아직 안되었다면, 그 다음 라인 정보 갱신 함수 호출
		else {
			this.rtrenewData("initLayer(" + this.aLayerNum + ")");
		}
	}
}

// 키워드 깜빡거리기 in Firefox
getRtObj.prototype.blinkKwdinFF = function(pLayer,pLayerS) {
	var loader = this;
	this.scrBreaktime = setTimeout(function() {
		pLayer.style.opacity = 1.0;
		pLayer.style.MozOpacity = 1.0;
		pLayer.style.KhtmlOpacity = 1.0;
		pLayer.style.filter = "alpha(opacity=100)";
		pLayer.style.top = 0;
		pLayerS.style.top = 0;

		loader.aLayerNum++;
		// 보여주는 라인 개수가 모두 스크롤 되면, 다시 맨 처음 정보부터 스크롤
		if (loader.aLayerNum > loader.rtnum - 1) {
			loader.aLayerNum = 0;

			// 5 seconds 후에 정보 갱신 함수 호출
			loader.scrBreaktime = setTimeout(function(){loader.rtrenewData("initLayer(" + loader.aLayerNum + ")")}, 5000);
		}
		else {
			loader.rtrenewData("initLayer(" + loader.aLayerNum +")");
		}
	},500);
}

// to set a search value
getRtObj.prototype.url_write = function() {
	var locationStr = document.location.toString();
	if (locationStr.indexOf("&w=") > "0" || locationStr.indexOf("?w=") > "0") {
		var temp = locationStr.split("?","2");
		var spObj = temp[1];
		var spObj2 = spObj.split("&");
		var len = spObj2.length;

		for(var i=0; i<len; i++) {
			var searchParam = spObj2[i].indexOf("w=");
			if(searchParam == "0"){
				searchParam = i;
				var spVal = spObj2[i];
				var wVal = spVal.substring("2",spVal.length);
				break;
			}
		}
		return wVal;
	} else if (locationStr.indexOf("w=&") > "0") {
		var wVal = "tot";
		return wVal;
	} else if (locationStr.indexOf("/website/") > "0") {
		var wVal = "dir";
		return wVal;
	} else {
		var wVal = "tot";
		return wVal;
	}
}

// check a url
getRtObj.prototype.urlexpand = function(url){
	var href = document.location.href;
	if (url == "") return href;
	if (url.match(/^[-.A-Za-z]+:/)) return url;
	if (url.charAt(0) == '#') return href.split("#")[0] + url;
	if (url.charAt(0) == '?') return href.split("?")[0] + url;
	if (url.charAt(0) == '/') return href.replace(/([^:\/])\/.*$/, "$1") + url;
	return href.substring(0, href.lastIndexOf("/")+1) + url;
}

// return a url form after setting each parameter
getRtObj.prototype.getLink = function(p,q) {
	var r_query = q;
	var host = document.location.host;

	var linkStr = document.location.toString();
	var linkTemp = linkStr.split(";");
	var linkTemp2 = linkStr.split("?");
	if (linkStr.indexOf("Search;jsessionid") > "0") {
		var linkTempN = linkTemp[0].split("/");
		var linkTempS = linkTemp[1].split("?");
	} else {
		var linkTempN = linkTemp2[0].split("/");
	}
	//var val = url_write();
	var val = this.rtsn;
	var u = '';
	var nf = '';
	var np = "realtime";
	var nm = "";
	if(val == "alldic") nm = "alldic";
	else if (val == "dic100") nm = "encdic";
	else if (val == "dicee") nm = "eedic";
	else if (val == "dicen") nm = "endic";
	else if (val == "dickr") nm = "krdic";
	else if (val == "dicha") nm = "handic";
	else if (val == "dicjp") nm = "jpdic";
	else nm = "alldic";

	if(val == "alldic") u = this.urlexpand("http://alldic.daum.net/dic/search_result_total.do?nil_profile=" + np + "&nil_menu=" + nm);
	else if (val == "dic100") u = this.urlexpand("search.do?w=100&m=all&nil_profile=" + np + "&nil_menu=" + nm);
	else if (val == "dicee") u = this.urlexpand("http://eedic.daum.net/dicee/search_result_total.do?nil_profile=" + np + "&nil_menu=" + nm);
	else if (val == "dicen") u = this.urlexpand("http://engdic.daum.net/dicen/search_result_total.do?nil_profile=" + np + "&nil_menu=" + nm);
	else if (val == "dickr") u = this.urlexpand("search.do?nil_profile=" + np + "&nil_menu=" + nm);
	else if (val == "dicha") u = this.urlexpand("http://handic.daum.net/dicha/search_result_total.do?nil_profile=" + np + "&nil_menu=" + nm);
	else if (val == "dicjp") u = this.urlexpand("http://jpdic.daum.net/dicjp/search_result_total.do?nil_profile=" + np + "&nil_menu=" + nm + "&type=jp");
	else u = this.urlexpand("http://alldic.daum.net/dic/search_result_total.do?nil_profile=" + np + "&nil_menu=" + nm);;

	u += "&ref_code=";
	u += nf;
	u += "&q=";
	u += encodeURIComponent(r_query);
	//if (rtsn == "tot") u += "&rflag=real";
	//else if (rtsn == "tot_more") u += "&rflag=more";
	return u;
}

// 실시간 검색어가 8자 이상일 경우 말풍선 처리
function showBalloon(i,str,rtwn,rtnum,scRandNum) {
	scRandNum = scRandNum.toString();
	// 기존 말풍선이 있을 경우 제거
	if (document.getElementById("rtdivBalloon_" + scRandNum)) hideBalloon(scRandNum);
	if (document.getElementById("rtdivWrap_" + scRandNum)) {
		if (str.length > rtwn) {
			var divBalloon = document.createElement("div");
			divBalloon.id = "rtdivBalloon_" + scRandNum;
			divBalloon.style.position = "absolute";
			divBalloon.style.zIndex = 1000;
			divBalloon.style.left = "15px";
			if (i > rtnum - 2) divBalloon.style.top = i * 22 - 34 + "px";
			else divBalloon.style.top = i * 22 + 13 + "px";
			//if (navigator.appName == "Microsoft Internet Explorer") divBalloon.style.width = (str.length * 10) + 22 + "px";
			//else divBalloon.style.width = (str.length * 11) + 5 + "px";
			divBalloon.style.padding = "7px";
			divBalloon.style.backgroundColor = "#F7FFE2";
			divBalloon.style.border = "1px #98B477 solid";
			divBalloon.innerHTML = str;
			document.getElementById("rtdivWrap_" + scRandNum).appendChild(divBalloon);
		}
	}
}

// 말풍선 제거 함수
function hideBalloon(scRandNum) {
	scRandNum = scRandNum.toString();
	if (document.getElementById("rtdivWrap_" + scRandNum)) {
		if (document.getElementById("rtdivBalloon_" + scRandNum)) {
			// Memory Leaking 방지
			document.getElementById("rtdivWrap_" + scRandNum).removeChild(document.getElementById("rtdivBalloon_" + scRandNum));
		}
	}
}