﻿// Key:Value 형태의 값을 가진 문자열로부터 Key값에 해당하는 Value값을 반환한다.
function GetKeyValue(arrayString, key, splitChar) {
	var arrayItems = arrayString.split(',');
	for (var i = 0; i < arrayItems.length; i++) {
		var colItem		= arrayItems[i];
		var colName		= (colItem.split(splitChar))[0];
		var colValue	= (colItem.split(splitChar))[1];
		if (colName == key)
			return colValue;
	}
		
	return '';
}

// SELECT 태그의 하위아이템을 제거한다.
function ClearSelectItems(selectObject) {
	if (selectObject != null) {
		if (selectObject.length > 0) {
			for (var i = selectObject.length; i >= 0; i--) {
				selectObject.remove(i);
			}			
		}
	}
}

// SELECT 태그의 하위아이템을 제거한다.
function ClearSelectItemsById(selectId) {
	var selectObject	= document.getElementById(selectId);
	if (selectObject != null) {
		ClearSelectItems(selectObject);
	}
}

// ChildControl의 Value를 초기화한다.
function ResetChildControls(parent) {
	if (parent.children != null) {
		for (var i = 0; i < parent.children.length; i++) {
			ResetChildControls(parent.children[i]);
			var child	= parent.children[i];
			
			if (child.readonly) {
				continue;
			}
			
			var childTagName	= child.tagName;
			if (childTagName == 'INPUT' && (child.type == 'checkbox' || child.type == 'radio')) {
				child.checked	= false;
			}
			else if (childTagName == 'INPUT' && child.type != 'button' && child.type != 'reset') {
				child.value = '';
			}
			else if (childTagName == 'SELECT') {
				child.value	= '';
			}
			else if (childTagName == 'TEXTAREA') {
				child.value	= '';
			}
		}
	}
}

// ChildControl의 Value를 초기화한다.
function ResetChildControlsById(parentID) {
	var parent	= document.getElementById(parentID);
	if (parent != null) {
		ResetChildControls(parent);
	}
}

// ChildControl의 disabled 속성을 제어한다.
function SetEnableChildControls(parent, status) {
	if (parent.children != null) {
		for (var i = 0; i < parent.children.length; i++) {
			SetEnableChildControls(parent.children[i], status);
			var child	= parent.children[i];
			var childTagName	= child.tagName;
			if (childTagName == 'INPUT' || childTagName == 'SELECT' || childTagName == 'TEXTAREA') {
				child.disabled	= status;
			}
		}
	}
}

// ChildControl의 disabled 속성을 제어한다.
function SetEnableChildControlsById(parentID, status) {
	var parent	= document.getElementById(parentID);
	if (parent != null) {
		SetEnableChildControls(parent, status);
	}
}

// Select 태그의 아이템을 바인딩한다.
function BindSelectItems(selectObject, dataSource) {
	for (var i = 0; i < dataSource.length; i++) {
		var listItem = dataSource[i].split(':');
		selectObject.add(new Option(listItem[0], listItem[1]));
	}
}

// Select 태그의 아이템을 바인딩한다.
function BindSelectItemsById(selectId, dataSource) {
	var selectObject = document.getElementById(selectId);
	if (selectObject != null) {
		BindSelectItems(selectObject, dataSource.split(';'));
	}
}

// 모달 팝업을 생성한다. (공통모달)
function openModalDialog(wndID, title, width, height, url) {

    openProtoTypeMWnd(wndID, title, width, height, url);

}

// 모달 팝업(ProtoType Alphacube)
function openProtoTypeMWnd(wndID, title, width, height, url) {
    // Window with scrollable text
    var optionValue = {className: 'alphacube',  width: width, height: height, zIndex: 100, resizable: false, title: title, showEffect:Element.show, hideEffect: Element.hide};

    win = new Window(wndID, optionValue);

	win.setURL(url);
	win.setDestroyOnClose();
	win.showCenter(true);	
}

// 모달 팝업을 종료한다.
function closeModalWindow() {
    Windows.close(Windows.focusedWindow.getId());
}

// 선택한 체크박스의 속성을 체크박스리스트에 적용시킨다.
function selectCheckBox(sender, cbxName) {
	var checkList = document.getElementsByName(cbxName);
	var checked = sender.checked;

	if (checkList != null) {
		for (var i = 0; i < checkList.length; i++) {
			checkList[i].checked = checked;
		}
	}
}

