﻿// JavaScript Document
/////////////////////////////////////////////////////////
// 기능관련 공통함수
// 최종 수정일 2008.03.19
/////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////
// onLoad 이벤트를 추가한다. 
// ex) addOnLoad(test);
//     function test(){
//     }
// 한글은 어떻게....
// @funcName 함수명
function addOnLoad(funcName){
	if(window.attachEvent){ 
		window.attachEvent('onload', funcName); 
	}
}

// 공통 페이지프린트 함수
// 방법 : 인쇄하고자 하는 영역을 <print> </print>로 감싸줌
// 호출방법 : <a href="javascript:printPage('<html:env name='pageURL'/>', 800, 600)">
function ContentPrint(url, idx, w, h){
	openBrWindow(url + '?idx=' + idx, w, h, 'Y');
}

// 자바스크립트만으로 인쇄하는 기능
function ps_page_print(){
	popup('/common/print.html', 500, 500);
}

///////////////////////////////////////////////////////////
// 팝업 기능관련
// @url URL
// @w 폭
// @h 너비
// @s 스크롤바 여부 1, 'Y'이면 보여줌, 0, '', 'N'이면 숨김
function popup(url,w,h,s){
	var l, t, objPopup;
	l = (screen.width-w)/2;
	t = (screen.height-h)/2;
	if(s==1 || s=="Y") 
		objPopup  = window.open(url,'','width='+w+',height='+h+',left='+l+',top='+t+',resizable=0,scrollbars=1');
	else if (s=="" || s==0 || s=="N" || !s) 
		objPopup = window.open(url,'','width='+w+',height='+h+',left='+l+',top='+t+',resizable=0,scrollbars=0,status=0');
	else
		objPopup = window.open(url,'','width='+w+',height='+h+',left='+l+',top='+t+',resizable=1,menubar=1,toolbar=1,scrollbars=1,status=1');
	if (objPopup == null) { 
		alert("차단된 팝업창을 허용해 주십시오."); 
	} 
	return objPopup;

}

function openBrWindow(url,w,h,s){
	var l, t, objPopup;
	l = (screen.width-w)/2;
	t = (screen.height-h)/2;
	if(s==1 || s=="Y") 
		objPopup  = window.open(url,'OPENWIN','width='+w+',height='+h+',left='+l+',top='+t+',resizable=0,scrollbars=1');
	else if (s=="" || s==0 || s=="N" || !s) 
		objPopup = window.open(url,'OPENWIN','width='+w+',height='+h+',left='+l+',top='+t+',resizable=0,scrollbars=0,status=0');
	else
		objPopup = window.open(url,'OPENWIN','width='+w+',height='+h+',left='+l+',top='+t+',resizable=1,menubar=1,toolbar=1,scrollbars=1,status=1');
	if (objPopup == null) { 
		alert("차단된 팝업창을 허용해 주십시오."); 
	} 
	
	var new_instance = objPopup;
	new_instance.focus();

}
/*----------------------------------------------------------------------------
새창을 화면 가운데로 띄우는 함수
----------------------------------------------------------------------------*/
function newwin(w_url,w_title,w_width,w_height,w_resizable,w_scrollbars)
{
	var option = "alwaysRaised,toolbar=0,status=0,menubar=0";
	
	var w_left = (screen.width)?(screen.width-w_width)/2:100;
	var w_top = (screen.height)?(screen.height-w_height)/2:100;
	
	//width 와 height 가 있을때만 화면의 가운데에 표시한다
	if (w_width) option = option + ",width=" + w_width + ",left=" + w_left;
	if (w_height) option = option + ",height=" + w_height + ",top=" + w_top;
	//창크기 조절가능과 스크롤바 표시는 기본적으로 보이지 않으며, 지정할때만 보인다
	if (w_resizable == true) option = option + ",resizable=1";
	if (w_scrollbars == true) option = option + ",scrollbars=1";

	var new_instance = window.open(w_url,w_title,option,"");
	new_instance.focus();
//	window.open(w_url,w_title,option,"");
}	

/*----------------------------------------------------------------------------
새창을 화면 가운데로 띄우는 함수
----------------------------------------------------------------------------*/
function newwin2(w_url,w_title,w_width,w_height,w_resizable,w_scrollbars)
{
	var option = "alwaysRaised,toolbar=0,status=0,menubar=0";
	
	var w_left = (screen.width)?(screen.width-w_width)/2:100;
	var w_top = (screen.height)?(screen.height-w_height)/2:100;
	
	//width 와 height 가 있을때만 화면의 가운데에 표시한다
	if (w_width) option = option + ",width=" + w_width + ",left=" + w_left;
	if (w_height) option = option + ",height=" + w_height + ",top=" + w_top;
	//창크기 조절가능과 스크롤바 표시는 기본적으로 보이지 않으며, 지정할때만 보인다
	if (w_resizable == true) option = option + ",resizable=1";
	if (w_scrollbars == true) option = option + ",scrollbars=1";
	
	option = option + ",toolbar=1";
	option = option + ",location=1";
	option = option + ",status=1";
	option = option + ",menubar=1";

	var new_instance = window.open(w_url,w_title,option,"");
	new_instance.focus();
//	window.open(w_url,w_title,option,"");
}

