﻿// ============================================================================
// 
// 화 일 명   : common.js 
// 기능정의   : 각 페이지마다 필요한 공통변수 정의
// 작 성 자   : 신은철
//
// ============================================================================

//var JS_HOME_URL = "http://210.204.162.8/";
//var JS_HOME_URL = "http://www.gwangjin.or.kr/";
var JS_HOME_URL = "/";

/****** 배너 링크 ********/

// Main Home
function flash_home() { document.location.href = JS_HOME_URL; }

// Description :  F5키 막기
/*
	commonFunctions.php 에 설정되어 있음.
*/

// Description :  이미지 blur
function bluring()
{
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") 
	document.body.focus();
}	
document.onfocusin=bluring;

// Description :  마우스 over, out, click시 링크를 감춤  , focus의 점선 없앰 -> 인사메지시 출력
var HideStr = "안녕하세요. 광진구시설관리공단 입니다";
function HideStatus(){
	window.status = HideStr;
	return true;
}
if (document.layers) document.captureEvents(Event.mouseover | Event.mouseout);
document.onmouseover=HideStatus;
document.onmouseout=HideStatus;

// Description :  마우스 오른쪽 버튼 금지
/*
	commonFunctions.php 에 설정되어 있음.
*/

// ************************************************************************
// Function : MM_ Functions
// Description : 이미지 관련 함수
// ************************************************************************
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
reloadPage(true);

function showhide_layer() { //v6.0
    
	var i,p,v,obj,args=showhide_layer.arguments;
	for (i=0; i<(args.length-2); i+=3) 
		if ((obj=find_Obj(args[i]))!=null) 
		{ 
			v=args[i+2];
			if (obj.style) 
			{ 
				obj=obj.style; 
				v=(v=='show')?'visible':(v=='hide')?'hidden':v; 

				obj.visibility=v; 

				<!--  window scroll에 따라 위치조절  -->
				if(window.event != null && window.event.y != null)
					obj.top = window.event.y - 13 + document.body.scrollTop;  

			}
		}
}

//************************************************************************
// Function : chgImg
// Description : 이미지 변환 스크립트
// Argument : obj - img name, url - image src
//************************************************************************
function chgImg ( obj, url )
{
	obj.filters.blendTrans.apply();
	obj.src = url;
	obj.filters.blendTrans.play(); 
}

// ************************************************************************
// Function : Resize_Frame
// Description : 프레임 화면크기 재조정(가로, 세로 확장)
// Description : 기본 Width - 590px 고정
// Argument : name - Frame name , val - Height(int, Default : 300)
// ************************************************************************
function Resize_Frame(name, val)
{
        var Frame_Body  = document.frames(name).document.body;
        var Frame_name  = document.all(name);
	    var Frame_height;
		var Frame_width = "590px";
		
		if (val == "" || val == null)
			Frame_height = "300px";
		else
			Frame_height = val + "px";

        Frame_name.style.width 
                = Frame_Body.scrollWidth + (Frame_Body.offsetWidth-Frame_Body.clientWidth);
        Frame_name.style.height 
                = Frame_Body.scrollHeight + (Frame_Body.offsetHeight-Frame_Body.clientHeight);

        if (Frame_name.style.height < Frame_height || Frame_name.style.width < Frame_width){
            Frame_name.style.width = Frame_width;       //기본 iframe 너비
            Frame_name.style.height = Frame_height;      //기본 iframe 높이
        }else{
        }
}

// ************************************************************************
// Function : Resize_Frame
// Description : 프레임 화면크기 재조정(세로 확장)
// Description : Width - 590px 혹은 지정값으로 고정, 높이 확장
// Argument : name - Frame name , val - Height(int, Default : 300) , prt_type - Print Type(Default="")
// ************************************************************************
function Resize_Frame2(name, val, prt_type)
{
        var Frame_Body  = document.frames(name).document.body;
        var Frame_name  = document.all(name);
	    var Frame_height;
		
		if (val == "" || val == null)
			Frame_width = "590px";
		else
			Frame_width = val + "px";

        if (prt_type)
        	Frame_name.style.height = Frame_Body.scrollHeight + Frame_Body.offsetHeight;
        else
        	Frame_name.style.height 
                = Frame_Body.scrollHeight + (Frame_Body.offsetHeight-Frame_Body.clientHeight) + 20;
                
        Frame_name.style.width = Frame_width;       //기본 iframe 너비
}

//************************************************************************
// Function : clearText
// Description : 디폴트 텍스트 값 여부 판단하여 DB 입력시 체크
// Argument : obj - Input name
//************************************************************************
function clearText(obj){
	if (obj.defaultValue == obj.value) 
	{
		obj.value = "";
	}
} 