// 글자 수 제한
function textareacheck(aro_name,ari_max) // 텍스트박스, 제한글자수
{
   var ls_str     = aro_name.value; // 이벤트가 일어난 컨트롤의 value 값
   var li_str_len = ls_str.length;  // 전체길이

   // 변수초기화
   var li_max      = ari_max; // 제한할 글자수 크기
   var li_byte     = 0;  // 한글일경우는 2 그밗에는 1을 더함
   var li_len      = 0;  // substring하기 위해서 사용
   var ls_one_char = ""; // 한글자씩 검사한다
   var ls_str2     = ""; // 글자수를 초과하면 제한할수 글자전까지만 보여준다.

   for(i=0; i< li_str_len; i++)
   {
      // 한글자추출
      ls_one_char = ls_str.charAt(i);

      // 한글이면 2를 더한다.
      if (escape(ls_one_char).length > 4)
      {
         li_byte += 2;
      }
      // 그밗의 경우는 1을 더한다.
      else
      {
         li_byte++;
      }

      // 전체 크기가 li_max를 넘지않으면
      if(li_byte <= li_max)
      {
         li_len = i + 1;
      }
   }
   
   // 전체길이를 초과하면
   if(li_byte > li_max)
   {
      alert("내용은 한글 " + li_max/2 + "자 영문 " + li_max + "자 까지만 허용됩니다.");
      ls_str2 = ls_str.substr(0, li_len);
      aro_name.value = ls_str2;
   }
   aro_name.focus();   
}

/* IE 사용시 화면 확대축소 비율 */
var ttsenv_zoomRate = 10;   /* 화면 확대축소 비율 변동폭 (% 단위) */
var ttsenv_zoommaxRate = 160;   /* 화면 확대축소시 원크기대 최대 확대비율 (% 단위) */
var ttsenv_zoomminRate = 100;   /* 화면 확대축소시 원크기대 최대 축소비율 (% 단위) */
var ttsenv_zoomDefault = 100;   /* 기본 화면 크기 */

/* NS 사용시 글자 확대축소 비율 */
var ttsenv_fontRate = 2;    /* 2pt 단위 */
var ttsenv_fontmaxRate = 19;    /* 최대 19pt */
var ttsenv_fontminRate = 9; /* 최소 9pt */
var ttsenv_fontDefault = '';    /* 디폴트 숫자 크기(CSS값) */

/* IE에도 글자 확대축소 사용여부 */
var ttsenv_mustadjustfont = true;

/* 현재 확대축소비율 */
var tts_curRate;
/* 현재 글자색상번호 */
var tts_fontcolorindex;
/* 현재 배경색상번호 */
var tts_bgcolorindex;
/* 현재글자크기 */
var tts_curfontsize;

/* 타 도메인 통제를 위한 컨트롤 프레임 변수 */
var tts_subcontrol = null;

/* 글자색 배열 */
var ttsenv_fontcolor = new Array();
ttsenv_fontcolor[0] = "";
ttsenv_fontcolor[1] = "#000000";
ttsenv_fontcolor[2] = "#ffff00";
ttsenv_fontcolor[3] = "#ffffff";
ttsenv_fontcolor[4] = "#6666ff";
ttsenv_fontcolor[5] = "#ff6666";
ttsenv_fontcolor[6] = "#ff66ff";
ttsenv_fontcolor[7] = "#66ff66";

/* 배경색 배열 */
var ttsenv_bgcolor = new Array();
ttsenv_bgcolor[0] = "";
ttsenv_bgcolor[1] = "#ffffff";
ttsenv_bgcolor[2] = "#000000";
ttsenv_bgcolor[3] = "#6666ff";
ttsenv_bgcolor[4] = "#ff6666";
ttsenv_bgcolor[5] = "#ff66ff";
ttsenv_bgcolor[6] = "#66ff66";



/* 화면 확대/축소 - 외부호출 */
/*****************************************************************************
 * f_scalescreen()
 *
 * 입력인수1 : mode = 0 현재값 유지, 1=확대, -1=축소
 * 역할 : 글자나 화면 확대 축소를 설정합니다. (ttsenv_mustabjustfont가
 *  true이거나 zoom 스타일을 지원하지 않는 경우 글자확대축소, 그 외는
 *  화면확대축소가 적용됩니다)
 *****************************************************************************/
function f_scalescreen(mode)
{
/*
	if(zoomInOut == 'in')	{ f_scalescreenInter(1)	}else
	if(zoomInOut == 'out')	{ f_scalescreenInter(-1)}else
							{ f_scalescreenInter(0)	}
*/
	f_scalescreenInter(mode)
}