function popupEx(url,w,h,s){
	var objPopup;
	
	if(s==1 || s=="Y") 
		objPopup  = window.open(url,'','width='+w+',height='+h+',resizable=0,scrollbars=1');
	else if (s=="" || s==0 || s=="N" || !s) 
		objPopup = window.open(url,'','width='+w+',height='+h+',resizable=0,scrollbars=0,status=0');
	else
		objPopup = window.open(url,'','width='+w+',height='+h+',resizable=1,menubar=1,toolbar=1,scrollbars=1,status=1');
	if (objPopup == null) { 
		alert("차단된 팝업창을 허용해 주십시오."); 
	} 
	return objPopup;
	
}

function openWin(url,w,h){
	window.open(url,"",'width='+w+',height='+h+',resizable=0,scrollbars=0,status=0');
}

///////////////////////////////////////////////////////////
// 특정 url로 이동
function goSite(url){
	if(url != ''){
		if(url.indexOf("http")<0)
			url = "http://"+url;
		popup(url,1024,768,9);
	}else
		alert('url이 없습니다.');
}


///////////////////////////////////////////////////////////
// 0으로 체우기

function getZeroFill(n,str) {
 		var ret="";
 		i=0;
 		len=0;
 		if(str == ""){
 			ret = "0";
 			len = 1;
 		}else{
 			ret = str;
 			len = str.length;
 		}

 		if(len < n){
 			for(i=0;i<n-len;i++){
 				ret = "0" + ret;
 			}
 		}
	return ret;
}


///////////////////////////////////////////////////////////
// 페이지 위치 변경 처리
function goUrl(url,target){
	if(!target) target = window;
	target.location.href=url;
}


///////////////////////////////////////////////////////////
// 쿠키셋팅
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 "";
}


///////////////////////////////////////////////////////////
// String 문자열 처리
function LTrim(strValue){
    while (strValue.length>0){
       if(strValue.charAt(0)==' '){
           strValue=strValue.substring(1,strValue.length);              
   }
       else
          return strValue;     
    }
return strValue;
}


function RTrim(strValue){
    while (strValue.length>0){
       if(strValue.charAt(strValue.length-1)==' '){
           strValue=strValue.substring(0,strValue.length-1);              
   }
       else
           return strValue;     
   }
   return strValue;
}

function Trim(str) {
	var search = 0
	while ( str.charAt(search) == " ") search = search + 1
	str = str.substring(search, (str.length))
	search = str.length - 1
	while (str.charAt(search) ==" ") search = search - 1
	return str.substring(0, search + 1)
}

function Trim2(str){
	var reg = /\s+/g;
	return str.replace(reg,'');
}
//문자열 변환
function strReplace(szFind, szReplace, szAll) {
	var i;
	var length;

	length = szReplace.length - szFind.length;

	for (i=0; i < szAll.length; i++) {
		if (szAll.substr(i,szFind.length) == szFind) {
			if ( i > 0 ) {
				if (szFind == "\n") {
					szAll = szAll.substr(0, i-1) + szReplace + szAll.substr(i+szFind.length,szAll.length - (i+szFind.length));
				} else {
					szAll = szAll.substr(0, i) + szReplace + szAll.substr(i+szFind.length,szAll.length - (i+szFind.length));
				}
			} else { 
				szAll = szReplace + szAll.substr(i+szFind.length,szAll.length - (i+szFind.length));
			}
			i = i + length;
		}
	}
	return szAll;
}
// 대문자로 변경
function toUpperCase(val){
	return val.toUpperCase();
}
//*************************** 
// *** 123,456 형 숫자로 리턴
// ************************** 
function numberFormat(num)
{
	var str=''+num;
	var len=str.length;	
	var no =len/3;
	var remain=len%3;
	var rv='';
	var str1='';
	var blank=0;
	var Bstr='                                   ';
	
	for (var i=1;i<=no;i++)
	{
		rv=str.substring(len-i*3,len-(i*3)+3)+rv;
		if (i!=no ) rv=','+rv;
	}
	if (remain) rv=str.substring(0,remain)+rv;
	
	if (navigator.appName=="Microsoft Internet Explorer")
	{
		rv=Bstr.substring(0,14-rv.length)+rv;
	}
	else
	{
		rv=Bstr.substring(0,14-rv.length)+rv;
	}
	return rv;
}

//*******************************
// *** 셀렉트박스 선택 되었는지 
// ******************************
function isSelect(sel) {
	if(sel.selectedIndex==0){
		return false;
	}else{
		return true;
	}
}

//*******************************
// *** 라디오버튼 체크 되었는지 
// ******************************
function isRadio(sel) {
	var n=0;
	if(sel.length==undefined){
		if(sel.value) n++;
	}else{
		for(i=0; i<sel.length; i++){
			if(sel[i].checked){
				n++;
			}
		}
	}
	if(n==0){
		return false;
	}else{


		return true;
	}
}

//*******************************
// *** 히든폼에 값이 있는지 
// ******************************
function isHidden(sel) {
	if(!sel.value){
		return false;
	}else{
		return true;
	}
}

//*************************** 
// *** 입력이 되었는지 체크 
// ************************** 
function isInput(obj)
{ 

	if(obj.type=="select-one"){
		if(!isSelect(obj))
		return false;
	}else if(obj.type=="radio" || obj.type==undefined){

		if(!isRadio(obj))
		return false;
	}else if(obj.type=="hidden"){
		if(!isHidden(obj))
		return false;
	}else{
		if(obj.value.length==0 || obj.value=="")
		return false;
	}
	return true; 
} 

