/*
function sInit(){
}
function stockCodeHref2(){
}
*/

//2009 3 26 hjkim ´º½º¼¾ÅÍ¿¡¼­ Á¾¸ñ ÆË¾÷ ¼­ºñ½º ºüÁöÁö ¾Ê¾Æ ´çºÐ°£ ÁÖ¼® Ã³¸®ÇÔ.

var codeAll = new Array();
var codeAllCoun = 0;
var regxp;
var LoadCheck = 0;
var pointChk = false;
function stockCodeHref(){
	try{
	bodyText = document.all["Conts"];
	tdText = new String(bodyText.innerHTML);
	regxp =  /(\()([0-9]{6})(\))/i;
	bodyText.innerHTML = tdText.replace(regxp , "(<a href=http://vip.mk.co.kr/newst/price/fastStockSearch.php?keyWord=$2 target=_new>$2</a>)");
	}catch(e){}
}
function pointUp(){
	this.pointChk = true;
}
function pointOut(){
	this.pointChk = false;
}
function stockCodeHrefn(bodyTextTag){
	try{
	tdText = new String(bodyTextTag.innerHTML);
	regxp =  /(\()([0-9]{6})(\))/ig;
	bodyTextTag.innerHTML = tdText.replace(regxp , "(<a href=http://vip.mk.co.kr/newst/price/fastStockSearch.php?keyWord=$2 target=_new>$2</a>)");
	}catch(e){}
}
function stockCodeHref2(){
	try{
		stockCodeTable.src = "http://channel.mk.co.kr/common/js/stock/newsCodestockCode.js";
	}catch (e){}

	if(window.ActiveXObject){
		setTimeout("initStockCodeHref()",500);
	}
}
function regInk2(s){
	s = s.replace("*","\\*");
	s = s.replace("-","\\-");
	return s;
}
function initStockCodeHref(){
	try{
			var kcodeAllap
			bodyTextTag = document.all["artText"];
//			if(this.LoadCheck == 3 && bodyTextTag.toLowerCase().indexOf("gonews") < -1   ){

				if(this.LoadCheck == 3 && bodyTextTag.innerHTML.toLowerCase().indexOf("object") < 0    ){

//			if(this.LoadCheck == 3   ){

					tdText = new String(bodyTextTag.innerHTML);
					kcodeAllap = tdText.match(this.regxp);
					kcodeAllap.sort();
					kcodeAlla = new Array();

					for(i=kcodeAllap.length -1,j=0 ; i>=0; i--,j++) {
						kcodeAlla[j] = kcodeAllap[i];
					}
					for(i = 0 ; i < kcodeAlla.length ; i++){
						boolean1 = false;
							for(o=0 ; o < i ;o++){
									if(kcodeAlla[i] == kcodeAlla[o]){
										boolean1 = true;
										break;
									}
							}
						if(boolean1 == false){
							if(tdText.indexOf("\">"+kcodeAlla[i].toString())  < 0){
								rrregxp = new RegExp(regInk2(kcodeAlla[i].toString()),"g");
								tdText = tdText.replace(rrregxp, "<span onClick=\"AllClose('"+i+"')\" style=\"cursor: pointer;color:0b06a8\" onMouseup=\"pointUp()\" onMouseout=\"pointOut()\">"+kcodeAlla[i]+"</span>");
								delete rrregxp;
							}else{
								k2TmpArray = new Array();
								k2TmpArray = tdText.split("\">"+kcodeAlla[i].toString());
								tdText = "";
								for(k2=0; k2<k2TmpArray.length; k2++) {
									rrregxp = new RegExp(regInk2(kcodeAlla[i].toString()),"g");
									if(k2 == 0){
	          							tdText += k2TmpArray[k2].replace(rrregxp, "<span onClick=\"AllClose('"+i+"')\" style=\"cursor: pointer;color:0b06a8\" onMouseup=\"pointUp()\" onMouseout=\"pointOut()\">"+kcodeAlla[i]+"</span>");
									}else{
										tdText += "\">"+kcodeAlla[i].toString()+k2TmpArray[k2].replace(rrregxp, "<span onClick=\"AllClose('"+i+"')\" style=\"cursor: pointer;color:0b06a8\" onMouseup=\"pointUp()\" onMouseout=\"pointOut()\">"+kcodeAlla[i]+"</span>");
									}
									delete rrregxp;
								}
								delete  k2TmpArray;
							}
						}
						this.codeAll[this.codeAllCoun] = kcodeAlla[i];
						this.codeAllCoun++;
					}
					bodyTextTag.innerHTML = tdText;
					delete tdText;
		}
	}catch(e){}
}
function tableCreateStockTable(){
try{
		if(this.codeAll.length > 0){
			str = "";
			for(i=0 ; i<this.codeAllCoun;i++){
				str+=";"+this.codeAll[i];
			}
			if(this.codeAllCoun >  0){
				stockCodeTable.src="http://vip.mk.co.kr/st/include/stockSearchJs.php?keyWord="+str;
			}
		}
	}catch(e){};
}
//<!--
function startCateScrollScroll(id1,ph) {
	try{
	setTimeout("slideCateScroll('"+id1+"',"+ph+")", 10);
	}catch(e){};
}
function slideCateScroll(id_ii,ph) {
		try{
			var Sel_Height=220;
			el = document.getElementById("stock_A");
			if (el.heightPos == null || (el.isDone && el.isOn == false)) {
				el.isDone = false;
				el.heightPos = 6;
				el.heightTo = Sel_Height;
				el.style.display = "block";
				el.style.backgroundColor = "#ffffff";
				el.innerHTML = "<img src=http://img.mk.co.kr/loading3.gif>";
			} else if (el.isDone && el.isOn){
				el.isDone = false;
				el.heightTo = 6;
				el.innerHTML = "";
				el.style.backgroundColor = null;
			}
			if (Math.abs(el.heightTo - el.heightPos) > 1) {
				el.heightPos += (el.heightTo - el.heightPos) / 1.2;
				el.style.height = el.heightPos + "px";
				el.innerHTML = el.innerHTML	+ "<img src=http://img.mk.co.kr/loading3.gif>";
				startCateScrollScroll("stock_A",ph);
			} else {
			if (el.heightTo == Sel_Height) {
				if(id_ii != "mkdicLayer"){
					if(this.codeAll[ph].indexOf("&amp;") < 0){

						if(this.codeAll[ph].length > 0){
							stockCodeTable.src = "http://chart.mk.co.kr/newsSmallPrice.php?stCode="+this.codeAll[ph]+"&symbolname=stock_A";
							}

						}else{
						stockCodeTable.src = "http://chart.mk.co.kr/newsSmallPrice.php?stCode="+this.codeAll[ph].replace("&amp;","^^")+"&symbolname=stock_A";
					}
				}
				el.isOn = true;
			} else {
				el.isOn = false;
				el.style.display = "none";
			}
			el.heightPos = el.heightTo;
			el.style.height = el.heightPos + "px";
			el.isDone = true;
			}
		}catch(e){};
}
function startCateScrollScroll2() {
		try{
			setTimeout("slideCateScroll2()", 10);
		}catch(e){}
}
function slideCateScroll2() {
	try{
		var Sel_Height=178;
		el = document.getElementById("mkdicLayer");
		if (el.heightPos == null || (el.isDone && el.isOn == false)) {
			el.isDone = false;
			el.heightPos = 6;
			el.heightTo = Sel_Height;
			el.style.display = "block";
			el.style.backgroundColor = "#ffffff";
		} else if (el.isDone && el.isOn){
			el.isDone = false;
			el.heightTo = 6;
			el.innerHTML = "";
			el.style.backgroundColor = null;
		}
		if (Math.abs(el.heightTo - el.heightPos) > 1) {
			el.heightPos += (el.heightTo - el.heightPos) / 1;
			el.style.height = el.heightPos + "px";

			startCateScrollScroll2();
		} else {
		if (el.heightTo == Sel_Height) {
			el.isOn = true;
		} else {
			el.isOn = false;
			el.style.display = "none";
		}
		el.heightPos = el.heightTo;
		el.style.height = el.heightPos + "px";
		el.isDone = true;
		}
	}catch(e){};
}
function AllClose(cid){
	try{
		if(document.all("stock_A").isDone && document.all("stock_A").isOn){
			slideCateScroll('stock_A',cid);
		}
		show2("stock_A",cid);
	}catch(e){}
}
function AllCloseD(){
	try{
		if(document.all("mkdicLayer").isDone && document.all("mkdicLayer").isOn){
			slideCateScroll2();
		}
		show();
	}catch(e){}
}
function AllCloseA(){
		try{
		if(document.all("stock_A").isDone && document.all("stock_A").isOn){
			slideCateScroll('stock_A',-1);
		}
		}catch(e){}
}
function stockCodeHrefTitle(){
	try{
		bodyTextTag = document.all["titleTdTab"];
		tdText = new String(bodyTextTag.innerHTML);
		kcodeAll = tdText.match(this.regxp);
		for(i = 0 ; i < kcodeAll.length ; i++){
			this.codeAll[this.codeAllCoun] = kcodeAll[i];
			this.codeAllCoun++;
		}
	}catch(e){}
}