function zoomHTML_IE8(zoomValue)
{
	document.body.style.zoom  = zoomValue + "%";
	applyOverflow(document.body, false);
		/*
	if (webgenStyleSheet == null)
	{
		webgenStyleSheet = document.createStyleSheet('webgen.css');
	}

	if(parseInt(zoomValue) > 100)
	{
		if (webgenStyleSheet != null)
		{
			if (webgenStyleSheet.rules.length > 0 )
			{
				webgenStyleSheet.removeRule(0);
			}
			webgenStyleSheet.addRule("html","overflow: scroll;");
		}
	} else
	{
		if (webgenStyleSheet != null)
		{
			if (webgenStyleSheet.rules.length > 0 )
			{
				webgenStyleSheet.removeRule(0);
			}
		}
	}
		*/
}

function applyOverflow(rootNode, parentApply)
{
	var nodeItem;
	var isApply = parentApply;
	for(var i=0; i<rootNode.childNodes.length; i++)
	{
		nodeItem = rootNode.childNodes[i];
		if(nodeItem.nodeType == "1")
		{
			if (!parentApply)
			{
				nodeItem.style.overflow = "hidden";
				isApply = true;
			}
			applyOverflow(rootNode.childNodes.item(i),isApply);
		}
	}
}

function zoomHTML_IE7(zoomValue)
{
	applyZoom(document.body, false, zoomValue);
}

function applyZoom(rootNode, parentZoom, zoomValue)
{
	var nodeItem;
	var isZoom = parentZoom;
	for(var i=0; i<rootNode.childNodes.length; i++)
	{
		nodeItem = rootNode.childNodes[i];
		if(nodeItem.nodeType == "1")
		{
			if (!parentZoom)
			{
				nodeItem.style.zoom = zoomValue+ "%";
				isZoom = true;
			}
			applyZoom(rootNode.childNodes.item(i),isZoom, zoomValue);
		}
	}
}

//확대 축소 함수
function zoomHTML(zoomValue)
{
	if (browser.msie)
	{
		if(browser.version == "8.0")
		{zoomHTML_IE8(zoomValue);}else
		{zoomHTML_IE7(zoomValue);}
	}
}

function f_scalescreenInter(mode)
{
	function webgen_subframesize(win,param)
	{
		if(win!=this)
		{
			if(win.f_setFontColor2!=null)
			win.f_setFontColor2(param);
		}
		if(win.frames.length>0)
		{
			var i;
			for(i=0;i<win.frames.length;i++)
			webgen_subframefont(win.frames[i],param);
		}
	}

	if((document.body.style.zoom==null)||(ttsenv_mustadjustfont==true))
	{
		/* 글자확대축소기능 사용시 */
		if(mode==1)
		{
			/* 확대 */
			if(tts_curfontsize==null)
				tts_curfontsize=ttsenv_fontminRate;
			else if(tts_curfontsize=='')
				tts_curfontsize=ttsenv_fontminRate;
			else
			{
				tts_curfontsize=tts_curfontsize-(-ttsenv_fontRate);
				if(tts_curfontsize>ttsenv_fontmaxRate)
					tts_curfontsize=ttsenv_fontmaxRate;
			}
		} else if(-1)
		{
			/* 축소 */
			if(tts_curfontsize!=null)
			{
				if(tts_curfontsize!='')
				{
					tts_curfontsize=tts_curfontsize-ttsenv_fontRate;
					if(tts_curfontsize<ttsenv_fontminRate)
												tts_curfontsize='';
				}
			}
		}
		webgen_setcookie("fontSize", tts_curfontsize, 1);
		webgen_setface();
		webgen_pushsub();
	} else
	{
		/* 화면확대축소기능 사용시 (비표준 zoom스타일 사용) */
		if(tts_curRate==null)
			tts_curRate=ttsenv_zoomDefault;
		if(tts_curRate=='')
			tts_curRate=ttsenv_zoomDefault;
		if (mode==1)
		{
			/* 확대시 */
			tts_curRate=tts_curRate-(-ttsenv_zoomRate);
			if(tts_curRate>ttsenv_zoommaxRate)
				tts_curRate=ttsenv_zoommaxRate;
		} else
		if (mode==-1)
		{
			/* 축소시 */
			tts_curRate=tts_curRate-ttsenv_zoomRate;
			if(tts_curRate<ttsenv_zoomminRate)
				tts_curRate=ttsenv_zoomminRate;
		}
		if(tts_curRate>ttsenv_zoommaxRate)
			tts_curRate = ttsenv_zoommaxRate;
		if(tts_curRate<ttsenv_zoomminRate)
			tts_curRate = ttsenv_zoomminRate;

		zoomHTML(tts_curRate);
		webgen_setcookie("zoomVal",tts_curRate, 1);
	}
}


