/* Internet banking session extend script */
/* Copyright : 2001.2.24 CHB IB Team	  */

if(isAlive() == true && window.name == "main"){
	if(top.cibss && top.xecure){
		if(top.xecure.isXecureControl()){
			top.xecure.CibTouchSS();
		}
	}
}

function isAlive(){
	var uname=getCookieValue("chb_username");

	if(uname.length > 0)
		return true;
	else
		return false;
}

function getUserName(){
	var uname=getCookieValue("chb_username");

	return uname;
}

function getCookieValue(cname){
	var ckstr=document.cookie;
	var cklist = ckstr.split("; ");
	var sValue = "";

	for(var n =0; n < cklist.length; n++) {
		var ck = cklist[n].split("=");
		if(ck[0] == cname && ck.length > 1){
			for(var k=1; k < ck.length; k++){
				sValue = sValue + ck[k];
				if(ck.length > (k+1)) sValue = sValue + "=";
			}
		}
	}	
	return sValue;
}

function goLogOut()
{
	open("http://chbib.chb.co.kr/cib_gate.html?/servlets/ciblogout?LC=CIB", "_top")
}

// + emotion
function setLoginInfo(sdepth1)
{
	if(isAlive())
	{
		//·Î±×ÀÎ ÈÄ
		var loginbg;
		var nUserName = getUserName();
		if(sdepth1.length == 0 || sdepth1 == null)
			sdepth1 = "b2c";

		document.write("<table cellpadding='0' cellspacing='0' border='0' width='157' class='log_bg' >");
		document.write("<tr><td height='18' class='log_txt'>" + nUserName + "´Ô È¯¿µÇÕ´Ï´Ù.</td></tr>");
		document.write("<tr valign='top'>");
		document.write("	<td height='24' align='center'><a href='JavaScript:goLogOut()'><img src='/kor/images/btn_logout_" + sdepth1 + ".gif' width='151' height='21' alt='logout' border='0'></a></td>");
		document.write("</tr></table>");
	}
	else
	{
		//·Î±×ÀÎ Àü
		document.write("<table cellpadding='0' cellspacing='0' border='0' width='157'>");
		document.write("<tr><td height='1' bgcolor='#F6F5F1'></td></tr>");
		document.write("</table>");

	}
}




/***********************************************************************************
  coding
/***********************************************************************************/

