document.write('<script language=\'javascript\' src=\'/kws/js/domain_idc.js\'></script>');
document.write('<script language=\'javascript\' src=\'/kws/js/host_url.js\'></script>');

function getCookieVal (offset)
{
    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

var s = GetCookie('keybsecgb');
if(s != 1 || s == null)
{
  document.write('<script language=\'javascript\' src=\'/kws/js/security.js\'></script>');
}

/** 사이트 링크 인클루드 (트레이딩) **/
document.write('<script type="text/javascript" src="/kws/js/linkTrade.js"></script>');

/** 사이트 링크 인클루드 (트레이딩 외 나머지) **/
document.write('<script type="text/javascript" src="/kws/js/link.js"></script>');

var str = GetCookie('BBSID');
var id = "";
if(str != '' && str != null)
{
  str2 = str.split("|");
  id = str2[0];
}
else
{
  id ="";
}

var urls = new Array();
/********************************************************************************************************
    java 전용 버전
    0: 유탈메뉴 , 1: 트래이딩 , 2: 해외주식 , 3: 리서치센터 , 4: 펀드몰 , 5: 온라인지점 , 6 :On-Air
********************************************************************************************************/
/** 유틸 메뉴 **/
urls[0] = ["", "TD540000", "TD541103&tw=TD541000&lw=ETCLFXML101", "TD101007&tw=TD100000&lw=LFXML002", "CS000000", "MK000000", "UI000000", "EXBBN011&tw=CS100000&lw=ETCLFXML202", "SM100000", "/kws/html/ir_eng/ceo.html", "UI200004&tw=UI100000&lw=ETCLFXML003"];
/** 트레이딩 **/
urls[1] = ["TD101001&tw=TD100000&lw=LFXML000","TD101001&tw=TD100000&lw=LFXML000","TD102001&tw=TD100000&lw=LFXML010","TD103001&tw=TD100000&lw=LFXML020","TD104001&tw=TD100000&lw=LFXML030","TD105001&tw=TD100000&lw=LFXML040","TD106001&tw=TD100000&lw=LFXML050","TD107001&tw=TD100000&lw=LFXML060","TD108001?site=co&tw=TD100000&lw=LFXML070","TD109001&tw=TD100000&lw=LFXML080"];
/** 해외주식 **/
urls[2] = ["FR000000","FR101001&tw=FR100000&lw=LFXML100","FR110001&tw=FR100000&lw=LFXML110","FR102001&tw=FR100000&lw=LFXML120","FR104001&tw=FR100000&lw=LFXML130","FR111001&tw=FR100000&lw=LFXML140","FX105001&tw=FR100000&lw=LFXML150","OL101001&tw=FR100000&lw=LFXML160","EXBBN014&tw=FR100000&lw=LFXML170"];
/**urls[2] = ["FR000000","FR101001&tw=FR100000&lw=LFXML100","FR110001&tw=FR100000&lw=LFXML110","FR102001&tw=FR100000&lw=LFXML120","FR104001&tw=FR100000&lw=LFXML130","FR111001&tw=FR100000&lw=LFXML140","FX105001&tw=FR100000&lw=LFXML150","EXBBN014&tw=FR100000&lw=LFXML160"];******/
/** 리서치센터 **/
/*urls[3] = ["RS000000", "EXBBS015?menu=SD&tw=RS100000&lw=LFXML200", "EXBBS020?menu=BW&tw=RS100000&lw=LFXML210", "EXBBS016?menu=FD&tw=RS100000&lw=LFXML220", "EXBBS017&tw=RS100000&lw=LFXML230", "RS105001&tw=RS100000&lw=LFXML240","RS106001&tw=RS100000&lw=LFXML250"];*/
/** BBS ==> BBN 변경으로 링크 변경**/
urls[3] = ["RS000000", "EXBBN039&tw=RS100000&lw=LFXML200", "EXBBN044&tw=RS100000&lw=LFXML210", "EXBBN047&tw=RS100000&lw=LFXML220", "EXBBN049&tw=RS100000&lw=LFXML230", "RS105001&tw=RS100000&lw=LFXML240","RS106001&tw=RS100000&lw=LFXML250"];
/** 펀드몰 **/
urls[4] = ["EXFUN001", "EXFUN036", "EXFUN037", "EXFUN038", "EXFUN039",  "EXFUN040", "EXFUN041" ,"EXFUN062"];
/** 온라인지점 **/
urls[5] = ["OL000000", "OL101001&lw=LFXML400&tw=OL100000", "OL102001&lw=LFXML410&tw=OL100000", "OL103001&lw=LFXML420&tw=OL100000", "OL403100&lw=LFXML431&tw=OL100000", "OL105001&lw=LFXML440&tw=OL100000", "OL106001&lw=LFXML450&tw=OL100000", "OL107001&lw=LFXML460&tw=OL100000"];
/** ON-Air **/
urls[6] = ["OA000000", "OA101001&lw=LFXML500&tw=OA100000", "OA102001&lw=LFXML510&tw=OA100000", "OA103001&lw=LFXML520&tw=OA100000", "OA104001&tw=OA100000&lw=LFXML530", "OA106001&lw=LFXML531&tw=OA100000"];
/** 좌측 퀵메뉴 **/
/** 0 : 현재가 , 1 : 관심종목, 2 : 매도매수, 3: 잔고확인, 4: 주문종합10단R, 5:이체, 6. 신규고객수수료무료, 7. 고객만족센터, 8. 영웅문 동영상 강좌, 9.마이키움 - 내정보수정, 10 : 모바일 트레이딩 , 11 : 내게맞는 트레이딩, 12 : 계좌개설 안내  **/
urls[7] = ["TD101001&tw=TD100000&lw=LFXML002", "TD101007&tw=TD100000&lw=LFXML002", "TD101006&tw=TD100000&lw=LFXML001", "TD101020&tw=TD100000&lw=LFXML004", "TD101003&tw=TD100000&lw=LFXML000", "OL101001&tw=OL100000&lw=LFXML400", "UI200016&tw=CS100000&lw=ETCLFXML400", "CS101001&tw=CS100000&lw=ETCLFXML200", "OA101003&tw=OA100000&lw=LFXML503", "MI101001&tw=MK100000&lw=MK101000", "TD541121&tw=UI100000&lw=ETCLFXML102", "UI200019&tw=UI100000&lw=UI101000", "UI101008&tw=UI100000&lw=ETCLFXML000"];
/** FX 메뉴 **/
/** 0 : FX마진, 1 : FX마진거래안내, 2 : 계좌개설/이체/환전, 3 : 매매, 4 : FX모의투자, 5 : 투자정보, 6 : 계좌정보, 7 : 게시판/공지/FAQ 
urls[8] = ["FX100000","FX110001&tw=FX100001&lw=LFXML600","FX120001&tw=FX100001&lw=LFXML610","FX130001&tw=FX100001&lw=LFXML630","FX170001&tw=FX100001&lw=LFXML620","FX160001&tw=FX100001&lw=LFXML640","EXHOM001&tw=FX100001&lw=LFXML650","EXBBN001&tw=FX100001&lw=LFXML660"];
[2009/11/03] FX/해외선물 메뉴 변경*************************/
/** 0 : FX 홈 , 1 : FX마진, 2 : 해외선물, 3: FX매매, 4: 해외선물 매매, 5:투자정보, 6. 모의투자, 7. 이체/환전, 8. 계좌개설, 9.게시판  **/
urls[8] = ["FX100000", "FX110001&tw=FX100001&lw=LFXML600", "FX180001&tw=FX100001&lw=LFXML670", "FX130001&tw=FX100001&lw=LFXML630", "FX190001&tw=FX100001&lw=LFXML680", "FX160002&tw=FX100001&lw=LFXML640", "FX170001&tw=FX100001&lw=LFXML620", "EXHOM001&tw=FX100001&lw=LFXML650", "FX120001&tw=FX100001&lw=LFXML610", "EXBBN001&tw=FX100001&lw=LFXML660"];
/********************************************************************************************************
    
********************************************************************************************************/

function depth3TradingLink(left, center) {
	parent.leftFrame.location.href = "/jsp/kws/me/me10/ME1000LeftMenu.jsp?leftxml=" + left;
	parent.mainFrame.trdMain.location.href = center;
}

function depth3Link(left, center) {
	parent.leftFrame.location.href = "/jsp/kws/me/me10/ME1000LeftMenu.jsp?leftxml=" + left;
	parent.mainFrame.location.href = center;
}

function depth3OnairCnsLink(left, center) {
	parent.leftFrame.location.href = "/jsp/kws/me/me10/ME1000LeftMenu.jsp?leftxml=" + left;
	parent.mainFrame.location.href = center;
}

function depth3BBNLink(left, center) {	
	/**
	var host=location.host;
	var bbn_host="bbn.kiwoom.com";	
	if (host.indexOf("kiwoom.com") > 0)
		bbn_host = "bbn.kiwoom.com";
	else
		bbn_host = "bbn.kiwoom.co.kr";		
	****/	
	parent.leftFrame.location.href = "/jsp/kws/me/me10/ME1000LeftMenu.jsp?leftxml=" + left;
	parent.mainFrame.location.href = "http://" + bbn_host + center;
}

function depth3BBSLink(left, center) {	
	/****
	var host=location.host;
	var bbn_host="bbs.kiwoom.com";	
	if (host.indexOf("kiwoom.com") > 0)
		bbn_host = "bbs.kiwoom.com";
	else
		bbn_host = "bbs.kiwoom.co.kr";		
	*****/	
	parent.leftFrame.location.href = "/jsp/kws/me/me10/ME1000LeftMenu.jsp?leftxml=" + left;
	parent.mainFrame.location.href = "http://" + bbn_host + center;
}

function depth3VTSLink(left, center) {
	/*****
	var host=location.host;
	var vts_host="vts.kiwoom.com";	
	if (host.indexOf("kiwoom.com") > 0)
		vts_host = "vts.kiwoom.com";
	else
		vts_host = "bbn.kiwoom.co.kr";		
	******/
	parent.leftFrame.location.href = "/jsp/kws/me/me10/ME1000LeftMenu.jsp?leftxml=" + left;
	parent.mainFrame.location.href = "http://" + vts_host + center;
}

function depth3FXLink(left, center) {	
	parent.leftFrame.location.href = "/jsp/kws/me/me10/ME1000LeftMenu.jsp?leftxml=" + left;
	parent.mainFrame.trdMain.location.href = "http://" + fx_host + center;
}

function depth3FXLink2(left, center) {
	parent.leftFrame.location.href = "/jsp/kws/me/me10/ME1000LeftMenu.jsp?leftxml=" + left;
	parent.mainFrame.location.href =  "http://" + fx_host + center;
}


function goConsultDiv(cno, penname, name)
{
      var frm     = document.cnsfrm;

      if(cno == "" || cno == null){
         return;
      }

      leftarget = "/jsp/kws/me/me10/ME1000LeftMenu.jsp?cno="+ cno +"&leftxml="+"/kws.OA1000LeftConsultXml.do?cno="+cno+"&penname="+penname+"&cname="+name;
      maintarget = "/kws.OA7000Main_cnshome.do?cno="+cno+"&penname="+penname;
      parent.leftFrame.location.replace(leftarget);
      location.replace(maintarget);
}

function history_window_open() {
	parent.document.getElementById('mainFrame').rows = "*,38";	
	parent.trdTicker.document.getElementById('shlist').style.display = "block";
}
function history_window_close() {
	parent.document.getElementById('mainFrame').rows = "*,22";	
	parent.trdTicker.document.getElementById('shlist').style.display = "none";
}

/** 링크 관련 **/
goLink = function(m,s,s0,s1,s2){

    if(m == undefined){
        m = 0 ;
    }
    if(s == undefined){
        s = 0 ;
    }
    w = parent.mainFrame ;
	
	if(m==0&&s==9&&s!=1){
		window.open(urls[m][s]) ;
		return ;
	}else if ( m==8 ) {
		var target_host = location.host;
		
		if(target_host.substring(target_host.length-10) == "kiwoom.com")
		{
			if(top.index != null && typeof(top.index) != "undefined"){
	   			top.index.location.href = "http://"+fx_host + "/kfx.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2;
	   		}else{
	   			top.location.href = "http://"+fx_host + "/kfx.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2 ;
	   		}
   		} if(target_host.substring(target_host.length-12) == "kiwoom.co.kr")
		{
			if(top.index != null && typeof(top.index) != "undefined"){
	   			top.index.location.href = "http://"+fx_host + "/kfx.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2;
	   		}else{
	   			top.location.href = "http://"+fx_host + "/kfx.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2 ;
	   		}
   		}
   		else 
   		{
   			if(top.index != null && typeof(top.index) != "undefined"){
	   			top.index.location.href = "http://"+fx_host + "/kfx.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2 ;
	   		}else{
	   			top.location.href = "http://"+fx_host + "/kfx.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2 ;
	   		}
   		}
  	 	return ;
  	 	
	}else {
		var target_host = location.host;
		
		if(target_host.substring(target_host.length-10) == "kiwoom.com")
		{
			if(top.index != null && typeof(top.index) != "undefined"){
	   			top.index.location.href = domain_idc + "/kws.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2;
	   		}else{
	   			top.location.href = domain_idc + "/kws.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2 ;
	   		}
   		}
   		else 
   		{
   			if(top.index != null && typeof(top.index) != "undefined"){
	   			top.index.location.href = "/kws.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2 ;
	   		}else{
	   			top.location.href = "/kws.ME1000MainSet.do?c="+urls[m][s]+"&s0="+s0+"&s1="+s1+"&s2="+s2 ;
	   		}
   		}
  	 	return ;
  	}

    /** 트레이딩 **/
    if(m==1){
    	if(top.index != null && typeof(top.index) != "undefined"){
        	top.index.location.href = domain_idc + "/kws.ME1000MainSet.do?c="+urls[m][s] ;
        }else{
        	top.location.href = domain_idc + "/kws.ME1000MainSet.do?c="+urls[m][s] ;
        }
    }else{
        goLink2(m,s) ;
    }
}

/** 영문회사소개 상단 유틸 **/
var urlsEng = new Array("/kws/html/ir_eng/ceo.html", "/kws/html/ir/main.html", "/kws/html/ir_eng/contactus.html");
goLinkEng = function(m){
    if(m == undefined){
        m = 0;
    }
    location.href = urlsEng[m];
}

/** 김세진추가 floatBanner.js 페이지 이동 **/
function goLinkPage (url, opt){
    w = parent.mainFrame;
    /** mainset인 경우 **/
    if(w != null)
    {
        parent.location.href=url;
    }
    else
    {
       top.index.location.href=url;
    }
}

/********************************************************************************************************
    팝업창 오픈
********************************************************************************************************/
/** object 태그 뿌리기위한 공통 변수 선언 **/
var objectPrint = "";

function uf_popOpen(url, p_w, p_h) {
    window.open(url,"","width="+p_w+",height="+p_h+",toolbar=no,scrollbars=no,resizable=no" );
}

function uf_popOpen_s(url, p_w, p_h) {
    window.open(url,"","width="+p_w+",height="+p_h+",toolbar=no,scrollbars=yes,resizable=no" );
}

/********************************************************************************************************
    플래쉬
********************************************************************************************************/
function Flash_display(sFName, nWidth, nHeight, sVName, BGColor, Wmode ){
    document.writeln ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http:// fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ nWidth + '" height="'+ nHeight + '" id="'+ sVName +'" align="middle">');
    document.writeln ('<param name="allowScriptAccess" value="always" />');
    document.writeln ('<param name="movie" value="'+ sFName + '" />');
    document.writeln ('<param name="quality" value="high" />');
    document.writeln ('<param name="bgcolor" value="' + BGColor + '" />');
    document.writeln ('<param name="wmode" value="' + Wmode + '" />');
    document.writeln ('<embed src="'+ sFName + '" quality="high" bgcolor="#ffffff" width="'+ nWidth + '" height="'+ nHeight + '" name="'+ sVName +'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http:// www.macromedia.com/go/getflashplayer" /> ');
    document.writeln ('</object>');
}

/********************************************************************************************************
    이미지 오버/아웃
********************************************************************************************************/
function setOver(thisImg, sMode) {
    var sPath = thisImg.src;
    var sCommonPath = sPath.substring(0, sPath.lastIndexOf("_") + 1);
    var sType = sPath.substring(sPath.lastIndexOf("."), sPath.length);
    thisImg.src = sCommonPath + sMode + sType;
}

/********************************************************************************************************
    서브탭, 링크스탭 온/오프 함수
********************************************************************************************************/
function chgSub(thisImg){
    var seq = 1;
    var sPath = thisImg.src;
    var sImgName = sPath.substring(sPath.lastIndexOf("/") + 1, sPath.lastIndexOf("_") - 2);
    var seqTab = sPath.substring(sPath.lastIndexOf("_") - 2, sPath.lastIndexOf("_") );

    while (seq) {
        var tmpSeq;
        if( seq < 10 ) {
            tmpSeq = "0" + seq;
        } else {
            tmpSeq = seq;
        }

        var objImg = document.getElementById(sImgName + tmpSeq);
        if( objImg ) {

            setOver(objImg, "off");
            document.getElementById('list_' + sImgName + tmpSeq ).style.visibility="hidden";
            document.getElementById('list_' + sImgName + tmpSeq ).style.display="none";
            seq++;
        } else {
            break;
        }
    }

    setOver(thisImg, "on");
    document.getElementById('list_' + sImgName + seqTab ).style.visibility="visible";
    document.getElementById('list_' + sImgName + seqTab ).style.display="";

}

function chgSub2(thisImg){
    var seq = 1;
    var sPath = thisImg.src;
    var sImgName = sPath.substring(sPath.lastIndexOf("/") + 1, sPath.lastIndexOf("_") - 2);
    var seqTab = sPath.substring(sPath.lastIndexOf("_") - 2, sPath.lastIndexOf("_") );

    while (seq) {
        var tmpSeq;
        if( seq < 10 ) {
            tmpSeq = "0" + seq;
        } else {
            tmpSeq = seq;
        }

        var objImg = document.getElementById(sImgName + tmpSeq);
        if( objImg ) {
            setOver(objImg, "off");
            document.getElementById('list_' + sImgName + tmpSeq ).style.visibility="hidden";
            document.getElementById('list_' + sImgName + tmpSeq ).style.display="none";
            document.getElementById('link_' + sImgName + tmpSeq ).style.visibility="hidden";
            document.getElementById('link_' + sImgName + tmpSeq ).style.display="none";
            seq++;
        } else {
            break;
        }
    }

    setOver(thisImg, "on");
    document.getElementById('list_' + sImgName + seqTab ).style.visibility="visible";
    document.getElementById('list_' + sImgName + seqTab ).style.display="";
    document.getElementById('link_' + sImgName + seqTab ).style.visibility="visible";
    document.getElementById('link_' + sImgName + seqTab ).style.display="";

}

/********************************************************************************************************
    Select Menu Link
********************************************************************************************************/
/** 거래시 유의사항 셀렉트 메뉴 **/
function atten_sel(snum){
    if (snum == "1") {
        window.open('http://www.fss.or.kr/kor/koreanIndex.html','fss','width=965,height=650,top=10,left=10,scrollbars=yes,resizable=yes');
    } else {
        location.href = snum;
    }
}

/** Select Menu **/
function goto_byselect(sel,w_target) {
    var index  = sel.selectedIndex;
    var selVal = sel.options[index].value;

    if (selVal == '' )   return;
    else {
        if(w_target == "_blank"){
            window.open(selVal);
        } else {
            location.replace(selVal);
        }
    }
}


/********************************************************************************************************
    Box Menu 하이라이트 선택
********************************************************************************************************/

function CHclass(obj,num) {
    for (i=1;i<num+1;i++) {
        document.getElementById("ch_link" + i).className = "";
    }
    obj.className = "active";
}


/********************************************************************************************************
    FAQ List
********************************************************************************************************/
var z=1;

function faqList(i){
    var answer_i = document.all["answer"+i];
    var faq_text_i=document.all["faq" + i];
    var answer_z = document.all["answer"+z];
    var faq_text_z=document.all["faq" +z];

    if (answer_i && answer_z) {
        if(z != 0){
            answer_z.style.display="none"
            faq_text_z.className = "off";
            answer_i.style.display="";
            faq_text_i.className = "on";
        }
        answer_i.style.display="";
        faq_text_i.className = "on";
        z=i;
    }
}

/********************************************************************************************************
    LEFT MENU
********************************************************************************************************/
var old_menu= '';
var old_sub= 1;
/* 현재메뉴, 서브유무 0.없음, 1.있음 */
function displayMenu(currMenu, sub) {
  /** 현재 메뉴와 과거 메뉴 기억 **/
  var thisMenu = document.all[currMenu];
    var oldMenu =document.all[old_menu];
  var thisMenu_sub = document.all[currMenu+"_sub"];
  var oldMenu_sub = document.all[old_menu+"_sub"];

  if(thisMenu)
  {
    /* 현재메뉴와 과거메뉴가 틀릴경우 */
    if(currMenu != old_menu)
    {
      if(old_menu != '')
      {
        oldMenu.className = "off";
        if(old_sub == 1)
          oldMenu_sub.style.display = "none";
      }
    }

    /* 서브유무 */
    if(sub == 1)
    {
      if (thisMenu_sub.style.display == "block") {
        thisMenu.className = "off";
        thisMenu_sub.style.display = "none";
        old_menu = '';
      }
      else {
        thisMenu.className = "on";
        thisMenu_sub.style.display = "block";
        old_menu = currMenu;
      }
    }
    else
    {
      thisMenu.className = "on";
      old_menu = currMenu;
    }
  }
  old_sub = sub;

}

/********************************************************************************************************
    문자확인
********************************************************************************************************/
/** 바이트수 **/
function strLengthByte(str){
    var totLength = 0;
    for (var i=0;i<str.length;i++)
        totLength += strCharByte(escape(str.charAt(i)));
    return totLength;
}

function strCharByte(chStr){
	//** 한글일때 **/
    if (chStr.substring(0, 2) == '%u'){
        if (chStr.substring(2,4) == '00'){
            return 1;
        }else{
            return 2;
        }
    }else if (chStr.substring(0,1) == '%'){
        if (parseInt(chStr.substring(1,3), 16) > 127){
            return 2;
        }else{
            return 1;
        }
    }else{
        return 1;
    }
}

function isAlphaNumHangul( inStr ) {
    if (inStr.length > 0) {
        for (i=0; i < inStr.length; i++) {
            if (!((inStr.charAt(i) >= '가' && inStr.charAt(i) <= '힝') || (inStr.charAt(i) >= 'a' && inStr.charAt(i) <= 'z') || (inStr.charAt(i) >= 'A' && inStr.charAt(i) <= 'Z') || (inStr.charAt(i) >= '0' && inStr.charAt(i) <= '9')) ) {
                return false;

            }
        }
        return true;
    }else { return false; }
 }

/** 숫자만 **/
function isNum( inStr ) {
    if (inStr.length > 0) {
        for (i=0; i < inStr.length; i++) {
            if (!(inStr.charAt(i) >= '0' && inStr.charAt(i) <= '9')) {
                return false;
            }
        }

        return true;
    }else { return false; }
}

/** 종목코드여부 체크 (조기종료 ELW : 종목코드에 영문 포함) **/
function isNumCode( inStr ) {
    if (inStr.length > 0) {
        for (i=0; i < inStr.length; i++) {
        	if(i == 3) {
        		if (!((inStr.charAt(i) >= 'a' && inStr.charAt(i) <= 'z') || (inStr.charAt(i) >= 'A' && inStr.charAt(i) <= 'Z')) && !(inStr.charAt(i) >= '0' && inStr.charAt(i) <= '9') ) {
        			return false;
        		}
        	} else {
	            if (!(inStr.charAt(i) >= '0' && inStr.charAt(i) <= '9')) {
	                return false;
	            }
	         }
        }

        return true;
    }else { return false; }
}

/** 영문 **/
function isAlpha( inStr ) {
    if (inStr.length > 0) {
        for (i=0; i < inStr.length; i++) {
            if (!((inStr.charAt(i) >= 'a' && inStr.charAt(i) <= 'z') || (inStr.charAt(i) >= 'A' && inStr.charAt(i) <= 'Z')) ) {
                return false;
            }
        }
        return true;
    }else { return false; }
}
/** 영문&숫자만 **/
function isAlphaNum( inStr ) {
    if (inStr.length > 0) {
        for (i=0; i < inStr.length; i++) {

            if (!((inStr.charAt(i) >= 'a' && inStr.charAt(i) <= 'z') || (inStr.charAt(i) >= 'A' && inStr.charAt(i) <= 'Z') || (inStr.charAt(i) >= '0' && inStr.charAt(i) <= '9')) ) {
                return false;
            }
        }
        return true;
    }else { return false; }
}

/** 한글만 **/
function isHangul( inStr ) {
    if (inStr.length > 0) {
        for (i=0; i < inStr.length; i++) {
            if ( !((inStr.charAt(i) >= '가' && inStr.charAt(i) <= '힝') || (inStr.charAt(i)==',')) ) {
                return false;
            }
        }
        return true;
    }else { return false; }
}

/** 특수문자 가려내기.. **/
function isAlphaHangulEmpty( inStr ) {
    if (inStr.length > 0) {
        for (i=0; i < inStr.length; i++) {
            if (!((inStr.charAt(i) >= '가' && inStr.charAt(i) <= '힝') || (inStr.charAt(i) == ' ') || (inStr.charAt(i) >= 'a' && inStr.charAt(i) <= 'z') || (inStr.charAt(i) >= 'A' && inStr.charAt(i) <= 'Z'))) {
                return false;
            }
        }
        return true;
    }else { return false; }
}

function isAlphaHangulEmpty2( inStr ) {
    if (inStr.length > 0) {
        for (i=0; i < inStr.length; i++) {
            if (!((inStr.charAt(i) >= '가' && inStr.charAt(i) <= '힝') || (inStr.charAt(i) >= '0' && inStr.charAt(i) <= '9') || (inStr.charAt(i) == ' ') || (inStr.charAt(i) >= 'a' && inStr.charAt(i) <= 'z') || (inStr.charAt(i) >= 'A' && inStr.charAt(i) <= 'Z'))) {
                return false;
            }
      }
      return true;
    }else { return false; }
}


/** 특수문자 가려내기.. **/
function isHangulEmpty( inStr ) {
    if (inStr.length > 0) {
        for (i=0; i < inStr.length; i++) {
            if ((inStr.charAt(i) >= '가' && inStr.charAt(i) <= '힝') || (inStr.charAt(i) == ' ')) {
                return true;
            }
      }
      return false;
    }else { return false; }
}

/** 이멜의 유효성 체크 **/
function isEmail(inStr){
    var chkcnt;
    chkcnt = 0;
    if (inStr.length > 0) {
        for(i=0; i<inStr.length; i++){
           if(inStr.charAt(i)=='@') {chkcnt = chkcnt+1}
           if(inStr.charAt(i)=='.') {chkcnt = chkcnt+1}
        }

        if ((chkcnt == 2) || (chkcnt == 3)) {
            return true;
        }else {
            return false;
        }
    }else { return false; }
}
/********************************************************************************************************
/********************************************************************************************************

    History

********************************************************************************************************
********************************************************************************************************/

/*
 Util Function
*********************************************************/
String.prototype.trim = function(str) {
    str = this != window ? this : str;
    return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

String.prototype.escapeXml = function(str) {
    str = this != window ? this : str;
    str = str.replace(/&/g,'&amp;');
    str = str.replace(/\'/g,'&#039;');
    str = str.replace(/\"/g,'&#34;');
    str = str.replace(/</g,'&lt;');
    str = str.replace(/>/g,'&gt;');
    return str;
}


function CategoryManager() {
    this.dir = new Array;
    this.add = CategoryManager_add;
    this.getHistory = CategoryManager_getHistory;
}

function CategoryManager_add(_sId,_sTitle,_sUrl) {
    var nIndex = this.dir.length;
    this.dir[nIndex] = new Object;
    this.dir[nIndex].id = _sId;
    this.dir[nIndex].title = _sTitle;
    this.dir[nIndex].url = _sUrl;
}

/** 공인인증센터에선 이용안내와 디렉토리가 구분되어져있어서
        상위 메뉴인 이용안내를 강제로 넣어줘야함. **/
function gotoUseInfo() {
    location.href = "#";
}


function CategoryManager_getHistory() {
    var sHistory = '<ul id="history">';

    sHistory += '<li class="home"><a href="javascript:goMain();">HOME</a></li>';
    if( this.dir[0].id == "cert" ) {
        sHistory += '<li><a href="javascript:gotoUseInfo();">이용안내</a></li>';
    }
    for (var i=0; i<this.dir.length; i++) {
        var sId = this.dir[i].id;
        var sTitle = this.dir[i].title;
        var sUrl = this.dir[i].url;
        if (sTitle!="") {
            sHistory += '<li>';
            if (i<this.dir.length-1) {
                if (sUrl!="") {
                    sHistory += '<a href="'+sUrl.escapeXml()+'">';
                }
            } else {
                sHistory += '';
            }
            sHistory += sTitle.replace(/<br>/g,"");
            if (i<this.dir.length-1) {
                if (sUrl!="") {
                    sHistory += '</a>';
                }
            } else {
                sHistory += '';
            }
            sHistory += '</li>';
        }
    }
    sHistory += '</ul>';
	
	if(window.name != "index"){
    	sHistory += '<form name="frmTrans">';
		sHistory += '<input type="hidden" name="c">';
		sHistory += '<input type="hidden" name="tw">';
		sHistory += '<input type="hidden" name="lw">';
		sHistory += '<input type="hidden" name="credordgb">';
		sHistory += '<input type="hidden" name="realgb">';
		sHistory += '<input type="hidden" name="menu">';
		sHistory += '<input type="hidden" name="pmgb">';
		sHistory += '<input type="hidden" name="hty" value="hty">';
		sHistory += '<input type="hidden" name="optgb">';		
		sHistory += '</form>';
	}
	
    return sHistory;
}

/** 카테고리 정보 객체를 생성한다. **/
var kiwoomCategory = new CategoryManager();

/***************************************************************
 메뉴 구현에 필요한 전역변수 선언
*/
var a = document.URL.split("//");
var SERVER_DOMAIN = a[0]+ "//" +location.host;
var historyXML = null;

/***************************************************************
 파이어폭스 브라우저를 위한 처리.
*/
var isFireFox = false;
function getXMLHttpRequest() {
    if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        isFireFox = true;
        SERVER_DOMAIN = "";
        return new XMLHttpRequest();
    }
}

/***************************************************************
 XML 호출 시 캐쉬를 막기위해 매순간 고유한 파라미터값을 넣어준다.
*/
function getTimeStamp() {
    var localTime = new Date();
    return localTime.getTime();
}

/***************************************************************
 상위 메뉴 XML을 가져온다.
*/
function loadHistoryXML(_afterAction) {
    var request = getXMLHttpRequest();
    request.open("GET",SERVER_DOMAIN+"/kws/js/xml/"+dir[0]+".xml?temp="+getTimeStamp(),true);
    request.send(null);
    request.onreadystatechange = function() {
        if (request.readyState==4) {
            if (request.status==200) {
                historyXML = request.responseXML;
                if (_afterAction==null) {
                    setCategoryInfo();
                } else {
                    eval(_afterAction);
                }
            } else {
                if (_afterAction==null) {
                    historyXML = null;
                    writeError("historyArea","카테고리 정보 가져오기 실패");
                } else {
                    alert("오류가 발생하였습니다. 새로고침 후 다시 시도해 주십시오.");
                }
            }
        }
    }
}

/***************************************************************
 xml의 특정 자식 노드를 가져온다.
*/
function getChildNode(_node,_sChildNodeName) {
    var result = null;
    if (_node.childNodes.length > 0) {
        for (var i=0; i<_node.childNodes.length; i++) {
            if (_node.childNodes[i].tagName==_sChildNodeName) {
                result = _node.childNodes[i];
                break;
            }
        }
    }
    return result;
}

/***************************************************************
 카테고리 정보객체와 독립메뉴 카테고리 정보 객체에 정보를 셋팅한다.
*/
function setCategoryInfo() {
    var historyRoot = historyXML.getElementsByTagName("kiwoom")[0];
    var searchNode = null;
    var focusNode = null;
    if (historyRoot!=null) {
        focusNode = historyRoot.firstChild;
        if (isFireFox) focusNode = focusNode.nextSibling;
    }

    for (var i=0; i<dir.length; i++) {
        searchNode = focusNode;
        focusNode = null;
        if (searchNode!=null) {
            for (var j=0; j<searchNode.parentNode.childNodes.length; j++) {
                var sId = "";
                try {
                    sId = getChildNode(searchNode,"id").firstChild.nodeValue.trim();
                } catch(e) {}
                var sTitle = getChildNode(searchNode,"title").firstChild.nodeValue.trim();
                var sUrl = getChildNode(searchNode,"url").firstChild.nodeValue.trim();

                if (i<dir.length) {
                    if ( sId == dir[i] ) {
                        kiwoomCategory.add(sId,sTitle,sUrl);
                        focusNode = getChildNode(searchNode,"menu");
                    }
                }

                searchNode = searchNode.nextSibling;
                if (isFireFox) searchNode = searchNode.nextSibling;
                if (searchNode==null) {
                    break;
                }
            }
        }
    }
    var historyArea = document.getElementById("historyArea");
    if (historyArea) historyArea.innerHTML = kiwoomCategory.getHistory();

    var historyArea2 = document.getElementById("historyArea2");
    if (historyArea2) historyArea2.innerHTML = kiwoomCategory.getHistory();
}


/***************************************************************
 에러로그를 뿌려준다.
*/
function writeError(_sTargetID, _sErrorMsg) {
    var targetArea = document.getElementById(_sTargetID);
    if (targetArea) targetArea.innerHTML = _sErrorMsg;
}


/*
 URL에서 현재 메뉴의 Depth정보와 메뉴별 ID(디렉토리명)를 가져온다.
 상단 플래시, 좌측메뉴, 카테고리정보, 브라우저타이틀 등에서 모두 사용한다.
***************************************************************/
var sPathName = location.pathname;
var tempDir = sPathName.split("/");


var dir = new Array;

function setHistory(_depth) {
    var arrayDepth = _depth.split(",");

    for( var i=0; i<arrayDepth.length; i++ ) {
        dir[dir.length] = arrayDepth[i].trim();
    }

    loadHistoryXML();
    
    
    
}

/********************************************************************************************************
    History 끝
********************************************************************************************************/




/********************************************************************************************************
    주민번호 유효성체크
********************************************************************************************************/
/** 잘못된 주민번호 일때 false 리턴
    id0 -> 주민번호 앞 6자리
    id1 -> 주민번호 뒤 7자리 **/
function isJuno(id0, id1) {
    var id0 = String(id0);
    var id1 = String(id1);
    var id = id0+id1;
    var sum = 0;
    var digit = id.substring(12, 13);
    for (var i = 0; i<12; i++) {
        if (i<8) {
                sum += id.substring(i, i+1)*(i+2);
        } else {
                sum += id.substring(i, i+1)*(i-6);
        }
    }
    var magicDigit = (11-sum%11)%10;
    if (magicDigit == digit) {
        return true;
    } else {
        return false;
    }
}


/********************************************************************************************************
 * 종목코드 및 종목명 가져오는 function
 * @param pTargetName : target을 지정할 iframe 명
 * @param pFormName : form name
 * @param pShcodeFieldName : 종목코드 필드명
 * @param pShnameFieldName : 종목명 필드명
 * @param pKOSDAQgbFieldName : 코스닥구분 필드명
 * @param respFunc : 호출할 함수명
 * @param searchGbn : 검색 구분 ( 1 : 현물 종목 , 2:ELW 종목) ==> 차후 추가 (예. 3:프리보드종목  )
 * @param pShcode  : 비교할 값
********************************************************************************************************/
function findCodeName(pTargetName,pFormName,pShcodeFieldName,pShnameFieldName,pKOSDAQgbFieldName,respFnuc,searchGbn,pShcode){
    theForm = document.frmFindCodeName ;
    theForm.formName.value = pFormName ;
    if(!isNumCode(pShcode)){
        if(pShcode.length==6){
        	if(isNum(pShcode.substring(0,1))) {
        		theForm.codeOrNameGbn.value = "1" ;
        	}
        } else {
            theForm.codeOrNameGbn.value = "2" ;
        }
    }else{
        theForm.codeOrNameGbn.value = "1" ;
    }
    theForm.strVal.value = pShcode ;
    theForm.shcodeName.value = pShcodeFieldName ;
    theForm.shnameName.value = pShnameFieldName ;
    theForm.KOSDAQgbName.value = pKOSDAQgbFieldName ;
    theForm.respFnc.value = respFnuc ;
    theForm.searchGbn.value = searchGbn ;
    theForm.target = pTargetName ;
    theForm.action = "/jsp/kws/common/stkFindCodeName.jsp" ;
    theForm.submit() ;
    return false ;

}

/********************************************************************************************************
 * 종목코드 및 종목명 가져오는 function2
 * @param pTargetName : target을 지정할 iframe 명
 * @param pFormName : form name
 * @param pShcodeFieldName : 종목코드 필드명
 * @param pShnameFieldName : 종목명 필드명
 * @param pKOSDAQgbFieldName : 코스닥구분 필드명
 * @param pElwgbFieldName : ELW구분 필드명  -> 20090120 추가
 * @param respFunc : 호출할 함수명
 * @param searchGbn : 검색 구분 ( 1 : 현물 종목 , 2:ELW 종목) ==> 차후 추가 (예. 3:프리보드종목  )
 * @param pShcode  : 비교할 값
********************************************************************************************************/
function findCodeName2(pTargetName,pFormName,pShcodeFieldName,pShnameFieldName,pKOSDAQgbFieldName,pElwgbFieldName,respFnuc,searchGbn,pShcode){
    theForm = document.frmFindCodeName ;
    theForm.formName.value = pFormName ;
    if(!isNum(pShcode)){
        if(pShcode.length==6){
        	if(isNum(pShcode.substring(0,1))) {
        		theForm.codeOrNameGbn.value = "1" ;
        	}
        } else {
            theForm.codeOrNameGbn.value = "2" ;
        }
    }else{
        theForm.codeOrNameGbn.value = "1" ;
    }
    theForm.strVal.value = pShcode ;
    theForm.shcodeName.value = pShcodeFieldName ;
    theForm.shnameName.value = pShnameFieldName ;
    theForm.KOSDAQgbName.value = pKOSDAQgbFieldName ;
    theForm.elwgbName.value = pElwgbFieldName ;
    theForm.respFnc.value = respFnuc ;
    theForm.searchGbn.value = searchGbn ;
    theForm.target = pTargetName ;
    theForm.action = "/jsp/kws/common/stkFindCodeName2.jsp" ;
    theForm.submit() ;
    return false ;

}


/********************************************************************************************************
 * 종목코드 필드에 입력된 값이 종목코드이지 종목명인지 확인하고
 * 종목 코드일경우 6자리이면 true, 그렇지 않으면 false
 * 종목명일경우 Enter 값이 넘어 왔으면 true, 그렇지 않으면 false 를 return
 * @param obj : 이벤트 obj
 * @param shcode : 종목코드에 입력된 값
 * @return boolean
********************************************************************************************************/
function charCheck(obj,shcode){
    if (obj.keyCode < 48 || obj.keyCode > 122)
    {
        if (event.keyCode == 13){
            if(shcode.length > 0){
                if(isNumCode(shcode)){
                    if(shcode.length < 6){
                        return false;
                    }
                }
            }else{
                return false;
            }
        }else{
            return false;
        }
    }else{
       if(shcode == "" || !isNumCode(shcode) || shcode.length < 6){
           return false;
       }
    }
    return true ;
}

/********************************************************************************************************
 * 소매채권용 
 * @param obj : 이벤트 obj
 * @param shcode : 종목코드에 입력된 값
 * @return boolean
********************************************************************************************************/
function charCheckBond(obj,shcode){
    if (obj.keyCode < 48 || obj.keyCode > 105)
    {
        if (event.keyCode == 13){
            if(shcode.length > 0){
                if(isAlphaNum(shcode)){
                    if(shcode.length < 12){
                        return false;
                    }
                }
            }else{
                return false;
            }
        }else{
            return false;
        }
    }else{
       if(shcode == "" || !isAlphaNum(shcode) || shcode.length < 12){
           return false;
       }
    }
    return true ;
}


/********************************************************************************************************
 * 선물옵션 종목코드 및 종목명 가져오는 function
 * 작성자 : 김진백
 * 작성일 : 2008.07.08
 * @param pTargetName : target을 지정할 iframe 명
 * @param pFormName : form name
 * @param pShcodeFieldName : 종목코드 필드명
 * @param pShnameFieldName : 종목명 필드명
 * @param respFunc : 호출할 함수명
 * @param pShcode  : 비교할 값
********************************************************************************************************/
function foFindCodeName(pTargetName,pFormName,pShcodeFieldName,pShnameFieldName,respFnuc,pShcode){

    theForm = document.frmFoFindCodeName;
    theForm.formName.value   = pFormName;
    theForm.shcodeName.value = pShcodeFieldName;
    theForm.shnameName.value = pShnameFieldName;
    theForm.respFnc.value    = respFnuc;
    theForm.strVal.value     = pShcode;
    theForm.target           = pTargetName;
    //theForm.action = "/kws.FutOptFindCodeName.do";
    theForm.action = "/jsp/kws/common/FutOptFindCodeName.jsp";

    theForm.submit();
    return false ;

}

/********************************************************************************************************
 * 선물옵션 종목코드 필드에 입력된 값이 종목코드이지 종목명인지 확인하고
 * 종목 코드일경우 8자리이면 true, 그렇지 않으면 false
 * 종목명일경우 Enter 값이 넘어 왔으면 true, 그렇지 않으면 false 를 return
 * 작성자 : 김진백
 * 작성일 : 2008.07.08
 * @param obj : 이벤트 obj
 * @param shcode : 종목코드에 입력된 값
 * @return boolean
********************************************************************************************************/
function foCharCheck(obj,shcode){

    if (obj.keyCode < 48 || obj.keyCode > 105)
    {
        if (event.keyCode == 13){
            if(shcode.length > 0){
                if(shcode.length < 8){
                    return false;
                }
            }else{
                return false;
            }
        } else {
            return false;
        }
    }
    if(shcode == "" || shcode.length < 8){
        return false;
    }
    return true ;
}

/********************************************************************************************************
 * 숫자만 받을 수 있도록 구성된 FUNCTION
 * input box - onKeyPress="onlyNumber(event)
 * 숫자가 아니면  return
 * 작성자 : 김도훈
 * 작성일 : 2008.07.12
 * @param obj : 이벤트 obj
********************************************************************************************************/
function onlyNumber(event){
	
	var KeyEventType = event.type.toLowerCase();
	var KeyCodeNum   = event.keyCode;

	var strChar = String.fromCharCode(KeyCodeNum);
	
	if(event.keyCode == 32){
		if (event.srcElement.value.length != 0){
			event.returnValue = false;                                                                                                   
			return;                                                                                                                      
		}                                                                                                                              
    }else if(!(strChar>="0"&&strChar<="9")){
		
		event.returnValue = false; return;                                                                                             
	}
}

/********************************************************************************************************
   newConfirm (confirm창 수정 - 버튼이름과 버튼 포커스 변경)
********************************************************************************************************/
/**
사용예 > newConfirm("착오주문 방지 경고창",wnmsg,1,1,0);
newConfirm을 사용하려면 confirm.js를 반드시 해당 wfm에 vbscript로 포함해야 한다.
confirm.js include예 >
<script src="/js/confirm.js" type="text/vbscript"></script>
**/
function newConfirm(title,mess,icon,defbut,mods) {
IE4 = document.all;
   if (IE4) {
      icon = (icon==0) ? 0 : 2;
      defbut = (defbut==0) ? 0 : 1;
      retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
      retVal = (retVal==6);
   }
   else {
      retVal = confirm(mess);
   }
   return retVal;
}