/* 내부 함수 : 쿠키 읽기, str = 읽어들일 쿠키 키 이름, defaultValue = 기본값 */
function webgen_readcookie(str, defaultValue)
{
	var key = str + "=" ;
	var key_len = key.length ;
	var cookie_len = document.cookie.length;
	var i = 0;
	while (i < cookie_len )
	{
		var j = i + key_len;
		if ( document.cookie.substring( i, j ) == key )
		{
			var cookie_end = document.cookie.indexOf(";",j);
			if (cookie_end == -1)
			{
				cookie_end = document.cookie.length;
			}
			return document.cookie.substring(j,cookie_end );
		}
		i++;
	}
	return defaultValue;
}

/* 쿠키 설정함수, key = 쿠키 키이름, value = 쿠키 키값, term = 유효일자(보통 1로 넣음) */
function webgen_setcookie(key, value, term)
{
	var expire = new Date();
	expire.setDate( expire.getDate() + term );
	document.cookie	= key + "=" + escape( value ) + "; domain=nhic.or.kr; path=/;";
}

/* 내부 함수 : 글자크기 / 글자색 / 배경색 설정 (IE전용 화면확대축소는 여기가 아닌 f_scalescreen에서 직접 처리한다.) */
function webgen_setface()
{
	function webgen_setface_unit(tagarray,setback)
	{
		var i;
		if(tagarray!=null)
		{
			for (i=0;i<tagarray.length;i++)
			{
				tagarray[i].style.color=ttsenv_fontcolor[tts_fontcolorindex];
				if(setback==true)
					tagarray[i].style.backgroundColor=ttsenv_bgcolor[tts_bgcolorindex];
				if((document.body.style.zoom==null)||(ttsenv_mustadjustfont==true))
				{
					if((tts_curfontsize!='')&&(tts_curfontsize!=null))
						tagarray[i].style.fontSize=tts_curfontsize+'pt';
					else
						tagarray[i].style.fontSize='';
				}
			}
		}
	}
	var objs;

	objs=document.getElementsByTagName("tr");
	webgen_setface_unit(objs,true);
	objs=document.getElementsByTagName("td");
	webgen_setface_unit(objs,true);
	objs=document.getElementsByTagName("th");
	webgen_setface_unit(objs,true);
	objs=document.getElementsByTagName("div");
	webgen_setface_unit(objs,true);
	objs=document.getElementsByTagName("body");
	webgen_setface_unit(objs,true);
	objs=document.getElementsByTagName("a");
	webgen_setface_unit(objs,false);
	objs=document.getElementsByTagName("p");
	webgen_setface_unit(objs,false);
	objs=document.getElementsByTagName("span");
	webgen_setface_unit(objs,false);
	objs=document.getElementsByTagName("li");
	webgen_setface_unit(objs,false);
	
	if(document.getElementById('select2')!=null)
	{
		document.getElementById('select2').selectedIndex = parseInt(tts_fontcolorindex);
	}
	if(document.getElementById('select')!=null)
	{
		document.getElementById('select').selectedIndex = parseInt(tts_bgcolorindex);
	}
	webgen_setcookie("fontColorIndex", tts_fontcolorindex , 1);
	webgen_setcookie("bgColorIndex", tts_bgcolorindex , 1);
	if((document.body.style.zoom==null)||(ttsenv_mustadjustfont==true))
	{
		webgen_setcookie("fontSize", tts_curfontsize, 1);
	}
}

/* 서브프레임 호출함수 */
function webgen_pushsub()
{
	if(tts_subcontrol!=null) {
		var st;
		if(uvoice_mode==true) {
			st="start";
		} else {
			st="stop";
		}
		tts_subcontrol.f_setotherck(ttsenv_mustadjustfont,tts_curfontsize,st,voice_volume);
	}
}


/*****************************************************************************
 * f_setBasic()
 *
 * 역할 : 글자 및 음성정보를 초기화한다.
 *****************************************************************************/