//************************************************************************
// Function : checkKL
// Description : 텍스트 박스의 길이 체크, 길이가 넘으면 메세지 후 자름
// Argument : Tar - TextBox  ,  Val - int ( Default : 80 )
// Event : onKeyUp
//************************************************************************
function checkKL(Tar, Val) {
	str = Tar.value;
	byteLen = chkKor(str);
	strlen = '';

	if (Val == null || Val == '' || parseInt(Val) == 0) {
		strlen = "80";
	} else {
		strlen = Val;
	}

	if (byteLen > parseInt(strlen)){
		alert(strlen+"byte 제한을 넘아갔습니다. 문자는 제한된 길이로 자동으로 삭제됩니다.");
		
		Tar.value = checkKL_cut(str,parseInt(strlen));
		return 0;
	}

	return 1;
}

//************************************************************************
// Function : checkKL_cut
// Description : 문자열을 제한된 길이까지 byte체크해서 자름
// Argument	: str - string  ,  MAX_LEN - int
// Return : string
//************************************************************************
function checkKL_cut(str, MAX_LEN)
{
	 var sumlength=0;
	 var restr='';

	 for(var i= 0;i < str.length; i++)
	 {
		  ch = escape(str.charAt(i));        //ISO-Latin-1 문자셋으로 변경 

		  if ( MAX_LEN < (sumlength + GetCharLength(ch)) ) { break; }

		  sumlength += GetCharLength(ch);
		  restr += str.charAt(i);
	 }

	 return (restr);
}

//************************************************************************
// Function : chkKor
// Description : 입력받은 값의 length 계산시 한글을 2 Byte로 
//               영문과 숫자는 1 Byte로 처리하여 문자열의 길이를 구함
// Argument	: str - string
// Return : int (입력된 문자의 byte 길이)
//************************************************************************
function chkKor( str ) {
	var i; 
	var ch; 
	var rtnValue = 0;
	
	for (i = 0; i < str.length; i++) { 
		ch = escape(str.charAt(i));        //ISO-Latin-1 문자셋으로 변경 
		// 가 ==> %uAC00 
		// 힝 ==> %uD79D 
		// 힣 ==> %uD7A3 
		
		rtnValue = rtnValue + GetCharLength(ch);
	}

	return rtnValue; 
}