//******************************************* 
//*** 값이 같은지 체크 (pwd1/pwd2)
//******************************************* 
function isEqual(obj1,obj2) 
{ 
	if(obj1.value != obj2.value) return false;
	return true; 
} 

//************************************ 
//*** 입력된 문자의 길이가 같은지 체크 
//************************************ 
function isChkLen(obj,len)
{ 
	if(obj.value.length != len)  return false;
	return true 
} 

//*********************************** 
// *** 입력된 문자의 길이 범위를 체크
//*********************************** 
function isBtnLen(obj,len1,len2)
{ 
	if(obj.value.length <len1 && obj.value.length > len2) return false;
	return true ;
} 

//*********************************** 
// *** 입력된 문자의 길이 범위를 err체크  
//*********************************** 
function isBtnLens(obj,len1,len2)
{ 
	if(obj.value.length <len1 || obj.value.length > len2) return false;
	return true ;  
	
} 


//*****************************// 
//*** 숫자만 입력 가능 
//*****************************// 
function isNum(obj) 
{
	if(obj.value.search(/\D/) != -1 ) return false;
	return true ; 
} 

//*****************************// 
//***특수문자 제어 기능 (영문과 숫자만)
//*****************************// 
function isOnlyEng(obj) {
	var inText = obj.value; 
	var ret; 
	for (var i = 0; i < inText.length; i++) { 
		ret = inText.charCodeAt(i); 
		if ((ret > 122) || (ret < 48) || (ret > 57 && ret < 65) || (ret > 90 && ret < 97)) { 
			return false; 
		} 
	} 
	return true; 
} 



//**************************************** 
//*** 입력된 문자열이 주민등록번호인지 체크 
//**************************************** 
function isJuminNum(aNum1, aNum2) { 
	var tot=0, result=0, re=0, se_arg=0; 
	var chk_num=""; 
	var aNum = aNum1 + aNum2; 

	if (aNum.length != 13)	{ 
		return false; 
	}else{ 
		for (var i=0; i <12; i++){ 
			if (isNaN(aNum.substr(i, 1))) 
			return false; 
			se_arg = i; 

			//외국인 인 경우 
			if(i==6) { 
				if (aNum.substr(i, 1) == 7 || aNum.substr(i, 1) == 8 ) 
				return true 
			} 

			if (i >= 8) 
			se_arg = i - 8; 
			tot = tot + Number(aNum.substr(i, 1)) * (se_arg + 2) 
		} 

		if (chk_num != "err") 
		{ 
			re = tot % 11; 
			result = 11 - re; 
			if (result >= 10) result = result - 10; 
			if (result != Number(aNum.substr(12, 1))) return false; 
			if ((Number(aNum.substr(6, 1)) < 1) || (Number(aNum.substr(6, 1)) > 4)) return false; 
		} 
	} 
	return true; 
} 


//*****************************// 
//***이메일이 올바른지 체크 ***// 
//*****************************// 
function emailCheck (emailStr) { 
	// Email check 함수 
	var emailPat=/^(.+)@(.+)$/ 
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" 
	var validChars="\[^\\s" + specialChars + "\]" 
	var firstChars=validChars 
	var quotedUser="(\"[^\"]*\")" 
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/ 
	var atom="(" + firstChars + validChars + "*" + ")" 
	var word="(" + atom + "|" + quotedUser + ")" 
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$") 
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$") 


	var matchArray=emailStr.match(emailPat) 
	if (matchArray==null) { 
		alert("e-mail 주소가 정확하지 않습니다.\n @ 와 . 을 확인하십시오") 
		return false 
	} 
	var user=matchArray[1] 
	var domain=matchArray[2] 

	if (user.match(userPat)==null) { 
		alert("메일 아이디가 정확한 것 같지 않습니다.") 
		return false 
	} 

	var IPArray=domain.match(ipDomainPat) 
	if (IPArray!=null) { 
		for (var i=1;i<=4;i++) { 
		if (IPArray[i]>255) { 
		alert("IP가 정확하지 않습니다.") 
		return false 
	} 
	} 
	return true 
	} 

	var domainArray=domain.match(domainPat) 

	if (domainArray==null) { 
		alert("도메인 이름이 정확한 것 같지 않습니다.") 
		return false 
	} 
	var atomPat=new RegExp(atom,"g") 
	var domArr=domain.match(atomPat) 
	var len=domArr.length 

	if (domArr[domArr.length-1].length<2 || 
		domArr[domArr.length-1].length>3) { 
		alert("도메인명의 국가코드는 2자보다 크고 3자보다 작아야 합니다.") 
		return false 
	} 

	if (domArr[domArr.length-1].length==2 && len<3) { 
		var errStr="This address ends in two characters, which is a country" 
		errStr+=" code. Country codes must be preceded by " 
		errStr+="a hostname and category (like com, co, pub, pu, etc.)" 
		alert(errStr) 
		return false 
	} 

	if (domArr[domArr.length-1].length==3 && len<2) { 
		var errStr="이 주소는 호스트명이 일치하지 않습니다." 
		alert(errStr) 
		return false 
	} 
	return true; 
} 




/*
2005.08.12 추가
*/