/* PassWord Çü½Ä¿¡ ¸Â´ÂÁö Ã¼Å©ÇÕ´Ï´Ù. */
String.prototype.isPW = function() {
	if( this.search(/^[A-Za-z0-9_\-\!@#]{4,8}$/) < 0 || this.trim()=="" ) return false;
	else return true;
}

 /**  ¸µÅ©½Ã »ý±â´Â Á¡¼±¶óÀÎ ¾ø¾Ö±â **/
function allblur() {
    for (i = 0; i < document.links.length; i++)
       document.links[i].onfocus = document.links[i].blur;
}

/***********************************************************************************/
/***********************************************************************************/
/**  ·¹ÀÌ¾î show,hide ¸ðµâ 
      layer name ºÎ¿©½Ã  layer ¶ó´Â ³×ÀÓÀº ÁÖÁö ¾Ê´Â´Ù. (Netscape 6 ÀÌ»ó)
**/

function LayerSH(LayerName,Status) 
{

    if (navigator.appName == "Netscape")
    {
		LayerN = document.getElementById(LayerName).style;
		if (Status == 'show') LayerN.visibility = 'visible';
		else if (Status == 'hide') LayerN.visibility = 'hidden';
    }	
    else
    {
		LayerN = document.all[LayerName].style;
		if (Status == 'show') LayerN.visibility = 'visible';
		else if (Status == 'hide') LayerN.visibility = 'hidden';
	}
}



// title
//document.title="";



/**********************************************************************************
	openwindow(URL, Å¸ÄÏ¸í, features)
***********************************************************************************/
function openwindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}


/**********************************************************************************
	popupwindow (½ºÅ©·Ñ¹Ù no)
***********************************************************************************/
function popwindow(pop,width,height)
{
	var url = pop;
	var wd = 600;
	var he = 300;
	
	window.open(url,"","toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ";");
}

/**********************************************************************************
	popupwindow 02(½ºÅ©·Ñ¹Ù yes)
***********************************************************************************/
function popwindow02(pop)
{
	var url = pop;
	var wd = 764;
	var he = 650;
	
	window.open(url,"","toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ";");
}


/**********************************************************************************
	popupwindow01(½ºÅ©·Ñ¹Ù yes)
***********************************************************************************/

function popwindow01(pop,width,height)
{
	var url = pop;  
	var wd = width;
	var he = height;
	
	window.open(url,"","toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ";");
}	


/**********************************************************************************
	·¹ÀÌ¾î ¹Ù²ã ¶ç¿ì±â
***********************************************************************************/


function fview(width,height) {
	var wd = width;
	var he = height;

	f_hid.style.display = "none";
	f_view.style.display = "";
	this.resizeTo(wd,he);
}

function fhide() {
	f_view.style.display = "none";
	f_hid.style.display = "";
}
  
	
/**********************************************************************************
	Layer Show Hide
***********************************************************************************/
	
	function LayerSH(LayerName,Status) {
		ns4 = (document.layers)?true:false
		ie4 = (document.all)?true:false
	    
		if (ns4) {
			LayerN = document.layers[LayerName]
			if (Status == 'show') LayerN.visibility = 'show';
			if (Status == 'hide') LayerN.visibility = 'hidden';
		}
		if (ie4) {
			LayerN = document.all[LayerName].style
			if (Status == 'show') {
			LayerN.visibility = 'visible';
			LayerN.display = 'block';
			}
			if (Status == 'hide') {
			LayerN.visibility = 'hidden';
			LayerN.display = 'none';
			}
		}
	}
	
	
		
/**********************************************************************************
	Image Roll Over
***********************************************************************************/
	
	function preload(imgObj,imgSrc) {
		if (document.images) {
			eval(imgObj+' = new Image()')
			eval(imgObj+'.src = "'+imgSrc+'"')
		}
	}
	function imgChg(imgName,imgObj) {
		if (document.images) {
			document.images[imgName].src = eval(imgObj+".src")
		}
	}
	
	
	ns4 = (document.layers)?true:false
	ie4 = (document.all)?true:false	
	
	
  
/************************************************************************
//for eTG
/***********************************************************************************/  
  


/*+*****************************************popup******************************************/
function pop(pop,width,height,flag)
{
	var url = pop;
	var wd = width;
	var he = height;
    
    if (flag == "0" )
    {  window.open(url,"","toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ";");  }
    else 
    {  window.open(url,"","toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ";");  }
}

function pop2(pop,winname,width,height,flag)
{
	var url = pop;
	var wd = width;
	var he = height;
    
    if (flag == "0" )
    { window.open(url,winname,"toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ";");  }
    else 
    { window.open(url,winname,"toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ";");  }
}


function popZipCode(s1Depth, opener_z1, opener_z2, opener_addr1)
{
	pop2("/common/pop_zipcode.asp?s1Depth=" + s1Depth + "&opener_z1=" + opener_z1 + "&opener_z2=" + opener_z2 + "&opener_addr1=" + opener_addr1,"zipwin",480,306,0);
}

/*+***************************************±Û¾²±â ¹Ì¸®º¸±â***********************************/

function prevPop(isHTML, objTextarea)
{
	var win = window.open("","","toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=800,height=600;"); 
	var contents = objTextarea.innerText;

	if(isHTML=="N" || isHTML=="No") {
		contents = contents.replace(/(<)/g,"&lt;");
		contents = contents.replace(/\n/g,"<br>");
	}
	win.document.write("<HTML><HEAD><TITLE>¹Ì¸®º¸±â</TITLE></HEAD><BODY>\n");
	win.document.write(contents);
	win.document.write("</BODY></HTML>");
}

function preview(objFlag, objContents) {
	var chk='';

	for(var i=0;i<objFlag.length;i++) {
		if(objFlag[i].checked) {
			chk=objFlag[i].value;
			break;
		}
	}

	prevPop(chk,objContents);
}


/*+***************************************°Ë»ö ÀÚµ¿¿Ï¼º***********************************/

function makeSearch(searchFieldValue, keywordValue)
{
	if(typeof(document.all['sSearchField']) =="object" && typeof(document.all['sKeyword'])=="object")
	{
		
		var lstSearch = document.all['sSearchField'];
		var txtKeyword = document.all['sKeyword'];

		setDefaultOption(lstSearch,searchFieldValue);
		txtKeyword.value = keywordValue;

	}

}
 //°Ë»öÇ×¸ñÀÇ ¼¿·ºÆ®°´Ã¼°¡ "Ç×¸ñ¼±ÅÃ"ÀÏ °æ¿ì return false
function chkSearckLst(objSearchLst){
		if(objSearchLst.options[objSearchLst.selectedIndex].value == ""){
			alert('°Ë»ö Ç×¸ñÀ» ¼±ÅÃÇØÁÖ¼¼¿ä');
			return false;
		}
		return true;
}

function chkSearckKeyPress(objSearchLst){
	if(event.keyCode ==13){ 
		if(chkSearckLst(objSearchLst))
			return true;
		else
			return false;
	}
}



function CheckStr(strOriginal, strFind, strChange){
	var position, strOri_Length;
	position = strOriginal.indexOf(strFind);  
	
	while (position != -1){
	  strOriginal = strOriginal.replace(strFind, strChange);
	  position    = strOriginal.indexOf(strFind);
	}
  
	strOri_Length = strOriginal.length;
	return strOri_Length;
}

/********************************** Select Option ***************************************
		SelectÀÇ OptionÀ» °Ë»öÇÏ¿© Ã£´Â°ª°ú °°Àº ÀÎµ¦½º¸¦ ¼±ÅÃÇÑ´Ù.*/
function setDefaultOption(objSelect, strValue){

	if(strValue.length > 0 | typeof(objSelect) == "object" | typeof(objSelect.options.length) == "number")
	{
		
		for(i=0;i<objSelect.options.length;i++)
		{
			if(objSelect.options[i].value == strValue)
				objSelect.selectedIndex =i;
		}
	}

}

/*******************"»èÁ¦ÇÏ½Ã°Ú½À´Ï±î" °øÅëConfirm************************/
function delConfirm()
{
	if(confirm("»èÁ¦ÈÄ¿¡´Â º¹±¸ÇÒ ¼ö ¾ø½À´Ï´Ù. Á¤¸» »èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?"))
		return true;
	else
		return false;
}


/********************************** ÀÌ¹ÌÁö ÆÇº° ***************************************
		È®ÀåÀÚ°¡ gif,jpg,bmp ÀÎÁö °Ë»çÇÏ¿© true/false ¸®ÅÏÇÑ´Ù..
		ex)
			if(!isImage(document.frmWrite.fname1)){
				alert("ÀÌ¹ÌÁö Çü½ÄÀÇ ÆÄÀÏ¸¸ ¾÷·Îµå °¡´ÉÇÕ´Ï´Ù.");
				return;
			}
		*/

function isImage(objFile){
	if(objFile.value.length > 0)
	{
		var	imageName = objFile.value.toLowerCase();
		if(imageName.lastIndexOf(".gif") == -1 && imageName.lastIndexOf(".jpg") == -1 && imageName.lastIndexOf(".bmp") == -1){ 
			return false;
		}else{
			return true;
		}
	}
		return true;
}

function submitDelFrm(sFormName, sAction)
{
	//if(confirm("»èÁ¦ÈÄ¿¡´Â º¹±¸ÇÒ ¼ö ¾ø½À´Ï´Ù. Á¤¸» »èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?"))
	if(confirm("Á¤¸»·Î »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
		submitFrm(sFormName, sAction);
}

function submitFrm(sFormName, sAction)
{
	oFrm = eval('document.' + sFormName);
	oFrm.action = sAction;
	oFrm.submit();
}

/******************************** Value ±æÀÌ ½Ç½Ã°£ °Ë»ç *******************************
	ex) <textarea name=txtContents onKeyUp="chkLenAlert(this,200)">
*/

function chkLenAlert(objContent,maxLength){
	if(objContent.value.length > maxLength ){
		alert(maxLength + 'ÀÚ ±îÁö¸¸ °¡´ÉÇÕ´Ï´Ù');
		objContent.value=objContent.value.substr(0,maxLength);
		objContent.focus();
	}
}

/******************************** Ã·ºÎÀÚ·á ±Û¾²±â¸·±â *******************************
	ex) <input type="file" style="ime-mode:disabled;" onKeyPress="keyLock();">
*/
function keyLock() {
	if(event.keyCode != null)
		event.returnValue=false;
}



var isSub = 0;

function setLeftMenu()
{
	if(typeof(document.all.menu_a) != "object")
		return;

	var sPath = document.URL;
	if(sPath.indexOf("?") > 0)
		sPath = sPath.substring(0, sPath.indexOf("?"));

	if(sPath.indexOf("index.asp") > 0)
		sPath = sPath.substring(0, sPath.indexOf("index.asp"));

	//------------------------ sub menu ---------------------
	if(typeof(document.all.user)=="object")
	{
		
		if(typeof(document.all.user.length)=="number")
		{	
			for(i=0;i<document.all.user.length;i++)
				setSubMenu(sPath, document.all.user[i]);
		}
		else
			setSubMenu(sPath, null, document.all.user.all.menu_a);
	}

	//------------------------ sub menu ---------------------

	if(typeof(document.all.menu_a.length) == "number")
	{

		for(i=0;i<document.all.menu_a.length;i++)
		{

 			var ifclause;

			if(isSub > 0)
			{
				var m_sPath;
				m_sPath = sPath.substring(0,sPath.lastIndexOf("/")+1);
				
				ifclause = 'm_sPath.indexOf(document.all.menu_a[i].href) > -1';
			}
			else
			{
				var a_href = document.all.menu_a[i].href;
				ifclause = 'sPath == a_href';
			}
			if(eval(ifclause))
			{	

				if(document.all.menu_td[i].className != "left_M5select01")
				{
					document.all.menu_td[i].className = "left_M4select01";
					document.all.menu_td[i].onmouseover = function(){ return false } 
					document.all.menu_td[i].onmouseout = function(){ return false }	

					
				}
			}

		}
	}
	/*
	else
	{
		if(document.all.menu_a.href.indexOf(sPath) > -1)
		{
			document.all.menu_td.className = "left_M4select01";
			document.all.menu_td.onmouseover = function() {return false}
			document.all.menu_td.onmouseout = function() {return false}
		}			
	}
	*/

}


function forceLeftMenu(nMenuNum)
{
	if(typeof(document.all.menu_a) != "object")
		return;

	isSub = 0;
	var sPath = document.all.menu_a[nMenuNum - 1].href;
	if(sPath.indexOf("?") > 0)
		sPath = sPath.substring(0, sPath.indexOf("?"));

	//------------------------ sub menu ---------------------
	if(typeof(document.all.user)=="object")
	{
		
		if(typeof(document.all.user.length)=="number")
		{	
			for(i=0;i<document.all.user.length;i++)
				setSubMenu(sPath, document.all.user[i]);
		}
		else
			setSubMenu(sPath, null, document.all.user.all.menu_a);
	}
	
	//------------------------ sub menu ---------------------

	if(typeof(document.all.menu_a.length) == "number")
	{

		for(i=0;i<document.all.menu_a.length;i++)
		{

			var ifclause;
			if(isSub > 0)
			{
				var m_sPath
				m_sPath = sPath.substring(0,sPath.lastIndexOf("/")+1);
				ifclause = 'document.all.menu_a[i].href.indexOf(m_sPath) > -1';
			}
			else
			{
				var a_href = document.all.menu_a[i].href;
				ifclause = 'sPath == a_href';
			}
			if(eval(ifclause))
			{
				if(document.all.menu_td[i].className != "left_M5select01")
				{
					document.all.menu_td[i].className = "left_M4select01";
					document.all.menu_td[i].onmouseover = function(){ return false } 
					document.all.menu_td[i].onmouseout = function(){ return false }	

				//return;
				}
			}
		}
	}	
	else
	{
		if(document.all.menu_a.href.indexOf(sPath) > -1)
		{
			document.all.menu_td.className = "left_M4select01";
			document.all.menu_td.onmouseover = function() {return false}
			document.all.menu_td.onmouseout = function() {return false}
		}			
	}
	

}


function setSubMenu(m_sPath, m_oDiv)
{
	var oA = m_oDiv.all.menu_a;

	if(typeof(oA.length)=="number")
	{
		for(k=0;k<oA.length;k++)
		{
			//sub¿¡¼­ ÀÏÄ¡µÇ´Â °æ¿ì
			if(m_sPath == oA[k].href)
			{
				m_oDiv.style.display=""; //DIV ³ëÃâ
				m_oDiv.all.menu_td[k].className = "left_M5select01"; //ÇöÀç SubMenu				
				m_oDiv.all.menu_td[k].onmouseover = function(){ return false } 
				m_oDiv.all.menu_td[k].onmouseout = function(){ return false }
				isSub++;
				return;
			}
		}
	}
	else
	{
		//sub¿¡¼­ ÀÏÄ¡µÇ´Â °æ¿ì
		if(m_sPath == oA.href)
		{
			m_oDiv.style.display=""; //DIV ³ëÃâ
			m_oDiv.all.menu_td.className = "left_M5select01"; //ÇöÀç SubMenu
			m_oDiv.all.menu_td.onmouseover = function(){ return false } 
			m_oDiv.all.menu_td.onmouseout = function(){ return false }
			isSub++;
		}
	}}



//¿ÞÂÊ¸Þ´º Sub ÀÚµ¿ ÆîÄ§
function showSubDiv(aNum, myPath)
{
//	alert(aNum +'\n'+myPath)
	if(typeof(document.all.user.length) == "number")
	{
		for(k=0;k<document.all.user.length;k++)
		{

			if(typeof(document.all.user[k].all.menu_sub_a[aNum])=="object")
			{
				
				var a_href = document.all.user[k].all.menu_sub_a[aNum].href;
				if(a_href.indexOf(".asp") < 0)
				a_href = a_href + "index.asp";

				if(a_href == myPath)
				{			
					document.all.user[k].style.display="";
					return k;
				}

			}
		}
	}
	else
	{
		document.all.user.style.display="";
	}
	
}

/* 
	Left Menu¿¡¼­ 4Depth HighLight °­Á¦ ÇÒ´ç
		ex) forceDepthMenu(4, "main|sub", true|false)
		nDepthNum - highlightµÇ°ÔÇÒ menu ¹øÈ£ (À§ºÎÅÍ 1¹ø)
		sNenuType - "main" (4Depth) , "sub" (5Depth)
		isAccent - °­Á¶Ç¥½Ã("<")°¡ ºÙÀ» ¸Þ´º¸é true, ¾Æ´Ï¸é false
*/
function forceDepthMenu(nDepthNum, sMenuType)
{

	nDepthNum--;

	if(sMenuType == "main")
		document.all.menu_td[nDepthNum].className = "left_M4select01";
	else
		document.all.menu_td[nDepthNum].className = "left_M5select01";

	document.all.menu_td[nDepthNum].onmouseover = function(){ return false } 
	document.all.menu_td[nDepthNum].onmouseout = function(){ return false }	
}

// Left MenuÀÇ Sub Div °­Á¦ Open  
// nNum - Ã¹ DivºÎÅÍ 1¹ø, Div ÇÏ³ª ÀÏ¶§´Â 0
function forceSubDiv(nNum)
{
	if(typeof(document.all.user.length) == "number")
	{
		document.all.user[nNum-1].style.display="";
	}
	else
	{
		document.all.user.style.display="";
	}

}

//Flash¿¡¼­ ¸Þ´ºÀÌµ¿½Ã »ç¿ë
function goGateway(d2_name, d2, d3)
{
	if(d2 == 0 && d3 == 0)
		sGatewayUrl = "/kor/" + d2_name + "/"
	else
		sGatewayUrl = "/common/gateway.asp?s1DepthDir=" + d2_name + "&n2DepthSortNum=" + d2 + "&n3DepthSortNum=" + d3;

	location.href = sGatewayUrl;
}

//¼±ÅÃµÇ¾ú´ø ¸Þ´º ÃÊ±âÈ­
function resetDepthMenu()
{
	var oTds = document.all.menu_td;
	var nTdNum = document.all.menu_td.length;
	for(i=0;i<nTdNum;i++)
	{
		if(document.all.menu_td[i].className == "left_M4select01")		
			document.all.menu_td[i].className = "l_Menu";
		else
			document.all.menu_td[i].className = "s_Menu";
	}
}




//FAQ

	var rollFlag=0;

	function txt_roll(str)
	{
		sub_num = str.substring(str.length - 2);
		sub_str = str.substring(0, str.length -2);
	
		if (document.all[str].style.display=="")
		{
			document.all[str].style.display="none";
			rollFlag=0;
			return;
		}
		else
			{
			if(rollFlag != 0)
			{
				document.all[sub_str+rollFlag].style.display="none";
				document.all[str].style.display="";
			}
		
			document.all[str].style.display="";
			rollFlag=sub_num;
		}
		
	}
    
    
    
/* *****************************/   
	var z=1

	function quick_menu(i){
		if(document.all["quick_menu"+i].style.display==""){
			document.all["quick_menu"+i].style.display="none"
		    z=1}

	    else{
	        if(z != 0){document.all["quick_menu"+z].style.display="none"
            			document.all["quick_menu"+i].style.display=""}
     	    document.all["quick_menu"+i].style.display=""
	        z=i
	   }
	}  




/* OneSource-Multi Use °ü·Ã ÇÔ¼ö */
	function setOneSource(s1Depth)
	{
		//ÀÌ¹ÌÁö: bu01, btn_section   Å×ÀÌºíBG: inform_table
		
		if(s1Depth == 'b2c') return;

		//bu01
		if(typeof(document.all.bu01) == "object")
		{
			var img_bu01 = document.all.bu01;

			if(typeof(img_bu01.length) == "number")
			{
				for(i=0;i<img_bu01.length;i++)
				{
					img_bu01[i].src = str_replace(img_bu01[i].src, "b2c_", s1Depth + "_")
				}
			}
			else
			{
				img_bu01.src = str_replace(img_bu01.src,  "b2c_", s1Depth + "_")
			}
		}

		//btn_section
		if(typeof(document.all.btn_section) == "object")
		{
			var img_btn_section = document.all.btn_section;

			if(typeof(img_btn_section.length) == "number")
			{
				for(i=0;i<img_btn_section.length;i++)
				{
					img_btn_section[i].src = str_replace(img_btn_section[i].src, "/b2c/", "/" + s1Depth + "/")
				}
			}
			else
			{
				img_btn_section.src = str_replace(img_btn_section.src,  "/b2c/", "/" + s1Depth + "/")
			}
		}

	}


	function str_replace(str, out, add) 
	{
		if(out == add) return;
		temp = "" + str;
		while (temp.indexOf(out)>-1)
		{
			pos= temp.indexOf(out);
			temp = "" + (temp.substring(0, pos) + add + 
			temp.substring((pos + out.length), temp.length));
		}
		return temp;
	}

	function setEngSwf(n2Depth, n3Depth)
	{
		if(n3Depth == "" && n2Depth == "")
		{
		}
		else
		{
			document.all.base_flash.movie = document.all.base_flash.movie + "?oDN=" + n2Depth + "&tDN=" + n3Depth;
		}

	}