//************************************************************************
// Function : GetCharLength
// Description : 문자셋으로 변경된 문자를 비교 한글여부 확인
// Argument	: chStr - string
// Return : 2(한글) / (1)영문및숫자
//************************************************************************
function GetCharLength(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 : checkSpace
// Description : 문자열 중간에 공백이 있는지 여부 확인
// Argument : str - string
// Return : true/false(1/0)
//************************************************************************
function checkSpace( str )
{
     if(str.search(/\s/) != -1){
     	return 1;
     }
     else {
        return 0;
     }
}

//************************************************************************
// Function : evaltostr
// Description : 문자열 두자리를 수치로 치환
// Argument : str - TextBox
//			  i - int( 위치 )
// Return : int - (i)*10 + (i+1)
//************************************************************************
function evaltostr(str, i) {
	var j1 = eval(str.value.charAt(i));
	var j2 = eval(str.value.charAt(i+1));
	var j = j1*10 + j2;
	return j;
}

//************************************************************************
// Function : returnValue
// Description : 지정된 위치까지 문자열 반환
// Argument : szBuff - TextBox  ,  len - int(위치)
// Return : string
//************************************************************************
function returnValue(szBuff, len) {
	rtnValues = "";
	for(i=0; i < szBuff.length; i++) {
		if (i >= len) continue;
		else rtnValues = rtnValues + szBuff.charAt(i);
	}
	return rtnValues;
}

//************************************************************************
// Function : CheckPer
// Description : % 체크여부
// Argument : val - TextBox
// Return : true/false
//************************************************************************
function CheckPer(val) {
	szBuff = val.value;
   
   for (i=0;i<val.value.length;i++) {
		chBuff = val.value.charAt(i);

		if (chBuff=='%') {
			alert("%는 입력할 수 없습니다");
			val.value = returnValue(szBuff, i);
			val.blur();
			val.focus();
			return false;
		}
   }

   return true;
}

//************************************************************************
// Function : isNumberic
// Description : 숫자 여부 체크
// Argument : objInput - TextBox
// Return : true/false
//************************************************************************
function isNumberic(objInput) {
  var szBuff = "";
  var chBuff = '';
  var szTemp = "";
  var i = 0;

  szBuff = objInput.value;
  for(i=0; i < szBuff.length; i++) {
    chBuff = szBuff.charAt(i);

	if(chBuff < '0' || chBuff > '9') {
      alert("숫자만 입력 가능합니다!");
	  return false;
	}
  }

  return true;
}

//************************************************************************
// Function : onlyNumber
// Description : 경고메시지 없이 무조건 숫자만
// Argument : el - TextBox
// Event : onKeyUp
//************************************************************************
function onlyNumber( el ) {
	if(event.keyCode != '37' && event.keyCode != '39') {
		el.value = el.value.replace( /\D/g, '' );
	}
}

//************************************************************************
// Function : isFloatNumber
// Description : 실수 여부 체크
// Argument : objInput - TextBox
// Return : true/false
//************************************************************************
function isFloatNumber(objInput) {
  	var szBuff = "";
	var chBuff = '';
	var szTemp = 0;
	var i = 0;
	var j = 0;
	var k = 0;

	szBuff = objInput.value;
	for(i=0; i < szBuff.length; i++) {
		chBuff = szBuff.charAt(i);

		if((chBuff < '0' || chBuff > '9') && chBuff != '.') {
			alert("숫자만 입력 가능합니다!");
			objInput.value = returnValue(szBuff, i);
			return;
		}
		if (chBuff == '.') {
			szTemp = szTemp + 1;
			if (i == 0 || szTemp > 1) {
				alert("숫자만 입력 가능합니다!");
				objInput.value = returnValue(szBuff, i);
				return;
			}
		}
		if (szTemp > 0) {
			j = j + 1 ;  
			if (j > 4) {
				alert("소수점 3자리까지 입력하실수 있습니다!");
				objInput.value = returnValue(szBuff, i);
				return;
			}
		}
		else if (szTemp == 0) {
			k = k + 1;
			if (k > 11)	{
				alert("입력범위를 초과하였습니다!");
				objInput.value = returnValue(szBuff, i);
				return;
			}
		}
	}
}

//************************************************************************
// Function : inspectDate
// Description : 입력받은 스트링이 날짜로 유효한가 판정
//				 objName(8자리 스트링)
// Argument : objName - String
// Return : true/false
//************************************************************************
function inspectDate(objName) {
  var objDate;
  var nOldYear;
  var nOldMonth;
  var nOldDay;
  var nNewYear;
  var nNewMonth;
  var nNewDay;

  if(objName.length < 8) {
    return false;
  }

  nOldYear = parseInt(objName.substring(0, 4), 10);
  nOldMonth = parseInt(objName.substring(4, 6), 10) - 1;
  nOldDay = parseInt(objName.substring(6, 8), 10);
				
  objDate = new Date(nOldYear, nOldMonth, nOldDay);
				
  nNewYear = objDate.getFullYear();
  nNewMonth = objDate.getMonth();
  nNewDay = objDate.getDate();
				
  if(nOldYear == nNewYear && nOldMonth == nNewMonth && nOldDay == nNewDay) {
    return true;
  } else {
    return false;
  }
}

//************************************************************************
// Function : getNormalNumber
// Description : 금액관련 숫자를 일반적인 숫자로 변환
// Argument : strAmt - string
// Return : string
//************************************************************************
function getNormalNumber(strAmt) {
  var strResult = "";
  var strAry;
  
  strAry = strAmt.split(',');
  
  for(i=0; i < strAry.length; i++)
    strResult = strResult + strAry[i];
  
  if(strResult == "")
    return "0";
  else
    return strResult;
}

//************************************************************************
// Function : setNormalNumber
// Description : 일반적인 숫자를 금액관련 숫자로 변환(소수점 가능)
// Argument : a1 - string
// Return : string
//************************************************************************
function setNormalNumber(a1)
{
	var j = 0;
	var tmp = "";
	var tmp1 = "";
	var tmp2 = "";
	var tmp3 = "";
	var dum = 0;
	
	var source = a1 + "";
	
	
    var comma = source.indexOf(",");
    if(comma > 0)
    {
    	var len = source.length;
    	for(var k = 0; k < len; k++)
    	{
    		if(source.charAt(k) != ",")
    		tmp3 = tmp3 + source.charAt(k);
    	}
    }
    else tmp3 = source;
    
    var index = tmp3.indexOf(".");
    if(index > 0)
    {
    	tmp1 = tmp3.substring(0, index);
    	tmp2 = tmp3.substring(index);
    }
    else tmp1 = tmp3;
    
    for (var i = tmp1.length; i > 0; i--) {
    	if (i % 3 == 0){
    		tmp = tmp + ",";
    	}
   
    	tmp = tmp + tmp3.charAt(dum++);
    }
    if(tmp.charAt(0) == ",") tmp = tmp.substr(1);
    f_number = (tmp2 == "")? tmp : tmp+ tmp2; 
        
    return f_number;
}

//************************************************************************
// Function : newWindow
// Description : 팝업창
// Argument : 
//		url		: 해당 URL		String
//		name	: 해당 Window명  String(''으로 생략가능)
//		width	: 새창 너비		int
//		height	: 새창 높이		int
//		scroll	: 새창 scroll	yes/no
//		resize	: 새창 resize	yes/no
//************************************************************************
function newWindow(url, name, width, height, scroll, resize)
{
	var win= null; 
	var scleft = (screen.width-width)/2; 
	var sctop = (screen.height-height)/2; 

	var settings  = 'height='+height+','; 
		settings += 'width='+width+','; 
		settings += 'top='+sctop+','; 
		settings += 'left='+scleft+','; 
		settings += 'scrollbars='+scroll+','; 
		settings += 'resizable='+resize;
		settings += ', location=no, menu=no, toolbar=no, menubar=no, status=no, titlebar=no, toolbar=no';

	win=window.open(url,name,config=settings); 
	win.focus();
}

//************************************************************************
// Function : MM_openBrWindow
// Description : 팝업창
// Argument : 
//		theURL	: 해당 URL		String
//		winName	: 해당 Window명  String(''으로 생략가능)
//		features	: Options
//************************************************************************
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//************************************************************************
// Function : trim
// Description : 문자열의 양단 공백 제거
// Argument : tmp - string
// Return : string
//************************************************************************
function trim(tmp){
	if (tmp==null) tmp="";
	tmp = tmp.replace(/(^\s*)|(\s*$)/g, "");
	
	return tmp; 
}

//************************************************************************
// Function : isImageFile
// Description : 이미지 파일 여부 체크
// Argument : attachfile - img
// Return : true/false
//************************************************************************
function isImageFile(attachfile)
{
	if (attachfile.match(/.jpg|.jpeg|.gif|.png$/i))
		return true;
	else
		return false;
}

//************************************************************************
// Function : setCookie, getCookie
// Description : Cookie 관련 함수
// Argument : name - Cookie name(string), value - string, expiredays - day(int)
//************************************************************************
function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function getCookie( name )
{
        var nameOfCookie = name + "=";
        var x = 0;
        while ( x <= document.cookie.length )
        {
                var y = (x+nameOfCookie.length);
                if ( document.cookie.substring( x, y ) == nameOfCookie ) {
                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                                endOfCookie = document.cookie.length;
                        return unescape( document.cookie.substring( y, endOfCookie ) );
                }
                x = document.cookie.indexOf( " ", x ) + 1;
                if ( x == 0 )
                        break;
        }
        return "";
}

//************************************************************************
// Function : moveFocus
// Description : 자동 자리 이동 함수
// Argument : num - Max Length(int), fromform - TextBox, toform - Next TextBox
// Event : OnKeyUp
//************************************************************************
function moveFocus(num,fromform,toform){
	var str = fromform.value.length;
	if(str == num)
		toform.focus();
}

//************************************************************************
// Function : checkItems
// Description : 항목체크, 배열에 주어진 항목들로 구성
// Argument : thisform - form name
// Return : true/false
//************************************************************************
function checkItems( thisform, thisfieldlist ) {
	fieldlist = thisfieldlist;

	for (i = 0; i < fieldlist.length; i++)
	{
		if(eval(thisform + "." + fieldlist[i][0] + ".value.split(' ').join('')") == '') {
			alert(fieldlist[i][1] + " 항목을 반드시 입력해 주십시오.");
			eval(thisform + "." + fieldlist[i][0]).focus();
			return false;
		}
	}
	
	return true;
}

//************************************************************************
// Function : OpenSubmenu
// Description : 서브메뉴의 부메뉴[레이어] DISPLAY
// Argument : id - tr or div name
//************************************************************************
function OpenSubmenu ( id ){
	
	document.all[id+'_line'].style.display = (document.all[id+'_line'].style.display=='none'?'':'none');
	document.all[id].style.display = (document.all[id].style.display=='none'?'':'none');

	for (i=1;i<=20;i++) {
		ids = 'submenu' + (i<10?"0"+i:i);
		
		if ( ids!=id && document.all[ids+'_line'] ) document.all[ids+'_line'].style.display = 'none';
		if ( ids!=id && document.all[ids] ) document.all[ids].style.display = 'none';		
	}
}

//************************************************************************
// Function : CloseGo
// Description : 팝업창에서 opener의 링크를 연결 후 창을 닫음
// Argument : url - url address
//************************************************************************
function CloseGo( url ){
	opener.parent.location.href=url;
	self.close();
}

//************************************************************************
// Function : zoomImage
// Description : 해당이미지를 원하는 크기대로 팝업한다
// Argument : imageName - Text, width - width length, height - height length
//************************************************************************
function zoomImage(imageName,width,height) {
	var url = JS_HOME_URL+"popup/pop_view.php?img=" + imageName + "&image_width=" + width + "&image_height=" + height;
	window.open( url, 'ViewImgWin', 'directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=467,height=600' );
}

//************************************************************************
// Function : showbigimg
// Description : 해당이미지를 보여준다
// Argument : imgname - Text, title - title name
//************************************************************************
function showbigimg ( imgname, title ){
	var win = window.open ( JS_HOME_URL+"common/bigimg.html?img="+imgname, "_gy_bigimg", "width=200,height=200"  );
	win.focus();
}

//************************************************************************
// Function : number_format
// Description : 숫자형식에 ,를 넣어준다.
// Argument : num 숫자
//************************************************************************
function number_format(num) {
   var num_str = num.toString();
   var result = '';

   for(var i=0; i<num_str.length; i++) {
      var tmp = num_str.length-(i+1);
      if(i%3==0 && i!=0) result = ',' + result;
      result = num_str.charAt(tmp) + result;
   }

   return result;
}

//************************************************************************
// Function : errorMsg
// Description : 에러메시지 창
// Argument : errorCode : string
//************************************************************************
function errorMsg(errorCode) {
	if(errorCode=="mem") {
		alert("회원전용입니다.\n\n회원가입후 이용해주세요.");
	}
	
	if(errorCode=="member") {
		alert("정회원전용입니다.\n\n정회원 변경후에 이용해주세요.");
	}
		
	if(errorCode=="del") {
		alert("시샵은 탈퇴가 불가능합니다.\n\n시샵변경후에 탈퇴하시기 바랍니다.");
	}	
}


//************************************************************************
// Function : checkID
// Description : 아이디 체크 ( 첫자 영문자, 4~12자 )
// Argument : IDS - TextBox
// Return : true/false(1/0)
//************************************************************************
function checkID( IDS )
{
 	 str = IDS.value;
	 
	 /* check whether input value is included space or not  */
     if( checkSpace(str) ) {
        alert("아이디는 빈 공간 없이 입력하시기 바랍니다.");
		IDS.focus(); 
		return 0; 
     } 

	 var ch = str.charAt(0);
	 var isCH = /^[a-z]$/;
	 if ( !isCH.test(ch) ) {
		alert("아이디 첫 문자는 반드시 영문 소문자를 사용해 주세요.");
		IDS.focus(); 
		return 0;
     }

     /* checkFormat  */
     var isID = /^[a-z0-9]{4,12}$/;
     if( !isID.test(str) ) {
        alert("아이디는 4~12자의 영문 소문자와 숫자만 사용할 수 있습니다."); 
		IDS.focus(); 
		return 0; 
     }

     return 1;
}

//************************************************************************
// Function : checkREGNO
// Description : 주민번호 체크
// Argument : jc1 - TextBox(주민번호 앞 6자리)  ,
//			  jc2 - TextBox(주민번호 뒤 7자리)  ,  
// Return : true/false
//************************************************************************
function checkREGNO(jc1, jc2){
	if (jc1.value.length != 6) {
		alert("[주민등록번호] 앞 6자리를 정확히 입력하십시오.");
		jc1.focus();
		return false;
	}
	
	if (jc2.value.length != 7) {
		alert("[주민등록번호] 뒤 7자리를 정확히 입력하십시오.");
		jc2.focus();
		return false;
	}

	if (evaltostr(jc1, 2) > 12) {
		alert("[주민등록번호] 생년월일을 정확히 입력하십시오.");
		jc1.focus();
		return false;
	}
	
	if (evaltostr(jc1, 4) > 31) {
		alert("[주민등록번호] 생년월일을 정확히 입력하십시오.");
		jc1.focus();
		return false;
	}

	var jS = eval(jc2.value.charAt(0));
	
	if ((jS < 1)||(jS > 4)) {
		alert("[주민등록번호]를 다시 입력하여 주세요.");
		jc2.focus();
		return false;
	}
	
	var jumin = new String(jc1.value + jc2.value);
	
	var Sum = 0;
	
	for (var nCnt = 0; nCnt < 12; nCnt++) {
		Sum += (eval(jumin.charAt(nCnt)) * ((nCnt%8)+2));
	}
	
	var Sub = (11 - (Sum % 11)) % 10;

	if (Sub == eval(jumin.charAt(12))) {
		return true;
	} else {
		alert("[주민등록번호]를 다시 입력하여 주세요.");
		jc1.focus();
		return false;
	}
}

//************************************************************************
// Function : checkTel
// Description : 전화번호 및 휴대폰 번호 체크
// Argument : t1 - TextBox  ,  t2 - TextBox  ,  t3 - TextBox
// Return : true/false
//************************************************************************
function checkTel(t1, t2, t3, flag)
{
	if (t1.value.length < 2) {
		alert(flag + " 항목을 바르게 입력해 주세요.");
		t1.focus();
		return false;
	}

	if (t2.value.length < 3 || t2.value.length > 4) {
		alert(flag + " 항목을 바르게 입력해 주세요.");
		t2.focus();
		return false;
	}

	if (t3.value.length < 4 || t3.value.length > 4) {
		alert(flag + " 항목을 바르게 입력해 주세요.");
		t3.focus();
		return false;
	}

	return true;
}

//************************************************************************
// Function : checkPWD
// Description : 패스워드 체크 ( 연속된 비밀번호, 4~8자 )
// Argument : PWD - TextBox  ,  PWDS - TextBox
// Return : true/false
//************************************************************************
function checkPWD( PWD, PWDS )
{
     var cnt=0;
	 str = PWD.value;
	 str1 = PWDS.value;

     if( checkSpace(str) ) {
         alert("비밀번호는 빈공간 없이 연속된 영문 소문자와 숫자만 사용할 수 있습니다");
		 PWD.focus(); 
		 return 0;
     }

     /* limitLength */
     //var isPW = /^[a-z0-9_~`!@\\#\$%\^&\*()-\+=\|\[\]\{\};:'"<,>.?/]{6,12}$/;
     var isPW = /^[a-z0-9]{4,8}$/;
     if( !isPW.test(str) ) {
         alert("비밀번호는 4~8자의 영문 소문자와 숫자만 사용할 수 있습니다"); 
		 PWD.focus(); 
		 return 0; 
     }
	 
	 for( var i=0; i < str.length; ++i)
     {
         if( str.charAt(0) == str.substring( i, i+1 ) ) ++cnt;
     }  
     if( cnt == str.length ) {
         alert("보안상의 이유로 한 문자로 연속된 비밀번호는 허용하지 않습니다");
		 PWD.focus(); 
		 return 0; 
     }

     if (str != str1) {
        alert("비밀번호확인과 비밀번호가 일치하지 않습니다");
		PWD.focus(); 
		return 0;
     }

     return 1;
}

//************************************************************************
// Function : checkMAIL
// Description : 메일 체크 ( 이메일주소 )
// Argument : inputform - TextBox
// Return : true/false
//************************************************************************
function checkMAIL( inputform ) 
{ 
	var checkString = inputform.value;
    var newstr = ""; 
    var at = false; 
    var dot = false; 
    var st_length = checkString.length;
 
    if ( checkString.substring(0,1) == '@' || checkString.substring( st_length-1,st_length ) == '@'||
    		checkString.substring(0,1) == '.' || checkString.substring( st_length-1,st_length ) == '.' ) {
    		alert ("일반적인 email 주소를 입력해 주세요"); 
      		inputform.focus(); 
      		return false; 	
    }
    
    if (checkString.indexOf("@") != -1) { 
      at = true; 
    } else if (checkString.indexOf(".") != -1) { 
      dot = true; 
    } 
 
    for (var i = 0; i < checkString.length; i++) { 
        ch = checkString.substring(i, i + 1) 
        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") 
                || (ch == "@") || (ch == ".") || (ch == "_") 
                || (ch == "-") || (ch >= "0" && ch <= "9")) { 
                newstr += ch; 
                if (ch == "@") { 
                    at=true; 
                } 
                if (ch == ".") { 
                    dot=true; 
                } 
        }else {
        	// DISPLAY ERROR MESSAGE 
      		alert ("일반적인 email 주소를 입력해 주세요"); 
      		inputform.focus(); 
      		return false; 
        } 
    } 
    
    if ((at == true) && (dot == true)) { 
        return true; 
    } 
    else { 
      // DISPLAY ERROR MESSAGE 
      alert ("일반적인 email 주소를 입력해 주세요"); 
      inputform.focus(); 
      return false; 
    } 
}