///////////////////////////////////////////////////////////
// 한글인지 체크
function isHangul (obj)
{
	if (obj.type == object) {
		var str = obj.value;
        var retCode=0;
        for(i=0; i<str.length; i++)
        {
                var code = str.charCodeAt(i)
                var ch = str.substr(i,1).toUpperCase()
                code = parseInt(code)

                if((ch<"0" || ch>"9") && (ch<"A" || ch>"Z") && ((code>255) || (code<0)))
                {
                        return true;
                }
        }
        return false;

	} else {
		return isHangul2(obj);
	}
}

// 한글인지 아닌지 구별
function isHangul2(s) 
{
     var len;
     
     len = s.length;

     for (var i = 0; i < len; i++)  {
         if (s.charCodeAt(i) != 32 && (s.charCodeAt(i) < 44032 || s.charCodeAt(i) > 55203))
             return false;
     }
     return true;
}

///////////////////////////////////////////////////////////
// 공백체크      
function isEmpty( str ) {
   for ( var i = 0 ; i < str.length ; i++ )    {
      if ( str.substring( i, i+1 ) == " " )
         return true;
   }
   return false;
}

///////////////////////////////////////////////////////////
// 폼 항목들 입력값 체크 
function chkInput(obj, msg){
	if(!isInput(obj)){
		alert(msg);
		if(obj.type !="radio" && obj.type != undefined && obj.type != "hidden"){
			obj.value="";
			obj.focus();
		}
		return false;
	}
	return true;
}

///////////////////////////////////////////////////////////
// 폼 항목의 숫자 체크
function chkNum(obj,msg) 
{
	if(!chkInput(obj,msg)) return false;
	if(!isNum(obj)){
		alert(msg);
		obj.value="";
		obj.focus();
		return false;		
	}
	return true;
} 

///////////////////////////////////////////////////////////
// 폼 항목 영문/수자 체크
function chkOnlyEng(obj, msg){
	if(!isInput(obj) || !isOnlyEng(obj)){
		alert(msg);
		obj.value="";
		obj.focus();
		return false;
	}
	return true;
}

function chkBtnLen(obj,len1,len2,msg){
	if(!isBtnLen(obj,len1,len)){
		alert(msg);
		obj.value="";
		obj.focus();
	}
}

//////////////////////////////////////////////////////////////
// 멀티 체크박스
/**
 * 특정이름의 멀티체크박스를 체크 또는 체크해제한다.
 * ex) <input type=checkbox name=IDS value='...'>
 *     <script language='javascript'>
 *		toggleMultiChk(true, 'IDS')
 *	   </script>
 *
 * @param bCheck    true|false(체크할 상태)
 * @param itemName  체크대상 체크박스이름
 */
function toggleMultiChk(bCheck, itemName){
	var obj = document.getElementsByName(itemName);
	if(typeof(obj) == 'undefined'){
		return;
	}
	
	for(var i=0; i<obj.length; i++){
		obj[i].checked = bCheck;
	}
}
/**
 * 체크된 개수
 * @param itemName 체크박스명
 */
function getMultiCheckedNum(itemName){
	var obj = document.getElementsByName(itemName);
	if(typeof(obj) == 'undefined'){
		return 0;
	}
	var chkedCnt=0;
		
	for(var i=0; i<obj.length; i++){
		if(obj[i].checked)
			chkedCnt++;
	}
	return chkedCnt;
}
/**
 * 체크된 항목들 값을 취합해서 리턴
 * @param itemName 체크박스명
 * @param delim    구분자
 */
function getMultiCheckedString(itemName, delim){
	var obj = document.getElementsByName(itemName);
	var div = delim;
	if(div=="")
		div="|";
	var chkCnt=0;
	if(typeof(obj) == 'undefined'){
		return "";
	}
	var s="";
	var n=0;
	for(var i=0; i<obj.length; i++){
		if(obj[i].checked){
			if(n>0)
				s += div;
			s += obj[i].value;
			n++;
		}
	}
	return s;
}

///////////////////////////////////////////////////////////
// 포커스이동 
function moveFocus(obj1,obj2,movLen){
	movLen = (!movLen) ? 6 : movLen; //  = 6 //포커스이동   ;
	if(obj1.value.length == movLen ) obj2.focus();
}
//대문자로 변경
function upperCase(str) {
	if (str.length = 0 ) return "";
	else return str.toUpperCase();
}
//소문자로 변경
function lowerCase(str) {
	if (str.length = 0 ) return "";
	else return str.toLowerCase();
}