function AllClose2(){
	for(i=0; i<this.codeAllCoun; i++) {
	try{
		var jj;
		jj = "stock_"+i;
			el = eval("document.getElementById('"+jj+"')");
			if(el.style.display == "block"){
				slideCateScroll(jj);
				break;
			}
	}catch(e){};
	}
}

function fnHandleDragStart(){
	try{
	  var oData = window.event.dataTransfer;
	  oData.effectAllowed = "move";
	}catch(e){};
 }
function fnHandleDrop()
{
	try{
	  var oTarg = window.event.srcElement;
	  var oData = window.event.dataTransfer;
	  fnCancelDefault();
		window.open('http://dic.mk.co.kr/cp/pop/desc.php?where=ti&so=all&from=&to=&key_word='+oData.getData("text"),'view','');
	}catch(e){};
}
function fnHandleDragEnter()
{
	try{
		  var oData = window.event.dataTransfer;
		  fnCancelDefault();
		  oData.dropEffect = "move";
	  }catch(e){};
}

function fnCancelDefault()
{
	try{
	  var oEvent = window.event;
	  oEvent.returnValue = false;
    }catch(e){};
}
function sInit(){
	try{
		var SourceLink;
		SourceLink= document.all("artText");
		SourceLink.ondragstart=function(){fnHandleDragStart()};
		SourceLink.onclick=function(){hiddenOntextMenu()};
		SourceLink.onmouseup  = function(){AllCloseD()};
	}catch(e){};
	try{
		var SourceLink2;
		SourceLink2= document.all("newsTitleTag");
		SourceLink2.ondragstart=function(){fnHandleDragStart()};
		SourceLink2.onclick=function(){hiddenOntextMenu()};
		SourceLink2.onmouseup  = function(){AllCloseD()};
	}catch(e){};
	/*
	try{
		var viewLink;
		viewLink = document.all("mkDicSearch");
		viewLink.ondrop=function(){fnHandleDrop()};
		viewLink.ondragover=function(){fnCancelDefault()};
		viewLink.ondragenter=function(){fnHandleDragEnter()};
	}catch(e){};
	*/
}