//************************************************************************
// Function : id2Test
// Description : ID 및 닉네임 중복체크
// Argument : mode - string
//************************************************************************
function id2Test(mode)
{
	if(mode == 'id') {
		if(!joinusForm.id.value){
			alert("희망 ID를 입력하세요")
			joinusForm.id.focus();
			return;
		}

		if (!checkID(joinusForm.id)) return false;	

		/*
		var url = "id_check.html", arg = "" , ID = "";
		if ( document.joinusForm.id.value != "" )
			arg = "?str=" + document.joinusForm.id.value + "&mode=" + mode;
			
		*/

		var url = JS_HOME_URL + "member/member_check.php";
		var arg = "?MEM_ID=" + document.joinusForm.id.value;
		var responseText = "";
		
		if(window.XMLHttpRequest) {
	   		xmlhttp = new XMLHttpRequest();
	  	} else {
	   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  	}
	
		xmlhttp.open("GET", url + arg, "false");
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	  	xmlhttp.onreadystatechange = function() {
		   	if(xmlhttp.readyState==4 && xmlhttp.status == 200 && xmlhttp.statusText=='OK') {
			    responseText = xmlhttp.responseText;
		   	}
		}
		
		xmlhttp.send();
	
	   	if (responseText=="YES") {
	   		alert("이미 등록된 ID입니다.\n\n다시 입력하시기 바랍니다.");
	   		return;
	   	} else {
	   		//url = "http://210.204.162.1/check_web/member_check.asp";
			//arg = "?str=" + document.joinusForm.id.value + "&mode=" + mode;
	   		alert("등록되지 않은 ID입니다.\n\n이용가능합니다.");
	   		joinusForm.iddup.value = "true";
	   		return;
	   	}
	} else if(mode == 'nick') {
		if(!joinusForm.nickname.value){
			alert("닉네임을 입력하세요")
			joinusForm.nickname.focus();
			return;
		}
		var url = "id_check.html", arg = "" , ID = "";
		if ( document.joinusForm.nickname.value != "" )
			arg = "?str=" + document.joinusForm.nickname.value + "&mode=" + mode;
	}
	
	var win = window.open( url + arg, "check", "width=250,height=170,resizable= no" );
	if ( win.focus )
		win.focus();
}