// 숫자만 입력하게 한다.
// onkeydown="return onlyNumber();"
function onlyNumber() {
	 if ((window.event.keyCode == 8) || (window.event.keyCode == 9) || (window.event.keyCode == 46)) { //백스페이스키와  tab, del키는 먹게한다.
      window.event.returnValue=true;
	 } else if ((window.event.keyCode >= 96) && (window.event.keyCode <= 105)) { //숫자패드는 먹게 한다.
	 		window.event.returnValue=true;
   } else if( (window.event.keyCode<48) || (window.event.keyCode>57) ) {
      window.event.returnValue=false;
  }
}
// 숫자 및 '.' 만 입력
function onlyNumberAndDot() {
	 if ((window.event.keyCode == 8) || (window.event.keyCode == 190) || (window.event.keyCode == 9) || (window.event.keyCode == 46)) { //백스페이스키와  '.', tab, del키는 먹게한다.
      window.event.returnValue=true;
	 } else if (((window.event.keyCode >= 96) && (window.event.keyCode <= 105)) || (window.event.keyCode == 110)) { //숫자패드는 먹게 한다.
	 		window.event.returnValue=true;
   } else if( (window.event.keyCode<48) || (window.event.keyCode>57) ) {
      window.event.returnValue=false;
  }
}
// 이미지 파일 여부
function isImageFile(fn) {
	var ext = fn.value;
	ext = ext.substring(ext.length-3,ext.length);
	ext = ext.toLowerCase();
	if(ext == "jpg" || ext == "jpeg" || ext == "gif" || ext == "bmp") {
		return true; 
	} else {
		alert("이미지 파일(jpg, gif, bmp)만 업로드 할 수 있습니다.");
		return false; 
	}
}
// 팝업창
// arg1 : url
// arg2 : window name
// arg3 : width
// arg4 : height
// arg5 : 창 중앙 위치 여부
// arg6 : top
// arg7 : left
function showPopup()
{
	var url, name, w, h, loca, top, left, status, scroll, resize;
	var menubar, toolbar, locat, fullscreen;
	var winprops, win;
	url = arguments[0];
	name = arguments[1];
	if (arguments[2] == "" || arguments[2] == null)
	w = 300;
	else w = arguments[2];
	if (arguments[3] == "" || arguments[3] == null)
	h = 200;
	else h = arguments[3];
	if ( arguments[4] == "" || arguments[4] == null || arguments[4] == "1" || arguments[4] == "yes")
	{
	top = (screen.height - h) / 2;
	left = (screen.width - w) / 2;
	loca = 'top='+top+'; left='+left+';' ;
	}
	else if(arguments[4] == "0" || arguments[4] == "no")
	{
	if (arguments[5] == "" || arguments[5] == null)
	top = 0;
	else top = arguments[5];
	if (arguments[6] == "" || arguments[6] == null)
	left = 0;
	else left = arguments[6];
	loca = 'top='+top+'; left='+left+';' ;
	}
	else loca = '';
	if (arguments[7] == "" || arguments[7] == null)
	status = '1';
	else status = arguments[7];
	if (arguments[8] == "" || arguments[8] == null)
	scroll = '0';
	else scroll = arguments[8];
	if (arguments[9] == "" || arguments[9] == null)
	resize = '0';
	else resize = arguments[9];
	if (arguments[10] == "" || arguments[10] == null)
	menubar = '0';
	else menubar = arguments[10];
	if (arguments[11] == "" || arguments[11] == null)
	toolbar = '0';
	else toolbar = arguments[11];
	if (arguments[12] == "" || arguments[12] == null)
	locat = '0';
	else locat = arguments[12];
	if (arguments[13] == "" || arguments[13] == null)
	fullscreen = '0';
	else fullscreen = arguments[13];
	winprops = 'width='+w+'; height='+h+'; '+loca+' status='
	+status+'; scrollbars='+scroll+'; resizable='+resize+'; menubar='
	+menubar+'; toolbar='+toolbar+'; location='+locat+'; fullscreen='+fullscreen;
	win = window.open(url,name,winprops);
	return win ; 
}
function closeWindow()
{
	window.close();
	return false;
}

// 주민등록번호 체크
function checkNationalId(nationalId1, nationalId2)
	{
	
	if(isNaN(nationalId1) || isNaN(nationalId2))
	{
		return 'N';
	}
	
	var nationalId = nationalId1 + nationalId2;

	var nationalIdStr = nationalId.toString();
	a = nationalIdStr.substring(0, 1);
	b = nationalIdStr.substring(1, 2);
	c = nationalIdStr.substring(2, 3);
	d = nationalIdStr.substring(3, 4);
	e = nationalIdStr.substring(4, 5);
	f = nationalIdStr.substring(5, 6);
	g = nationalIdStr.substring(6, 7);
	h = nationalIdStr.substring(7, 8);
	i = nationalIdStr.substring(8, 9);
	j = nationalIdStr.substring(9, 10);
	k = nationalIdStr.substring(10, 11);
	l = nationalIdStr.substring(11, 12);
	m = nationalIdStr.substring(12, 13);
	
	month = nationalIdStr.substring(2,4);
	day = nationalIdStr.substring(4,6);
	
	if(month <= 0 || month > 12) return 'N';
	if(day <= 0 || day > 31) return 'N';
	
	
	
	// 주민등록뒷자리 첫번째 번호 유효성 체크 (1,2,3,4) are only valid
	if(g > 4 || g == 0) return 'N';
	
	temp=a*2+b*3+c*4+d*5+e*6+f*7+g*8+h*9+i*2+j*3+k*4+l*5;
	temp=temp%11;
	temp=11-temp;
	temp=temp%10;
	
	if(temp == m)
		return 'Y';
	else
		return 'N'; 
	
}


// 공백이 있는지 체크
function checkSpace( str )
{
	return (str.search(/\s/) != -1);
}