function f_setBasic()
{
	function webgen_subframerst(win,param)
	{
		if(win!=this)
		{
			if(win.f_setBasic!=null)
			win.f_setBasic();
		}
		if(win.frames.length>0)
		{
			var i;
			for(i=0;i<win.frames.length;i++)
			{
				webgen_subframerst(win.frames[i],param);
			}
		}
	}

	/* 글자크기 및 색 초기화 */
	webgen_setcookie("fontColorIndex", 0, 1);
	tts_fontcolorindex = webgen_readcookie("fontColorIndex",0);
	webgen_setcookie("bgColorIndex", 0, 1);
	tts_bgcolorindex = webgen_readcookie("bgColorIndex",0);
	if((document.body.style.zoom!=null)&&(ttsenv_mustadjustfont==false))
	{
		webgen_setcookie("zoomVal",ttsenv_zoomDefault, 1);
		tts_curRate = ttsenv_zoomDefault;
		f_scalescreenInter(0);
	} else
	{
		webgen_setcookie("fontSize",ttsenv_fontDefault,1);
		tts_curfontsize = webgen_readcookie("fontSize",ttsenv_fontDefault);
	}
	webgen_setface();
	
}




/*컨트롤 입력여부 체크*/
function NullCheck(InObj, InMsg) {
	if (InObj.value == '') {
		alert(InMsg + '  입력해주세요.');
		InObj.focus();
		InObj.select();
		return false;
	}

	if (InObj.type == "textarea") {
		if (InObj.value.split(" ").join("")=="") {
			alert(InMsg + ' 값을 입력해 주세요.');
			InObj.focus();
			InObj.select();
			return false;
		}
	}
	return true;
}

// 주민등록번호 유효성 체크
function checkJuminNum(strRegNo1, strRegNo2) {
    var nCheckDigitFront, nCheckDigitBack;

    if (strRegNo1.length + strRegNo2.length != 13) return false;

    if (strRegNo1.substring(2, 3) > 1)
        return false;

    if (strRegNo1.substring(4, 5) > 3)
        return false;

    if (strRegNo2.substring(0, 1) > 4
		|| strRegNo2.substring(0, 1) == 0) {
        return false;
    }

    var a1 = strRegNo1.substring(0, 1)
    var a2 = strRegNo1.substring(1, 2)
    var a3 = strRegNo1.substring(2, 3)
    var a4 = strRegNo1.substring(3, 4)
    var a5 = strRegNo1.substring(4, 5)
    var a6 = strRegNo1.substring(5, 6)
    nCheckDigitFront = (a1 * 2) + (a2 * 3) + (a3 * 4) + (a4 * 5) + (a5 * 6) + (a6 * 7);

    var b1 = strRegNo2.substring(0, 1)
    var b2 = strRegNo2.substring(1, 2)
    var b3 = strRegNo2.substring(2, 3)
    var b4 = strRegNo2.substring(3, 4)
    var b5 = strRegNo2.substring(4, 5)
    var b6 = strRegNo2.substring(5, 6)
    var b7 = strRegNo2.substring(6, 7)

    nCheckDigitBack = nCheckDigitFront + (b1 * 8) + (b2 * 9) + (b3 * 2) + (b4 * 3) + (b5 * 4) + (b6 * 5);
    nCheckDigitBack = nCheckDigitBack % 11
    nCheckDigitBack = 11 - nCheckDigitBack
    nCheckDigitBack = nCheckDigitBack % 10

    if (nCheckDigitBack != b7)
        return false;
    else
        return true;
}


//새창띄우기
function OpenWin(filename,p_width,p_height,scrll)
{ 
    if (document.getElementById("divWait") != null)
	{
		document.getElementById("divWait").style.display = "none";
	}
   window.open(filename, "openwin2","resizable=no,scrollbars="+scrll+",width="+p_width+",height="+p_height);		 

}

/*숫자만 입력가능*/
function OnlyNumber(obj) 
{ 
    var bBreak = true;
    var charpos = obj.value.search("[^0-9\]"); 
    if(obj.value.length > 0 &&  charpos >= 0) 
    { 
        alert('숫자로만 등록이 가능합니다.');
        obj.value = "";
	    obj.focus(); 
	    return; 
    }
}