//*********************************************************************************************************
// Function : Modal Window 팝업관련 함수들
// Description : 카드결제시에 필요한 팝업
// List : ieznInit(e), open_window(popup_link, popup_name, w, h, scroll), popUpClose(), window.onunload
//*********************************************************************************************************
var openPop = Array();//팝업배열생성
//
//팝업이벤트제어
function ieznInit(e){
    if(openPop.length>0){
        for(var i=0; i<openPop.length; i++) {
            if( openPop[i] && !openPop[i].closed ){
                openPop[i].focus();
            }
        }
    }else{
        if(document.addEventListener){//ns
            document.removeEventListener("focus",ieznInit, true);
        }else if(document.detachEvent){//ie
            document.detachEvent("onmousedown",ieznInit);//이벤트해지
        }
    }
}

//
//윈도우 오픈 함수
//
// popup_link 팝업링크
// popup_name 팝업이름
// w          팝업윈도우 폭
// h          팝업윈도우 높이
// scroll     팝업윈도우 스크롤 사용유무
function open_window(popup_link, popup_name, w, h, scroll) {
    //윈도우 중앙정렬
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    wp = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
    openPop[openPop.length] = window.open(popup_link, popup_name, wp);
    
    if(document.addEventListener){//ns
        document.addEventListener("focus",ieznInit,true);
    }else if(document.attachEvent){//ie
        document.attachEvent("onmousedown",ieznInit);//이벤트등록
    }
}