// 14세 이상이면 true아니면 false;
function is14AgeOver( v_year, v_month, v_day)
{
     var today = new Date();
     var d_year = v_year*1 + 14;
     var d_month = v_month*1;
     var d_day = v_day*1;
     
     /* 과거 날짜여야 함. */ 
     if( d_year > today.getYear() ){
         return false;
     }else if( d_year == today.getYear() && d_month > (today.getMonth()*1+1)){
         return false;
     }else if( d_year == today.getYear() && d_month == (today.getMonth()*1+1) && d_day > today.getDate()){
         return false;
     }
     
     
     /* 달별 일 check */
     if( d_month == 1 || d_month == 3 || d_month == 5 || d_month == 7 || d_month == 8 || d_month == 10 || d_month == 12){
         if( d_day > 31 || d_day < 1) {
         	return false;
         }
     }
     else if(d_month == 4 || d_month == 6 || d_month == 9 || d_month == 11 ){
         if( d_day > 30 || d_day < 1 ) {
         	return false;	
         }
     }
     else if( d_month == 2 )
     {
     /*
     	 if( ((d_year%400) == 0 || ((d_year%100) != 0 && (d_year%4) == 0) ){
     	     if( d_day > 29 || d_day < 1 ) {
     	     	return false;
     	     }
     	 }
     	 else {
     	     if( d_day > 28 || d_day < 1 ) {
     	     	return false;
     	     }
     	 }
     */
     }
     
     return true;
}

	// 특수문자 체크
function Check_nonChar(id_text)
{
		//var nonchar = '~`!@#$%^&*()-_=+\|<>?,./;:"';
		var nonchar = '`@#$%&\|<>;"';

		var i ; 
		for ( i=0; i < id_text.length; i++ )  {
			if( nonchar.indexOf(id_text.substring(i,i+1)) > 0) {
				break ; 
			}
		}
		if ( i != id_text.length ) {
			return false ; 
		}
		else{
			return true ;
		} 

		return false;
}

//문자열 개수
function LengthCheck(message) {
	var nbytes = 0;

	for (i=0; i<message.length; i++) {
		var ch = message.charAt(i);
		if (escape(ch).length > 4) {
			nbytes += 2;
		} else if (ch != '\r') {
			nbytes++;
		}
	}

	return nbytes;
}

function strCutByte(message, maximum){
	var inc = 0;
	var nbytes = 0;
	var msg = "";
	var msglen = message.length;
	
	for (i=0; i<msglen; i++) {
		var ch = message.charAt(i);
		if (escape(ch).length > 4) {
			inc = 2;
		} else if (ch != '\r') {
			inc = 1;
		}
		if ((nbytes + inc) > maximum) {
			break;
		}
		nbytes += inc;
		msg += ch;
	}

	return msg;
}


function next(str, size){     // 주민번호 valid check , 자동 다음 폼 이동
   num = str.socialId1.value;
   siz = num.length;
   if(siz == size){
      str.socialId2.focus();
   }
   return true;
}

function next2(str, size){     // 주민번호 valid check , 자동 다음 폼 이동
   num = str.jumin1.value;
   siz = num.length;
   if(siz == size){
      str.jumin2.focus();
   }
   return true;
}


