///////////////////     공통적으로 쓰는 <SCRIPT>입니다.     ///////////////////
// ActiveX 모두 설치 
function installActivexAll(url)
{
	var str = ''
	
	str += '<object id = "regOCX" classid="clsid:B5383EA3-8717-4D94-9FC0-9E6CE05D050B" width="" height="" CODEBASE="/cab/KEDACTIVEX.cab#version=1,0,1,2">'
	str += '<PARAM NAME="_targetURL" VALUE="'+url+'/cab"></PARAM>'
	str += '<PARAM NAME="_verfile" VALUE="ocxver.ini"></PARAM>'
	str += '<PARAM NAME="_files" VALUE="zBar.ocx;zBarEx.ocx;zLine.ocx;zLineEx.ocx;zPie.ocx;zTrust.ocx;IEPrint.ocx;zSearch.ocx;"></PARAM>'
	str += '</object>'

	document.write(str);
}
//검색엔진의 값 넘겨주기
function searchDate(val){
	document.all.listDate.action = '';
	document.all.listDate.target = '';
	document.all.listDate.method = 'post';
	document.all.listDate.submit();  
}

// 재무제표 nbsp 처리
function parsingNBSP(val){
	val = val.replace(/\s/g, "&nbsp;");
	val = val.replace("(*)", "");
	document.write(val);
}
// 재무제표 nbsp 처리
function parsingNBSP1(val){
	val = val.replace("(*)", "");
	document.write(val);
}