function hiddenOntextMenu(){
	try{
		if(document.all("mkdicLayer").isDone && document.all("mkdicLayer").isOn){
			document.all("mkdicLayer").style.display = "none";
		}

		if(document.all("stock_A").isDone && document.all("stock_A").isOn){
			document.all("stock_A").style.display = "none";
		}

	}catch(e){}
}
function show(){
	try{
		if(document.selection.createRange().text.length > 1 && document.selection.createRange().text.length < 60 && this.pointChk == false){
			 obj2=document.getElementById('mkdicLayer');
			 st=document.body.scrollTop;
			 sl=document.body.scrollLeft;
			 ex=event.x+sl+5;
			 ey=event.y+st+15;
			if(ex < 10) ex = 10;
			locationInfo =  document.location;

				SelectData = document.selection.createRange().text;

						SelectData = SelectData.replace("\"","");
			SelectData = SelectData.replace("'","");
			SelectData = SelectData.replace("\n","");
			SelectData = SelectData.replace("\r","");



			html = "";
			html +=  "<div class=dc_search_div>";
			html +=  "  <a href='http://find.mk.co.kr/search/search.php?old_news=recent&pageNum=1&cat=&cat1=&pageSize=10&sub=all&dispFlag=OFF&page=total&go_page=page&ord=1&ord1=1&ord2=1&s_page=dic&method=allwordthruindex&area=ttbd&s_keyword="+document.selection.createRange().text+"'  target=_new><span class=dc_search2 style=color:#df7414;>ÅëÇÕ°Ë»ö</span></a><br />";
			html +=  "  <a href='http://find.mk.co.kr/search/search_news.php?old_news=recent&pageNum=1&cat=&cat1=&media_eco=&pageSize=10&sub=all&dispFlag=OFF&page=news&go_page=&ord=1&ord1=1&ord2=1&s_page=news&method=allwordthruindex&area=ttbd&s_keyword="+document.selection.createRange().text+"' target=_new><span class=dc_search2>´º½º°Ë»ö</span></a><br />";
			html +=  "  <a href='http://find.mk.co.kr/search/search_tech.php?old_news=recent&pageNum=1&cat=&cat1=&media_eco=&pageSize=10&sub=all&dispFlag=OFF&page=tech&go_page=page&ord=1&ord1=1&ord2=1&s_page=news&method=allwordthruindex&area=ttbd&s_keyword="+document.selection.createRange().text+"' target=_new><span class=dc_search2>ÀçÅ×Å©°Ë»ö</span></a><br />";
			html +=  "  <a href='http://find.mk.co.kr/search/search_dic.php?old_news=recent&pageNum=1&cat=&cat1=&media_eco=&pageSize=10&sub=all&dispFlag=OFF&page=dic&go_page=page&ord=1&ord1=1&ord2=0&s_page=tech&method=allwordthruindex&area=ttbd&s_keyword="+document.selection.createRange().text+"' target=_new><span class=dc_search2>°æÁ¦¿ë¾î°Ë»ö</span></a></td>";
			html +=  " <hr style=height:1px; width:100px; color:#CCCCCC/>";
			html +=  "  <a href=javascript:; onClick=\"javascript:sendPrint()\"><span class=dc_search>ÀÎ¼âÇÏ±â</span></a><br />";
			html +=  " <a href=javascript:; onClick=\"java"+"script:window.clipboard"+"Data.setDa"+"ta('Text', '"+locationInfo+"');alert('ÁÖ¼Ò¸¦ º¹»ç ÇÏ¿´½À´Ï´Ù.');\"><span class=dc_search>ÁÖ¼Òº¹»ç</span></a><br />";
			html +=  " <a href=javascript:; onClick=\"java"+"script:window.clipboard"+"Data.setDa"+"ta('Text', '"+SelectData+"');alert('º¹»ç ÇÏ¿´½À´Ï´Ù.');\"><span class=dc_search>´Ü¾îº¹»ç</span></a>";
			html +=  "</div>";
			 obj2.innerHTML = html;
			 obj2.style.left=ex;
			 obj2.style.top=ey;
			 eval(layerview+'["mkdicLayer"]'+styleview+'visibility="visible"');
		 	slideCateScroll2();
		}
	}catch(e){}
}