function chkEmail(obj1,obj2){
	if(!chkInput(obj1,"e-mail을 입력하세요.")) return false;
	if(obj2){
		if(!chkInput(obj2,"e-mail을 입력하세요.")) return false; 
		if(!emailCheck(obj1.value+"@"+obj2.value)){ obj1.focus(); return false; }
	}else{
		if(!emailCheck(obj1.value)){ obj1.focus(); return false; }
	}
	return true; 
}




	function doResize(){ 
		container.height = myframe.document.body.scrollHeight; 
		container.width = myframe.document.body.scrollWidth; 
	} 


	///////////////////////////////////////////////////////////////
	// 이미지 popup 함수
	function jsOpenImage(imageRef)
	{
		var x,y,w,h,loadingMsg;
		//팝업될 창의 초기 크기
		w=300;h=100;
		//화면 한가운데로 팝업창 띄우기 위한 좌표 계산
		x=Math.floor( (screen.availWidth-(w+12))/2 );y=Math.floor( (screen.availHeight-(h+30))/2 );
	
		//이지미가 로딩중에 내보낼 메시지
		loadingMsg="<table width=100% height=100%><tr><td valign=center align=center><font size='2' color='#ff6600' face='termanal'>NOW LODDING...</font></td></tr></table>";
	
		with( window.open("","",'height='+h+',width='+w+',top='+y+',left='+x+',scrollbars=no,resizable=no,status=no') )
		{
			document.write(
			"<body topmargin=0 rightmargin=0 bottommargin=0 leftmargin=0>",
			loadingMsg,
			"<img src=\""+imageRef+"\" hspace=0 vspace=0 border=0 onmousedown=\"window.close();\" onload=\"document.title='원본 이미지';document.body.removeChild(document.body.children[0]);window.resizeTo(this.width+12,this.height+30);window.moveTo(Math.floor( (screen.availWidth-(this.width+12))/2),Math.floor( (screen.availHeight-(this.height+30))/2 ));\">",
			"</body>");
			focus();
		}
	
		return false;
	}

	///////////////////////////////////////////////////////////////
	// 이미지 resize
	function imageResize(img, maxWidth, maxHeight)
	{
		var width, height;
	
		width	= parseInt(img.width);
		if(width == 0) {
			return false;
		}
	
		height	= parseInt(img.height);
		if(height > maxHeight) {
			img.style.width		= Math.ceil(width * maxHeight / height);
			img.style.height	= maxHeight;
		}
		if(width > maxWidth) {
			img.style.height	= Math.ceil(height * maxWidth / width);
			img.style.width		= maxWidth;
		}
	
		return true;
	}

	function cnj_win_view(img){
		img_conf1= new Image();
		img_conf1.src=(img);
		cnj_view_conf(img);
	}
	
	function cnj_view_conf(img){
		if((img_conf1.width!=0)&&(img_conf1.height!=0)){
			cnj_view_img(img);
		} else{
			funzione="cnj_view_conf('"+img+"')";
			intervallo=setTimeout(funzione,20);
		}
	}
	
	var cnj_img_view = null;
	function cnj_view_img(img){
		if(cnj_img_view != null) {
			if(!cnj_img_view.closed) { 
				cnj_img_view.close(); 
			}
		}
		//cnj_width=img_conf1.width+20;
		cnj_width=img_conf1.width;
		//cnj_height=img_conf1.height+20;
		cnj_height=img_conf1.height;
		
		var w_left = (screen.width)?(screen.width-cnj_width)/2:100;
		var w_top = (screen.height)?(screen.height-cnj_height)/2:100;
		str_img="width="+cnj_width+",height="+cnj_height + ",top=" + w_top + ",left=" + w_left;
		if(cnj_width > screen.width || cnj_height > screen.height) str_img += ",scrollbars=1";

		cnj_img_view=window.open("about:blank","",str_img);
		cnj_img_view.document.open(); // document.open() 
		cnj_img_view.document.writeln("<html>");
		cnj_img_view.document.writeln("<head>");
		cnj_img_view.document.writeln("<title>이미지 확대보기 팝업창이 열렸습니다.</title>");
		cnj_img_view.document.writeln("<meta http-equiv='content-type' content='text/html; charset=euc-kr'>");
		cnj_img_view.document.writeln("<meta http-equiv='imagetoolbar' content='no'>");
		/*
		var start="<";
		cnj_img_view.document.writeln("<script language='javascript'>");
		cnj_img_view.document.writeln("function click() {");
		cnj_img_view.document.writeln("if ((event.button==1) || (event.button==2)) {");
		cnj_img_view.document.writeln("top.close();");
		cnj_img_view.document.writeln(" }");
		cnj_img_view.document.writeln("}");
		cnj_img_view.document.writeln("document.onmousedown=click");
		cnj_img_view.document.writeln(start+"/script>");
		*/
		cnj_img_view.document.writeln("</head>");
		cnj_img_view.document.writeln("<body style='margin:0'>");
		cnj_img_view.document.writeln("<img src="+ img +" border=0 style='cursor:hand' onClick='self.close();'>") // 소스 테스트 부분
		cnj_img_view.document.writeln("</body></html>");
		cnj_img_view.document.close(); // 반드시 document.close() 닫아주어야 함
		cnj_img_view.focus();
		return;
	}

	///////////////////////////////////////////////////////////////
	// 년월 yyyyMM형태로 리턴
	function mergeToYM(year, month){
		var yymm = year;
		if(month.length < 2){
			yymm += "0"+month;
		}else{
			yymm += month;
		}
		return yymm;
	}

///////////////////////////////////////////////////////////////
/**
 * 입력박스의 입력되는 글자byte수를 체크하고 제한한다.
 * @param item   입력박스 이름
 * @param viewId 현재 입력된 글자수를 보여줄 span태그 아이디
 * ex)
 *         현재 <span id='cmntlen' style=''>0</span>byte
 *         <textarea onKeyUp='inputCheckLen(this, "cmntLen", 100)'></textarea>
 */
function inputCheckLen(item, viewId, limit){
	var len = LengthCheck(item.value);
	if(len>limit){
		alert(limit+'byte를 초과할 수 없습니다.');
		item.value = strCutByte(item.value, limit);
	}
	len = LengthCheck(item.value);
	var obj = document.getElementById(viewId);
	obj.innerHTML = len;
}

/**
 * Ajax call
 */
function getHttprequest(URL) { 
	var xmlhttp = null; 
	if(window.XMLHttpRequest) { 
		xmlhttp = new XMLHttpRequest(); 
	} else { 
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	xmlhttp.open('GET', URL,false); 
	xmlhttp.onreadystatechange = function() { 
		if(xmlhttp.readyState==4 && xmlhttp.status == 200 && xmlhttp.statusText=='OK') { 
			responseText = xmlhttp.responseText; 
		} 
	} 
	xmlhttp.send(''); 

	return responseText = xmlhttp.responseText; 
} 

/**
 * 선택박스 값을 디폴트 서택
 */
function setSelBoxSelectedByValue(tbox, val){
	for(var i=0; i<tbox.options.length; i++){
		if(tbox.options[i].value == val){
			tbox.selectedIndex = i;
			return;
		}
	}
}
function setSelBoxSelectedByText(tbox, val){
	for(var i=0; i<tbox.options.length; i++){
		if(tbox.options[i].text == val){
			tbox.selectedIndex = i;
			return;
		}
	}
}

/**
 * 0에서 N까지의 랜덤값 반환 
 */
function ps_random(i){
	return Math.floor(Math.random()*(i+1));
}

///////////////////////////////////////////////////////////////
// 드림위버공통함수
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.0
  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 && document.getElementById) x=document.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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_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=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