// 탭 버튼 세션 처리
function submittabSession(url)
{


	document.form_tabSession2.action = '/TabSession.do';
	document.form_tabSession2.method = 'post';
	document.form_tabSession2.submit();

	document.form_tabSession1.action = url;
	document.form_tabSession1.method = 'post';
	document.form_tabSession1.submit();  

	

}
//신청서 처리
function isNumeric(s)
{
	for(i=0;i<s.length;i++){
		if(s.charAt(i)< '0' || s.charAt(i)> '9'){
			return true;
		}
	}
}
function makeCode(){
	var f = document.form1;
	var iINST_CLS = f.iINST_CLS.value;
	var iFIN_PRIM_INFO = f.iFIN_PRIM_INFO.value;
	var iUSE_FORM = f.iUSE_FORM.value;
	var iENP_SZE = f.iENP_SZE.value;
	var code="",code1="",code2="";
	if(iINST_CLS=="10" || iINST_CLS=="21" || iINST_CLS=="22" || iINST_CLS=="23" || iINST_CLS=="24" || iINST_CLS=="26" || iINST_CLS=="27"){
		code1="01";
		if(iINST_CLS=="10"){
			if(iFIN_PRIM_INFO=="01"){
				code2="02";
			}else{
				code2="01"
			}
		}else{
			if(iUSE_FORM=="15"){
				if(iFIN_PRIM_INFO=="01"){
					code2="04";
				}else{
					code2="03";
				}
			}else{
				code2="05";
			}
		}
	}else{
		code1="02";
		if(iENP_SZE=="1"){
			if(iFIN_PRIM_INFO=="01"){
				code2="02";
			}else{
				code2="01";
			}
		}else{
			if(iUSE_FORM=="15"){
				if(iFIN_PRIM_INFO=="01"){
					code2="04";
				}else{
					code2="03";
				}
			}else{
				code2="05";
			}
		}
	}
	code = code2 + code1;
	return code;
}
function chkNumeric(obj)
{
	for(i=0;i<obj.value.length;i++){
		if(obj.value.charAt(i)< '0' || obj.value.charAt(i)> '9'){
			alert("숫자형식이 아닙니다.");
			obj.value="";
			return;
		}
	}
}
function setValue(obj){
	obj.select();
}
function setValueDate(obj){
	var str = obj.value;
	obj.value = str.replace(/-/g,"");
	obj.select();
}
function valueCheck(){
	var f = document.form1;
	if(f.iENP_SZE.value=="0"){
		alert("기업규모를 선택하세요.");
		f.iENP_SZE.focus();
		return true;
	}
	if(f.iINST_CLS.value=="00"){
		alert("기관구분을 선택하세요.");
		f.iINST_CLS.focus();
		return true;
	}
	if(f.iUSE_FORM.value=="00"){
		alert("이용형태를 선택하세요.");
		f.iUSE_FORM.focus();
		return true;
	}
	if(f.iFIN_PRIM_INFO.value=="00"){
		alert("이용정보를 선택하세요.");
		f.iFIN_PRIM_INFO.focus();
		return true;
	}
	if(f.iENP_SZE.value=="1"){
		if(f.iINST_CLS.value=="30" || f.iINST_CLS.value=="25" || f.iINST_CLS.value=="28" || f.iINST_CLS.value=="50" || f.iINST_CLS.value=="60" || f.iINST_CLS.value=="70"){
			if(f.iUSE_FORM.value=="17"){
				alert("대기업을 선택시 종량제를 선택할 수 없습니다.");
				f.iUSE_FORM.focus();
				return true;
			}
		}
	}
	if(f.iINST_CLS.value=="10"){
		if(f.iUSE_FORM.value=="17"){
			alert("제1금융권(은행) 선택시 종량제를 선택할 수 없습니다.");
			f.iUSE_FORM.focus();
			return true;
		}
	}
	if(f.iFIN_PRIM_INFO.value=="01"){
		if(f.iUSE_FORM.value=="17"){
			alert("기본정보 선택시 종량제를 선택할 수 없습니다.");
			f.iUSE_FORM.focus();
			return true;
		}
	}
	return false;
}
function validID( str )
{
	/* check whether input value is included space or not */
	if( str == ""){
		alert("아이디를 입력하세요.");
		return true;
	}
	
	var retVal = checkSpace( str );
		
	if( retVal != "" ) {
		alert("아이디는 빈 공간 없이 연속된 영문 대문자와 숫자만 사용할 수 있습니다.");
		return true;
	} 
	if( str.charAt(0) == '_') {
		alert("아이디의 첫문자는 '_'로 시작할수 없습니다.");
		return true;
	}

	/* checkFormat */
	var isID = /^[A-Z0-9]{6,8}$/;
	if( !isID.test(str) ) {
		alert("아이디는 6~8자의 영문 대문자와 숫자만 사용할 수 있습니다.");
		return true;
	}
	return false;
}
function checkSpace( str )
{
	if(str.search(/\s/) != -1){
		return 1;
	}else{
		return "";
	}
}
function isFocus(from_obj,to_obj,leng){
	 if ((event.keyCode >= 33) && (event.keyCode <= 40) || (event.keyCode == 9)){return;}
	 if(from_obj.value.length > leng-1){
		 to_obj.focus();
	 }
}
function validEMAIL( obj )
{
	var str = obj.value;
	/*
	if(str == ""){
		alert("이메일 주소를 입력하세요.");
		obj.focus();
		return;
	} */		
	/* checkFormat */
	if(str!=""){
		var isEmail = /[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+(\.[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+)*@[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+(\.[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+)*/;
		if( !isEmail.test(str) ) {
			alert("이메일 형식이 잘못 되었습니다.");
			obj.value="";
			obj.focus();
			return;
		}
		if( str.length > 35 ) {
			alert("이메일 주소는 35자까지 유효합니다.");
			obj.value="";
			obj.focus();
			return;
		}
	}
}
function convertVALUE(obj){
	var str = obj.value;
	var chg="";
	var s=""; /**/
	if(str!=""){
		for(i=0;i<str.length;i++){
			if(str.charCodeAt(i) >=97 && str.charCodeAt(i) <=122 ){
				chg = String.fromCharCode(str.charCodeAt(i)-32);
			}else{
				chg	= str.charAt(i);
			}
			s = s + chg;						
		}
		obj.value=s;
	}
}
function setEng(obj){
	obj.style.imeMode="inactive";
}
function setKor(obj){
	obj.style.imeMode="active";
}
function strLen(value,len){
	if(value.length>len){
		return true;//지정길이 이상
	}else{
		return false;//지정길이 이하
	}
}
function isValidPhone(obj){
	if(obj.value==""){return;}
    var format = /\d{2,3}-\d{3,4}-\d{4}/;
    if(!format.test(obj.value)){
		alert("올바르지 않은 번호입니다.");
		obj.value="";		
		obj.focus();
	}
}
function isValidHP(obj) {
	if(obj.value==""){return;}
    var format = /01[0136789]-\d{3,4}-\d{4}/;
    if(!format.test(obj.value)){
		alert("올바르지 않은 번호입니다.");
		obj.value="";
		obj.focus();
	}
}
function setPOST(obj){
	var t=obj.value;
	var f1;
	var f2;
	var c;
	var isChk = /\d{3}[-]\d{3}/;
	if(t.length >7){
		alert("우편번호 형식이 올바르지 않습니다.");
		obj.value="";
		obj.focus();			
		return;
	}
	if(t.length > 0 && !isChk.test(t)){
		if(isNumeric(t)){
			alert("우편번호 형식은 숫자로만 입력이 가능합니다.");
			obj.value="";			
			obj.focus();		
			return;
		}
		if(strLen(t,7)){
			alert("우편번호 형식이 올바르지 않습니다.");
			obj.value="";
			obj.focus();			
			return;
		}				
		f1=t.substr(0,3);
		f2=t.substr(3,3);
		c=f1+"-"+f2;					
		obj.value=c;
	}
}
function setDate(obj){
	var t = obj.value;
	var tYear;
	var tMonth;
	var tDay;
	var tDate = t;
	var isDate = /\d{4}[-]\d{2}[-]\d{2}/;
	if(t.length >10){
		alert("날짜형식이 올바르지 않습니다.");
		obj.value="";
		getToday(obj);
		obj.focus();			
		return;
	}
	if(t.length > 0 && !isDate.test(t)){
		if(isNumeric(t)){
			alert("날짜형식은 숫자로만 입력이 가능합니다.");
			obj.value="";
			getToday(obj);
			obj.focus();		
			return;
		}
		if(strLen(t,8)){
			alert("날짜형식이 올바르지 않습니다.");
			obj.value="";
			getToday(obj);
			obj.focus();			
			return;
		}				
		tYear=t.substr(0,4);
		tMonth=t.substr(4,2);
		tDay=t.substr(6,2);
		tDate=tYear+"-"+tMonth+"-"+tDay;								
		obj.value=tDate;
	}				
}

function setJN(obj){
	var t=obj.value;
	var f1;
	var f2;
	var c;
	var isChk = /\d{6}[-]\d{7}/;	
	if(t.length > 0 && !isChk.test(t)){
		if(isNumeric(t)){
			alert("주민번호 형식은 숫자로만 입력이 가능합니다.");
			obj.value="";			
			obj.focus();		
			return;
		}
		if(strLen(t,13)){
			alert("주민번호 형식이 올바르지 않습니다.");
			obj.value="";
			obj.focus();			
			return;
		}				
		f1=t.substr(0,6);
		f2=t.substr(6,7);
		c=f1+"-"+f2;								
		obj.value=c;
		if(obj.value.length != 14){
			alert("주민번호 형식이 올바르지 않습니다.");
			obj.value="";
			obj.focus();			
			return;
		}
	} 	
}
function isResId(id1, id2){
	a = Array(6);
	b = Array(7);   
	for (var i=0; i<6; i++){
		a[i] = parseInt(id1.charAt(i));	  } 
	for (var j=0; j<7; j++){
		b[j] = parseInt(id2.charAt(j));}	   
	ssntot = (a[0]*2)+(a[1]*3)+(a[2]*4)+(a[3]*5)+(a[4]*6)+(a[5]*7) + (b[0]*8)+(b[1]*9)+(b[2]*2)+(b[3]*3)+(b[4]*4)+(b[5]*5);
	ssnave = 11 - (ssntot%11);	   
	
	if (ssnave == 11){
		ssnave = 1;
	}else if(ssnave == 10){ ssnave = 0;	}   
	
	if (b[6] == ssnave) {
		return true;
	}else {
		return false;}
}
function setJP(obj){
	var t=obj.value;
	var f1;
	var f2;
	var c;
	var isChk = /\d{6}[-]\d{7}/;  	
	if(t.length > 0 && !isChk.test(t)){
		if(isNumeric(t)){
			alert("법인번호 형식은 숫자로만 입력이 가능합니다.");
			obj.value="";			
			obj.focus();		
			return;
		}
		if(strLen(t,13)){
			alert("법인번호 형식이 올바르지 않습니다.");
			obj.value="";
			obj.focus();			
			return;
		}				
		f1=t.substr(0,6);
		f2=t.substr(6,7);
		c=f1+"-"+f2;								
		obj.value=c;

		if(obj.value.length != 14){
			alert("법인번호 형식이 올바르지 않습니다.");
			obj.value="";
			obj.focus();			
			return;
		}
	}
	
}
function getToday(obj){
	if(obj.value==""){
		var now = new Date();
		var year = now.getFullYear ();
		var month= now.getMonth()+1;
		var day = now.getDate();
		if(month < 10){month="0"+month;}
		if(day < 10){day="0"+day;}
		var cal = year+"-"+month+"-"+day;
		obj.value = cal;
	}
}
function vaildPWD(obj){
	var str = obj.value;
	if(str==""){
		alert("비밀번호를 입력하세요.");
		obj.value="";
		obj.focus();
		return true;
	}
	/*
	var is = /^[A-Za-z0-9]{6,8}$/;
	if( !is.test(str) ) {
		alert("비밀번호 6~8자의 영문자와 숫자만 사용할 수 있습니다.");
		obj.value="";
		obj.focus();
		return true;
	} 
	*/
	return false;
}
function setUrl(iKed_cd){
	document.location.href = '/ctfcco_ba010g.do?iKed_cd='+iKed_cd;
}
//뉴스 쪽에서 쓰이는 데이트 타입
function parsingDatetime(datetime){
	date = datetime.substring(8,datetime.length);
	datetime = datetime.substring(0,8);
	if ( datetime == "" ){
		document.write("");
		return;
	}

	document.write(datetime.substring(0,4));
	document.write("-");
	document.write(datetime.substring(4,6));
	document.write("-");
	document.write(datetime.substring(6,9));
	document.write(" "+date);

}

function bubinno(val){
		//alert(val);
		//var str_no ;
		var str_len = val.length;
		var str = val ;
		//str_no = str.replace('-','');
		
		if (str_len == 13 ){
			no_ck = val.substring(0, 1) * 1;
			no_ck = no_ck + val.substring( 1, 2) * 2;
			no_ck = no_ck + val.substring( 2, 3) * 1;
			no_ck = no_ck + val.substring( 3, 4) * 2;
			no_ck = no_ck + val.substring( 4, 5) * 1;
			no_ck = no_ck + val.substring( 5, 6) * 2;
			no_ck = no_ck + val.substring( 6, 7) * 1;
			no_ck = no_ck + val.substring( 7, 8) * 2;
			no_ck = no_ck + val.substring( 8, 9) * 1;
			no_ck = no_ck + val.substring( 9, 10) * 2;
			no_ck = no_ck + val.substring( 10, 11) * 1;
			no_list = no_ck + val.substring( 11, 12) * 2;
			no_ck_no = no_list / 10;
			ck_no = "'"+no_ck_no+"'";
			namuji = ck_no.substring(3,4);
			no = 10 - namuji; 
			if (no > 9 ){
				no = 0;
			}
			if (no == val.substring(12, 13)){
				return true;
			}else{
				return false;

			}
		}else{
			return false ;
		}
	}

	function check_busino(vencod) {
	 if (vencod.length != 10)
	 {
		 return false;
	 }
	 var sum = 0;
	 var getlist =new Array(10);
	 var chkvalue =new Array("1","3","7","1","3","7","1","3","5");
	 for(var i=0; i<10; i++) { getlist[i] = vencod.substring(i, i+1); }
	 for(var i=0; i<9; i++) { sum += getlist[i]*chkvalue[i]; }
	 sum = sum + parseInt((getlist[8]*5)/10);
	 sidliy = sum % 10;
	 sidchk = 0;
	 if(sidliy != 0) 
	 { sidchk = 10 - sidliy; }
	 else 
	 { sidchk = 0; }
	 if(sidchk != getlist[9]) 
	 { return false; }
	 return true;
	}
	
//////////////////////////////처리상태표시////////////////////////////////////////
	// 처리중 프레임
	var _FrameWait = null;
	
	/**
	 * 처리중 상태이미지 표시
	 *
	 * param  : flag - 표시유무
	 */
	function cu_openRunning(flag) {
	
		// FrameWait 가 존재하는지 확인해서 없으면 생성
		if (document.getElementById('__FrameWaitIframe__')==null && flag) {
		  	var currentW, currentH;
			if(parent != null && parent.name == 'fContent') {
				currentW = document.body.clientWidth; // 현재 프레임의 너비(스크롤 영역 제외)
				currentH = document.body.clientHeight; // 현재 프레임의 높이(스크롤 영역 제외)
			} else {
				currentW = document.body.clientWidth;  // 현재 프레임의 너비(스크롤 영역 제외)
				currentH = document.body.clientHeight; // 현재 프레임의 높이(스크롤 영역 제외)
			}
			
			var msgW = 250;// 처리중 메시지창 너비
			var msgH = 82;// 처리중 메시지창 높이
	
			if ( currentW < msgW ) var leftPos = 0;
			else var leftPos = currentW/2 - msgW/2;
			if ( currentH < msgH ) var topPos = 0;
			else var topPos  = currentH/2 - msgH/2 -50;
	
			var _FrameWait = document.createElement("<div id='FrameWait' style='position:absolute;left:0px;top:0px;width:341px;height:112px;padding:0px;z-index:999; visibility:hidden ;'></div>");
			document.body.insertBefore(_FrameWait);
	
			var wait = "<table border='0' cellpadding='0' cellspacing='0' style=''> "
					 + "<tr align='center' valign='middle'></tr><td>"
					 + "<IFRAME name='__FrameWaitIframe__' frameborder=0 style='position:absolute;left:"+(leftPos+125)+"px;top:"+topPos+"px;width:"+msgW+"px;height:"+msgH+"px;visibility:hidden;' src='/jsp/common/wait.jsp' /> "
					 + "</td></tr></table> ";
			_FrameWait.innerHTML = wait;
	
		}
		
		if ( flag ) {
			window.document.body.style.cursor		= "wait";
			document.all.FrameWait.style.visibility	= "visible";
			document.all.__FrameWaitIframe__.style.visibility	= "visible";
		} else{
		 	if(document.getElementById('__FrameWaitIframe__')!=null){ 
				//clearInterval( __FrameWaitIframe__.iTimerID );
				window.document.body.style.cursor		= "default";
				document.all.FrameWait.removeNode(true); // 스크롤바가 없어지지 않아서 노드 삭제
			}
		}
	}
	
	/**
	 * 처리중 상태이미지 표시
	 *
	 * param  : flag - 표시유무
	 */
	function cu_openRunning2(flag) {
	
		// FrameWait 가 존재하는지 확인해서 없으면 생성
		if (document.getElementById('__FrameWaitIframe__')==null && flag) {
		  	var currentW, currentH;
			if(parent != null && parent.name == 'fContent') {
				currentW = document.body.clientWidth; // 현재 프레임의 너비(스크롤 영역 제외)
				currentH = document.body.clientHeight; // 현재 프레임의 높이(스크롤 영역 제외)
			} else {
				currentW = document.body.clientWidth;  // 현재 프레임의 너비(스크롤 영역 제외)
				currentH = document.body.clientHeight; // 현재 프레임의 높이(스크롤 영역 제외)
			}
			
			var msgW = 250;// 처리중 메시지창 너비
			var msgH = 82;// 처리중 메시지창 높이
	
			if ( currentW < msgW ) var leftPos = 0;
			else var leftPos = currentW/2 - msgW/2 -150;
			if ( currentH < msgH ) var topPos = 0;
			else var topPos  = currentH/2 - msgH/2 -50;
	
			var _FrameWait = document.createElement("<div id='FrameWait' style='position:absolute;left:0px;top:0px;width:341px;height:112px;padding:0px;z-index:999; visibility:hidden ;'></div>");
			document.body.insertBefore(_FrameWait);
	
			var wait = "<table border='0' cellpadding='0' cellspacing='0' style=''> "
					 + "<tr align='center' valign='middle'></tr><td>"
					 + "<IFRAME name='__FrameWaitIframe__' frameborder=0 style='position:absolute;left:"+(leftPos+125)+"px;top:"+topPos+"px;width:"+msgW+"px;height:"+msgH+"px;visibility:hidden;' src='/jsp/common/wait.jsp' /> "
					 + "</td></tr></table> ";
			_FrameWait.innerHTML = wait;
	
		}
		
		if ( flag ) {
			window.document.body.style.cursor		= "wait";
			document.all.FrameWait.style.visibility	= "visible";
			document.all.__FrameWaitIframe__.style.visibility	= "visible";
		} else{
		 	if(document.getElementById('__FrameWaitIframe__')!=null){ 
				//clearInterval( __FrameWaitIframe__.iTimerID );
				window.document.body.style.cursor		= "default";
				document.all.FrameWait.removeNode(true); // ì¤í¬ë¡¤ë°ê° ìì´ì§ì§ ììì ë¸ë ì­ì 
			}
		}
	}
	
			/**
	 * 처리중 상태이미지 표시 소송정보 사용
	 *
	 * param  : flag - 표시유무
	 */
	function cu_openRunning3(flag) {
	
		// FrameWait 가 존재하는지 확인해서 없으면 생성
		if (document.getElementById('__FrameWaitIframe__')==null && flag) {
		  	var currentW, currentH;
			if(parent != null && parent.name == 'fContent') {
				currentW = document.body.clientWidth; // 현재 프레임의 너비(스크롤 영역 제외)
				currentH = document.body.clientHeight; // 현재 프레임의 높이(스크롤 영역 제외)
			} else {
				currentW = document.body.clientWidth;  // 현재 프레임의 너비(스크롤 영역 제외)
				currentH = document.body.clientHeight; // 현재 프레임의 높이(스크롤 영역 제외)
			}
			
			var msgW = 400;// 처리중 메시지창 너비
			var msgH = 160;// 처리중 메시지창 높이
	
			if ( currentW < msgW ) var leftPos = 0;
			else var leftPos = currentW/2 - msgW/2 -150;
			if ( currentH < msgH ) var topPos = 0;
			else var topPos  = currentH/2 - msgH/2 -50;
	
			var _FrameWait = document.createElement("<div id='FrameWait' style='position:absolute;left:0px;top:0px;width:341px;height:112px;padding:0px;z-index:999; visibility:hidden ;'></div>");
			document.body.insertBefore(_FrameWait);
	
			var wait = "<table border='0' cellpadding='0' cellspacing='0' style=''> "
					 + "<tr align='center' valign='middle'></tr><td>"
					 + "<IFRAME name='__FrameWaitIframe__' frameborder=0 style='position:absolute;left:"+(leftPos+125)+"px;top:"+topPos+"px;width:"+msgW+"px;height:"+msgH+"px;visibility:hidden;' src='/jsp/common/wait1.jsp' /> "
					 + "</td></tr></table> ";
			_FrameWait.innerHTML = wait;
	
		}
		
		if ( flag ) {
			window.document.body.style.cursor		= "wait";
			document.all.FrameWait.style.visibility	= "visible";
			document.all.__FrameWaitIframe__.style.visibility	= "visible";
		} else{
		 	if(document.getElementById('__FrameWaitIframe__')!=null){ 
				//clearInterval( __FrameWaitIframe__.iTimerID );
				window.document.body.style.cursor		= "default";
				document.all.FrameWait.removeNode(true); // 스크롤바가 없어지지 않아서 노드 삭제
			}
		}
	}
	