//
//페이지 언로드 & 리플래쉬 열린 팝업창 닫기
//
function popUpClose(){
	try {
	    if(openPop.length>0){
	        for(var i=0;i<openPop.length; i++) {
				openPop[i].self.close();
	        }
	    }
	}  catch (e){
	}
}

/**
 * 년월을 입력받아 마지막 일를 반환한다(년월)
 * param : sYM 입력스트링(YYYYMM)
 * return : String 해당월의 마지막날
 */
function lastDay(sYM)
{
	  if(sYM.length != 6)
	  {
		alert("정확한 년월을 입력하십시요."+sYM);
		return;
	  }
	  
	  if(!isDateYM(sYM))
	  {
		 return;
	  }
	 
	  daysArray = new makeArray(12);    // 배열을 생성한다.

	  for (i=1; i<8; i++)
	  {
		daysArray[i] = 30 + (i%2);
	  }
	  for (i=8; i<13; i++)
	  {
		daysArray[i] = 31 - (i%2);
	  }		
	  var sYear = sYM.substring(0, 4) * 1;
	  var sMonth	= sYM.substring(4, 6) * 1;
		
	  if (((sYear % 4 == 0) && (sYear % 100 != 0)) || (sYear % 400 == 0))
	  {
			daysArray[2] = 29;
	  }
	  else
	  {
			daysArray[2] = 28;
	  }
	  return daysArray[sMonth].toString(); 
}
 