document.onkeypress = getKey;

//initZoomDisplay('bodywrapper') ;
	
function getKey(keyStroke) {
	isNetscape=(document.layers);
	eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
	which = String.fromCharCode(eventChooser).toLowerCase();
	which2 = eventChooser;

	var el=event.srcElement;

	if ((el.tagName != "INPUT") && (el.tagName != "TEXTAREA"))		//input,textarea 안에서의 +.-값은 실행안되도록
	{			
		if(which == "+" || which == "=")
			zoomInOut('zoom', 'in');
		else if(which == "-" || which == "_")
			zoomInOut('zoom', 'out');
	}
}

var zoomRate = 10;			//확대/축소시 증감률
//var maxRate = 300;			//최대확대률
var maxRate = 160;			//최대확대률
var minRate = 100;			//최소축소률

function zoomInOut(contentid, how) { 

	if(GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
		document.all[contentid].style.zoom = GetCookie("zoomVal");
		//document.body.style.zoom = GetCookie("zoomVal");
		currZoom=GetCookie("zoomVal");
	}
	else{
		document.all[contentid].style.zoom = '100%'; 
		//document.body.style.zoom = '100%'; 
		currZoom = '100%';
	}
	
	if (((how == "in") && (parseInt(currZoom) >= maxRate)) || ((how == "out") && (parseInt(currZoom) <= minRate)) ) {
		return; 
	}
	if (how == "in") {
		document.all[contentid].style.zoom = parseInt(document.all[contentid].style.zoom)+zoomRate+'%'
		//document.body.style.zoom = parseInt(document.body.style.zoom)+zoomRate+'%'
	}
	else {
		document.all[contentid].style.zoom = parseInt(document.all[contentid].style.zoom)-zoomRate+'%'
		//document.body.style.zoom = parseInt(document.body.style.zoom)-zoomRate+'%'
	}
	//SetCookie("zoomVal",document.body.style.zoom, 1);
	SetCookie("zoomVal",document.all[contentid].style.zoom, 1);
}



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 GoZoom(contentid){
	if(GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
		//document.all[contentid].style.zoom = GetCookie("zoomVal");
		document.body.style.zoom = GetCookie("zoomVal");
		currZoom=GetCookie("zoomVal");
	}
	else{
		//document.all[contentid].style.zoom = '100%'; 
		document.body.style.zoom = '100%'; 
		currZoom = '100%';
	}
}

function initZoomDisplay(contentid){
	var currZoom = "100%" ;

	if(GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
		currZoom=GetCookie("zoomVal");
	}
	document.all[contentid].style.zoom = currZoom ;
}

function basicZoom(){
	var currZoom = "100%" ;
	document.body.style.zoom = currZoom ;
	SetCookie("zoomVal",document.body.style.zoom, 1);
}


function object_fatch(src){
	document.write(src);
}

function mouseOver ( destobj, color ) {
  //destobj.style.backgroundColor = color;
  destobj.style.backgroundColor = '#FFD595';
}
	
	
function mouseOut ( destobj ) {
  destobj.style.backgroundColor = '';
}

//컴마 빼기
function outComma(str)
{
    comm_str = String(str);
		
	uncomm_str="";
		
	for(i=0; i<comm_str.length; i++)
	{
	   substr=comm_str.substring(i,i+1);
	   if(substr!=",")
	   	    uncomm_str += substr;
	}   	    
		
	return uncomm_str;
}		
	
//컴마 넣기		
function inComma(str)
{
    uncomm_str = String(str);
    comm_str = "";
		
    loop_j = uncomm_str.length - 3;
	
	for(j=loop_j; j>=1 ; j=j-3)
	{
		comm_str=","+uncomm_str.substring(j,j+3)+comm_str;
	}		 
	comm_str = uncomm_str.substring(0,j+3)+comm_str;
    
    return comm_str;
}

function objectTag(id, filepath, width, height)
{
	var objHTML = "";

	objHTML += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + width + "' height='" + height + "' id='" + id + "' align='middle'>";
	objHTML += "<param name='allowScriptAccess' value='always' />";
	objHTML += "<param name='movie' value='" + filepath + "' />";
	objHTML += "<param name='quality' value='high' />";
	objHTML += "<param name='wmode' value='transparent' />";
	objHTML += "<param name='salign' value='t' />";
	objHTML += "<embed src='" + filepath + "' quality='high' bgcolor='#ffffff' width='" + width + "' height='" + height + "' name='" + id + "' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	objHTML += "</object>";

	document.write(objHTML);
}

function MainobjectTag(id, filepath, width, height){
	
	var objHTML = "";

	objHTML += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + width + "' height='" + height + "' id='" + id + "'>";
	objHTML += "<param name='movie' value='" + filepath + "' />";
	objHTML += "<PARAM NAME='wmode' VALUE='transparent'>";
	objHTML += "<param name='menu' value='false'>";
	objHTML += "<param name='quality' value='high' />";
	objHTML += "<embed src='" + filepath + "' quality='high' width='" + width + "' height='" + height + "' name='" + id + "' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	objHTML += "</object>";

	document.write(objHTML);
}

function addfavorites(){ 
	var favoriteurl="";
	var favoritetitle="";
	if (document.all) 
		window.external.AddFavorite(favoriteurl,favoritetitle);
}