//*************************************** Zoom-in & Zoom-out *********************************/
function funcZoom(param){
        if(document.body.style.zoom==null||document.body.style.zoom==""){
                zoomStat = 100;
        }

        if(param=="plus"){
                zoomStat = zoomStat + 10;
        }else{
                zoomStat = zoomStat - 10;
        }

        if(zoomStat > 140){
                zoomStat = 140;
        }

        if(zoomStat < 60){
                zoomStat = 60;
        }

        if( zoomStat == 100 ) {
                if( document.getElementById("quick") ) {
                        document.getElementById("quick").style.display = "block";
                }
                if( document.getElementById("popup_btn") ) {
                        document.getElementById("popup_btn").style.display = "block";
                }
                if( document.getElementById("pop_content") ) {
                        document.getElementById("pop_content").style.display = "block";
                }
        } else {
                if( document.getElementById("quick") ) {
                        document.getElementById("quick").style.display = "none";
                }
                if( document.getElementById("append") ) {
                        document.getElementById("append").style.display = "none";
                }

        }

        document.body.style.zoom = zoomStat+"%";
}

var currentFontSize = 2;
function zoomUtil(state, e){
        if( navigator.userAgent.toLowerCase().indexOf("msie") != -1 ) {
                funcZoom(state);
        } //else { 
                var idx;
                var arrFontSize = new Array();

                arrFontSize[0] = "xx-small";
                arrFontSize[1] = "x-small";
                arrFontSize[2] = "small";
                arrFontSize[3] = "medium";
                arrFontSize[4] = "large";
                arrFontSize[5] = "x-large";
                arrFontSize[6] = "xx-large";

                if(isAccess(e)) {
                        if (state == "plus") {

                                if (currentFontSize < 6 ) {
                                        idx = currentFontSize + 1;
                                        currentFontSize = idx;
                                } else idx = currentFontSize;

                        } else if (state == "default") {
                                idx = 2;
                                currentFontSize = idx;
                        } else if (state == "minus") {

                                if ( currentFontSize >= 1) {
                                        idx = currentFontSize - 1;
                                        currentFontSize = idx;
                                } else idx = currentFontSize;
                        }
                }

                document.body.style.fontSize = arrFontSize[idx];
                return false;
        //}
}

function isAccess(e) {
        var keynum;
        var ismouseClick = 1;

        if (window.event) {             //IE & Safari
                keynum = e.keyCode;

                if (event.button == 0 || keynum == 0){
                        ismouseClick = 0;
                }
        } else if ( e.which ){          // Netscape/Firefox/Opera
                keynum = e.which;

                if (keynum == 1) {
                        ismouseClick = 0;
                }
        }

        if ( ismouseClick == 0 || keynum == 13 ) {
                return true;
        } else {
                return false;
        }
}
//*************************************** Zoom-in & Zoom-out *********************************/


function getDayOfWeek(times)
{
    var now = toTimeObject(times);

    var day = now.getDay();
    var week = new Array('일','월','화','수','목','금','토');
    
    return week[day];
}

/**
* Time 스트링을 자바스크립트 Date 객체로 변환
* parameter time: Time 형식의 String
*/
function toTimeObject(time) { //parseTime(time)
    var year  = time.substr(0,4);
    var month = time.substr(5,2) - 1; // 1월=0,12월=11
    var day   = time.substr(8,2);
    var hour  = time.substr(10,2);
    var min   = time.substr(12,2);

    return new Date(year,month,day,hour,min);
}

//날짜를 yyyy-mm-dd형태로 반환
function toDateString(date){
    var now = date;
    var year = now.getFullYear();
    var month = (now.getMonth()+1).toString().length == 1 ? '0'+(now.getMonth()+1) : now.getMonth()+1;
    var day = (now.getDate()).toString().length == 1 ? '0'+(now.getDate()) : now.getDate();  
    return (year + '-' + month + '-' + day);
}

//자리수만큼 0붙이기
function leadingZeros(n, digits) {
  var zero = '';
  n = n.toString();

  if (n.length < digits) {
    for (var i = 0; i < digits - n.length; i++)
      zero += '0';
  }
  return zero + n;
}

//이메일 유효성 체크
 function checkEmailFormat(email)
 {
      email.replace(" ", "");
      //email.value = trim(email.value);

      if (email == "")
      {
           alert("이메일을 입력해주세요.");
           return false;
      }
      else if(email != "") 
      {
           reg = new RegExp("^[\\w\\-]+(\\.[\\w\\-_]+)*@[\\w\\-]+(\\.[\\w\\-]+)*(\\.[a-zA-Z]{2,3})$", "gi");
           if (!reg.test(email))
           {
                alert("잘못된 이메일형식입니다.");
                return false;
           }
      }

      return true;
 }