/**
 * 날짜 여부를 확인한다.(년월)
 * param : sYM 입력스트링(YYYYMM)
 * return : Boolean true이면 날짜 범위임
 */
function isDateYM(sYM)
{
	  // 숫자 확인
	  if(!isNumber(sYM))
	  {
		alert('날짜는 숫자만 입력하십시오');
		return false;
	  }

	  // 길이 확인
	  if(sYM.length != 6)
	  {
		alert('일자를 모두 입력하십시오');
		return false;
	  }
		
	  var iYear = parseInt(sYM.substring(0,4)); //년도값을 숫자로
	  var iMonth = parseInt(trimZero(sYM.substring(4,6)));  //월을 숫자로
		
	  if((iMonth < 1) ||(iMonth >12))
	  {
		alert(iMonth+'월의 입력이 잘못 되었습니다.');
		return false;
	  }
	  return true;		
}

/**
 * 입력값이 숫자인지를 확인한다
 * param : sVal 입력스트링
 * return : Boolean True이면 숫자값
 */
function isNumber(sVal)
{
  if(sVal.length < 1)
  {
    return false;
  }

  for(i=0; i<sVal.length; i++)
  {
    iBit = parseInt(sVal.substring(i,i+1));     //문자(Char)를 숫자로 변경
    if(('0' < iBit) || ('9' > iBit)) 
    {
      //alert(i+':'+iBit+':'+'Mun');
    }
    else 
    {
      //alert((i+1)+'번째 문자는 숫자가 아닙니다.');
      return false;
    }
  }
  return true;
}

