String.prototype.isid = function() {
	if( this.length < 4 || this.length > 12 ) { return false; }
	if( this.charAt(0).search(/[^A-Za-z]/) > -1 ) { return false; }
	if( this.search(/[^A-Za-z0-9_-]{1,}/) == -1 && this.chknull() ) return true;
	else return false;
}

String.prototype.ispass = function() {
	if( this.length < 4 || this.length > 15 ) { return false; }
	if( this.search(/[^A-Za-z0-9_\-\!@#]{1,}/) == -1 && this.chknull() ) return true;
	else return false;
}

String.prototype.isemail = function() {
	if( this.search(/[A-Za-z0-9]{1,}@[A-Za-z0-9]{1,}\.[A-Za-z]{1,}$/) > -1 ) return true;
	else if( this.search(/[A-Za-z0-9]{1,}@[A-Za-z0-9]{1,}\.[A-Za-z]{2,}\.[A-Za-z]{2,}$/) > -1 ) return true;
	else return false;
}


function Popup_CenterWindow(url, wName, ww, wh,ss) {
	var oPop;
	var sw = screen.availWidth;
	var sh = screen.availHeight;

	if(ss =="")
	{
		ss="N";
	}

	if (ss=="Y")
	{
		ss="Yes";
	}else if (ss=="N")
	{
		ss="No";
	}



	sw = (sw - ww) / 2;
	sh = (sh - wh) / 2;
	
	oPop =  window.open(url, wName, "left=" + sw + ",top=" + sh + ",width=" + ww + ",height=" + wh + ",toolbar=no,menubar=no,status=no,scrollbars="+ss+",resizable=no");
	if(oPop == null) {
		alert("팝업차단을 해제해 주시기 바랍니다.");
		return null;
	} else {
		return oPop;
	}
}
function Full_openBrWindow(theURL) { //v2.0
	var larg_schermo = screen.availWidth - 8;
	var altez_schermo = screen.availHeight - 28;
        window.open(theURL,"win","width=" + larg_schermo + ",height=" + altez_schermo + ",top=0,left=0");
}
//숫자 체크
String.prototype.istel = function() {
	if( this.search(/^[0-9]*$/i) > -1 ) { return true; }
	else { return false; }
}

String.prototype.chknull = function() {
	var thisv = this;
	for (; thisv.indexOf(" ") != -1 ; )	thisv = thisv.replace(" ","");
	if( thisv.length > 0 ) return true;
	else return false;
}

String.prototype.trim = function() {
	var thisv = this;
	return thisv.replace(/^\s+/,'').replace(/\s+$/,'');
}

// HTML 특수문자를 변환
String.prototype.htmlChars = function () {
	var str = ((this.replace('"', '&')).replace('"', '"')).replace('\'', '');
	return (str.replace('<', '&lt;')).replace('>', '&gt;');
}

//global request and XML document objects
var req;

function loadXMLDoc(url, id) {
	// branch for native XMLHttpRequest object
	var URL = url;
  new Ajax.Request(URL, {
   method: 'post',
         asynchronous: true,
         contentType: 'application/x-www-form-urlencoded',
         encoding: 'UTF-8',
         parameters: {"id":id},
         onSuccess: function(xmlHttp, json) {
		  updateStatus(xmlHttp.responseText);
         },
         onFailure: function(xmlHttp, json) {
          alert('잘못된 요청입니다. (' + xmlHttp.status + ')');
         }
     });
}

//달력
function openCalendar(param) {
	var url, name, option;
	url = '/_nfm_admin/common/calendar.nfm';
	url+= '?param='+param;

	window.open(url,'calendar', 'width=100, height=200, top=10, left=10, scrollbars=no, resizable=yes');
}

// handle onreadystatechange event of req object
function processReqChange() {
	// only if req shows "loaded"
	if (req.readyState == 4) {
		// only if "OK"
		updateStatus(req.responseText);
	}
}

function idCheck(id) {
	
	if(id.length >3){
		if(!elementValue("id").isid())
		{
			//alert("아이디가 올바르지 않습니다.");
			//document.getElementById("id").focus();
			document.getElementById('id-check-text').innerHTML = '사용 할 수 없는 ID입니다.';
			document.getElementById('id-check-text').style.color = '#c00';
			document.getElementById("idchk").setAttribute("value","N");
			return false;
		}
		loadXMLDoc("/_meneger/member/adminID.nfm", id);

	}

}
function idCheckMEM(id) {
	
	if(id.length >3){
		if(!elementValue("id").isid())
		{
			
			
			//alert("아이디가 올바르지 않습니다.");
			//document.getElementById("id").focus();
			document.getElementById('id-check-text').innerHTML = '사용 할 수 없는 ID입니다.';
			document.getElementById('id-check-text').style.color = '#c00';
			document.getElementById("idchk").setAttribute("value","N");
			return false;
		}
		loadXMLDoc("userID.nfm", id);

	}

}

function updateStatus(status) {
	var text = document.getElementById('id-check-text');
	var textInput = document.getElementById('id');
	var chk = document.getElementById("idchk");

	if (status == '0') {
		text.innerHTML = '사용 할 수 없는 ID입니다.';
		text.style.color = '#c00';
		textInput.style.borderColor = '#c00';
		textInput.valid = false;
		chk.setAttribute("value","N");
	} else if (status == '1') {
		text.innerHTML = '사용 할 수 있는 ID입니다.';
		text.style.color = '#0c0';
		textInput.style.borderColor = '';
		textInput.valid = true;
		chk.setAttribute("value","Y");
	} else {
		text.innerHTML = '아이디는 영문, 숫자 4-10글자 이내로 하실 수 있습니다.';
		text.style.color = '';
		textInput.style.borderColor = '';
		textInput.valid = false;
		chk.setAttribute("value","N");


	}
}


/**** onload event func ********/
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	}else{
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
/**** onload event func ********/

function checkAll()
{
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;
	if(!document.getElementById("allchk")) return false;
	var box=document.getElementsByName("box");
	var allchk = document.getElementById("allchk");

	allchk.onclick=function(){
		for(var i=0;i<box.length;i++)
		{
			box[i].checked=true ;	
		}

	}
	

}


//### 선택 삭제 버튼 클릭시 
function allDel()
{
	
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;
	if(!document.getElementById("alldelete")) return false;
	if(!document.getElementById("box")) return false;
	var chkboxbtn = document.getElementById("alldelete");
	var box=document.getElementsByName("box");

	chkboxbtn.onclick=function(){
		var count=0;
		for(var i=0;i<box.length;i++)
		{
			if(box[i].checked){
				count ++;
			}
		}
		
		if(count ==0)
		{
			alert("삭제하실 데이터를 선택해주세요.");
			return false;
		}else{
			if(confirm("선택된 데이터를 삭제하시겠습니까?")){
				document.dForm.submit();
			}else{
				return false;
			}
		}
	}
	
}


	//#### 실명인증용
	function login()
	{

		if(!document.getElementsByTagName) return false;
		if(!document.getElementById) return false;
		if(!document.getElementById("real")) return false;
		if(!document.getElementById("ip")) return false;
		var nameok = document.getElementById("nameok");
		var ipin = document.getElementById("ipin");
		var real = document.getElementById("real");
		var ip = document.getElementById("ip");
		nameok.onclick=function(){
			

			real.style.display = "block";
			ip.style.display="none";
		}
		ipin.onclick=function(){

			real.style.display = "none";
			ip.style.display="block";
		}
	}

	
	//#### 실명인증용 팝업
    var CBA_window; 
    function openCBAWindow(){ 
        CBA_window = window.open('', 'CbaWindow', 'width=410, height=450, resizable=0, scrollbars=no, status=0, titlebar=0, toolbar=0, left=300, top=200' );
        document.reqCBAForm.action = 'https://name.siren24.com/vname/jsp/vname_j10.jsp';                     // 가상식별 실명확인서비스 URL
        document.reqCBAForm.target = 'CbaWindow';
        document.reqCBAForm.submit();
    }
    
		 //## 한국신용평가 실명인증용 팝업 
    function fnPopup(){
	   	   //한국신용평가정보 안심 실명확인 팝업페이지를 띄웁니다.	 
		   window.open('', 'popup','width=410, height=590');
		   document.reqCBAForm.target = "popup";
		   document.reqCBAForm.action = "https://cert.namecheck.co.kr/certnc_input.asp"
		   document.reqCBAForm.submit();
	   }
		
    function lnext(info,code){
    	
    	document.lForm.retInfo.value = info;
    	document.lForm.code.value = code;
    	document.lForm.chkReal.value = "Y";
    	document.lForm.submit();
    }
		
		
	 function initSubmenu(depth1, depth2, depth3) {
    	selectDepth1 = "menu" + depth1 + "-" + depth2;
    	selectDepth2 = "menu" + depth1 + "-" + depth2 + "-" + depth3;

    	nav = document.getElementById("leftmenu");
    	menuEl = nav.getElementsByTagName("li");


    	for(i = 0; i < menuEl.length; i++) {
    		if (menuEl.item(i).id == selectDepth1 || menuEl.item(i).id == selectDepth2  ) {
    			menuEl.item(i).getElementsByTagName("img").item(0).src = menuEl.item(i).getElementsByTagName("img").item(0).src.replace(".gif", "_ov.gif");
    		} else {
    			if (menuEl.item(i).getElementsByTagName("ul").item(0)) {
    				menuEl.item(i).getElementsByTagName("ul").item(0).style.display = "none";
    			}
    		}
    	}
    }
	
	function Auth(code,type) {
	    wWidth = 360;
	    wHight = 120;

	    wX = (window.screen.width - wWidth) / 2;
	    wY = (window.screen.height - wHight) / 2;

	    var w = window.open("/G-PIN/AuthRequest.jsp?code="+code+"&amp;type="+type, "gPinLoginWin", "directories=no,toolbar=no,left="+wX+",top="+wY+",width="+wWidth+",height="+wHight);
	   
	}
	
	
	function showPic(whichpic) {
		  if (!document.getElementById("placeholder")) return true;
		  var source = whichpic.getAttribute("href");
		  var placeholder = document.getElementById("placeholder");
		  placeholder.setAttribute("src",source);
		  
		  return false;
		}

		function prepareGallery() {
		  if (!document.getElementsByTagName) return false;
		  if (!document.getElementById) return false;
		  if (!document.getElementById("imagegallery")) return false;
		  var gallery = document.getElementById("imagegallery");
		  var links = gallery.getElementsByTagName("a");
		  for ( var i=0; i < links.length; i++) {
		    links[i].onclick = function() {
		      return showPic(this);
			}
		    links[i].onkeypress = links[i].onclick;
		  }
		}

addLoadEvent(prepareGallery);	
addLoadEvent(login);
addLoadEvent(allDel);
addLoadEvent(checkAll);


function aw_folk1() 
	{
			if (navigator.appName =="Netscape") {
				alert("익스플러어 에서만 사용가능합니다.");
				return false;
			}
            	if (ggChecker.check('http://cyber.museum.go.kr/web/down/ggLoader.ini')==false) 
		       	{
		            alert("다시시도 하시기 바랍니다.");
		       		return false;
		       	}
		    ggChecker.Launch('http://cyber.museum.go.kr/web/down/folk1.ggl') ;

	}
	function aw_folk2() 
	{
			if (navigator.appName =="Netscape") {
				alert("익스플러어 에서만 사용가능합니다.");
				return false;
			}
            	if (ggChecker.check('http://cyber.museum.go.kr/web/down/ggLoader.ini')==false) 
		       	{
		            alert("다시시도 하시기 바랍니다.");
		       		return false;
		       	}
		    ggChecker.Launch('http://cyber.museum.go.kr/web/down/folk2.ggl') ;

	}
	function aw_folk3() 
	{
			if (navigator.appName =="Netscape") {
				alert("익스플러어 에서만 사용가능합니다.");
				return false;
			}
            	if (ggChecker.check('http://cyber.museum.go.kr/web/down/ggLoader.ini')==false) 
		       	{
		            alert("다시시도 하시기 바랍니다.");
		       		return false;
		       	}
		    ggChecker.Launch('http://cyber.museum.go.kr/web/down/folk3.ggl') ;

	}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}	        