function show2(as,ph){

			 obj=document.getElementById('stock_A');
			 st=document.body.scrollTop;
			 sl=document.body.scrollLeft;
			 ex=event.x+sl-100;
			 ey=event.y+st+10;
			if(ex < 10) ex = 10;
			 obj.style.left=ex;
			 obj.style.top=ey;
			 eval(layerview+'["stock_A"]'+styleview+'visibility="visible"')
			 slideCateScroll(as,ph);
}

function hide(){
		try{
			eval(layerview+'["mkdicLayer"]'+styleview+'visibility="hidden"') ;
		}catch(e){};
}
function mouseDown(e)
{
	try{
			if (window.Event)
		   {
				if (e.which == 2 || e.which == 3){
								event.cancelBubble = true;
								event.returnValue = false;
								if(document.selection.createRange().text.length > 1){
										alert("a");
										  document.oncontextmenu = nocontextmenu;
									show(document.selection.createRange().text);
									slideCateScroll2('mkdicLayer');
									return false;
								}else{
								   document.oncontextmenu = nocontextmenu2;
								}
					}
				}else{
					if (event.button == 2 || event.button == 3)
					{
								if(document.selection.createRange().text.length > 1){

									 document.oncontextmenu = nocontextmenu;
									event.cancelBubble = true;
									event.returnValue = false;
									show(document.selection.createRange().text);
									slideCateScroll2('mkdicLayer');
									return false;
								}else{
								  document.oncontextmenu = nocontextmenu2;
								}
					}

				}
	}catch(e){};
}

function nocontextmenu()
{
	try{
      event.cancelBubble = true;
        event.returnValue = false;
        return false;
	}catch(e){};
}
function nocontextmenu2()
{
	return true;
}

try{
		if (document.all) {
		layerview='document.all'
		styleview='.style.'
		}
		else if (document.layers) {
		layerview='document.layers'
		styleview='.'
		}
	//		document.onmousedown = mouseDown ;
		document.writeln("<"+"script id=stockCodeTable"+"><"+"/script"+">");
		document.writeln("<div id=\"mkdicLayer\" style=\" filter:alpha(Opacity:100); visibility:hidden; width:116px; height:1; position:absolute;overflow: auto;display:none;bgcolor-color:#ffffff\"  onClick='hiddenOntextMenu()'></div>");
		document.writeln("<div id=\"stock_A\" style=\" filter:alpha(Opacity:100); visibility:hidden; width:290px; height:1; position:absolute;overflow: auto;display:none;bgcolor-color:#ffffff\" onClick=\"javascript:AllCloseA('stock_');\" ></div>");
}catch(e){};

//-->