/**
 * 첫번째 Zero 값을 자른다.
 * param : sVal 입력스트링
 * return : String  Zero값을 자른 값
 */
function trimZero(sVal)
{
	  if(sVal.charAt(0) == '0')
	  {
		return sVal.substring(1,sVal.length);
	  }
	  else
	  {
		return sVal;
	  }
}

/**
 * 숫자 0으로 초기화 된 1차원 배열을 생성한다.
 * param : iSize 배열 크기
 * return : this 배열
 */
function makeArray(iSize)
{
	  this.length = iSize;

	  for (i = 1; i <= iSize; i++)
	  {
		this[i] = 0;
	  }
	  return this;
}

function GetSelectedTxt(objSelect){
		var i;
		var selectedtext;
		for(i=0;i<objSelect.options.length;i++){
				if(objSelect.options[i].selected==true){
						selectedtext= objSelect.options[i].text;
						break;
				}
		}
return selectedtext;
}

function GetSelectedValue(objSelect){
		var i;
		var selectedtext;
		for(i=0;i<objSelect.options.length;i++){
				if(objSelect.options[i].selected==true){
						selectedtext= objSelect.options[i].value;
						break;
				}
		}
return selectedtext;
}

function Display_Date( tarDate ) {
	return tarDate.substring(0,4)+"년 "+tarDate.substring(4,6)+"월 "+tarDate.substring(6,8)+"일";
}

//
//3월 1일 보안패치 대응 코멘트 출력 함수
//
function __ws__( id ) {
	document.write( id.text );
	id.id = "";	
}

window.onunload=popUpClose;//이벤트등록


function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  cookie_str = document.cookie;
  cookie_str.toString();

  pos_start  = cookie_str.indexOf(name);
  pos_start  = cookie_str.indexOf('=', pos_start);
  pos_end    = cookie_str.indexOf(';', pos_start);
  
  if (pos_end <= 0) pos_end = cookie_str.length;
  cookie_val = cookie_str.substring(pos_start + 1, pos_end);

  if (cookie_val  == "done")
    return;

  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);

}

function mbar()
{
   var selid = document.mform.item.selectedIndex;

   if (selid>=1)
   { 
		URL =document.mform.item.options[selid].value; 
		window.open(URL,"ehrclink_win")
	}		
}

    /**
    * 콤마설정.
    */
    
    function putComma(input) { 
     var num = input;
     
     if (num < 0) { 
      num *= -1; 
      var minus = true
     }else{
      var minus = false
     }
     
     var dotPos = (num+"").split(".")
     var dotU = dotPos[0]
     var dotD = dotPos[1]
     var commaFlag = dotU.length%3
    
     if(commaFlag) {
      var out = dotU.substring(0, commaFlag) 
      if (dotU.length > 3) out += ","
     }
     else var out = ""
    
     for (var i=commaFlag; i < dotU.length; i+=3) {
      out += dotU.substring(i, i+3) 
      if( i < dotU.length-3) out += ","
     }
    
     if(minus) out = "-" + out
     if(dotD) return out + "." + dotD
     else return out 
    }