﻿/*
삭제 여부
*/
function DelChk(){
	if(!confirm("삭제하시겠습니까?")){
		return false;
	}
	return true;
}

/* CMS */
function GoCMS(){
	//새창의 크기
	cw=1000;
	ch=800;
	var opener = window.open("/_csradmin/cms/cms.html","cms","width="+cw+",height="+ch+",center=1,scrollbars=0,status=0,resizable=0,help=0");
	if(opener!=null){
			opener.focus();
	}
}


/*비밀번호 팝업*/
function popPw(indFlag, indSeq, indUrl){
		//새창의 크기
		cw=300;
		ch=180;

		var opener = window.showModalDialog("/Util/pop_Pw.aspx?flag="+indFlag+"&Seq="+indSeq, "popPw","dialogWidth=300px;dialogHeight=200px;center:yes;help:no;resizable:no;scroll:no;status:no");
		if(opener){
			location.href=indUrl;
		}
		return opener;
}

function popPw2(indFlag, indCat, indSeq, indUrl){
		//새창의 크기
		cw=300;
		ch=180;
		
		var opener = window.showModalDialog("/Util/pop_Pw.aspx?flag="+indFlag+"&sSeq="+indCat+"&Seq="+indSeq, "popPw","width="+cw+"px,height="+ch+"px,top="+py+",left="+px+",scrollbars=0,status=0,resizable=0,help=0");
		if(opener){
			location.href=indUrl;
		}
		return opener;
}

/*
이미지 팝업
*/
function ImagePopup(ind1, ind2, ind3){
	if(Number(ind2) > 800){
		ind2 = "800";
		ind3 = "600";
	}	
	var nWidth = ind2+"px";
	var nHeight = ind3+"px";
		var opener = window.open("/Util/pop_Image.aspx?img="+ind1+"&imgw="+ind2+"&imgh="+ind3, "imgp","width="+nWidth+",height="+nHeight+",center=1,scrollbars=0,status=0,resizable=0,help=0");
		if(opener!=null){
			opener.focus();
		}
}

/*
다운로드
*/
function Download(ind1, ind2){
		var opener = window.open("/Util/Download.aspx?FilePath="+ind1+"&FileName="+ind2, "download","width=1px,height=1px,top=1,left=1,scrollbars=0,status=0,resizable=0,help=0");
		if(opener!=null){
			opener.focus();
		}
}

/*
사용자 정보
*/
function UserInfoPopup(ind1, ind2, ind3, ind4, ind5, ind6){
		var opener = window.open("/Util/kor/pop_UserInfo.aspx?uName="+ind1+"&uNo="+ind2+"&dName="+ind3+"&sName="+ind4+"&email="+ind5+"&mobile="+ind6, "UserInfo","width=400px,height=320px,center=1,scrollbars=0,status=0,resizable=0,help=0");
		if(opener!=null){
			opener.focus();
		}
}

/*
우편번호
*/			
function ZipPopup(ind){
		var opener = window.open("/Util/pop_ZipCode.aspx?flag="+ind, "zipCode","width=600px,height=400px,center=1,scrollbars=1,status=0,resizable=0,help=0");
		if(opener!=null){
			opener.focus();
		}
	}

/*
관리자 메뉴 제어
*/
function MenuDisplay(ind1, ind2, ind3){
	document.getElementById("menu"+ind1).style.visibility = "visible";
	document.getElementById("td"+ind1).className = "menu_on";
	document.getElementById("ss"+ind1+ind2).className = "depth3_on";		
	document.getElementById("hlblSubTitle").innerText = document.getElementById("ss"+ind1+ind2).innerText;
	document.getElementById("himgSubTitle").src = "/eng/_csradmin/images/tit"+ind1+".gif";
}

/*
숫자이외에는 입력 X
*/
function handlerNum(ind) 
{
	if(event.keyCode < 48 || event.keyCode > 57)
		event.keyCode = null;
}

/*
이메일 체크 (표현식 사용)
*/
function emailValue(ind){
   var t = escape(ind.value);
   if(t.match(/^(\w+)@(\w+)[.](\w+)$/ig) == null && t.match(/^(\w+)@(\w+)[.](\w+)[.](\w+)$/ig) == null){
    alert("Your email address is not correct."); return false;
   }
   return true;
  }

/*
기타 값 체크 (표현식 사용)
*/
/*
function value_chk(ind, msg, flag) {	
	var chk_val = ind.value;
		var messag = "";
		if (flag == "id") {
		var numstr = /^[a-zA-Z0-9]+$/;
		messag = "에는 영문과 숫자만 입력 하실 수 있습니다."
		} else if (flag =="knum") {
			var numstr = /^[0-9.]+$/;
		messag = "에는 숫자와 (.)만 입력 하실 수 있습니다."
		} else if (flag == "E_Name") {
		var numstr = /^[a-zA-Z-[:space:]]+$/;
		messag = "에는 영문만 입력 하실 수 있습니다."
		} else if (flag == "tel") {
		var numstr = /([0-9]{2,4}[-])?[0-9]{3,4}[-][0-9]{3,4}$/;
		messag = "는(은) 전화번호 형식에 맞지 않습니다.\n\n예) 02-123-4567 또는 123-4567"
		} else if (flag == "htel") {
		var numstr = /^[0][0-9]{2}[-][0-9]{3,4}[-][0-9]{3,4}$/;
		messag = "는(은) 핸드폰 형식에 맞지 않습니다.\n\n예) 011-123-4567"
		} else if (flag == "num") {
		var numstr = /^[0-9]+$/;
		messag = "에는 숫자만 입력 하실 수 있습니다."
		} else if (flag == "ymd") {
		var numstr = /^[1-9][0-9]{3}[-][0-9]{2}[-][0-9]{2}$/;
		messag = "는(은) 날짜 형식에 맞지 않습니다.\n\n예) 2004-01-01"
		} else if (flag == "ymd2") {
		var numstr = /^[1-9][0-9]{3}[/][0-9]{1,2}$/;
		messag = "는(은) 년 월만 입력해주세요.\n\n예) 2004/01"
		} else if (flag == "ymd3") {
		var numstr = /^[1-9][0-9]{3}$/;
		messag = "는(은) 년도만 입력해주세요.\n\n예) 1995"
		} else if (flag == "img")  {
		var numstr = /.+[.]+([jJ][pP][gG]|[gG][iI][fF])$/;
		messag = "는(은) 확장자가 jpg, gif인것만 가능합니다."
		}
	
	if( !numstr.test(chk_val) ) {
		alert("\n"+msg+messag);
	  	ind.focus();
	  	return false;
	}
	return true;
}
*/


/*
기타 값 체크 (표현식 사용)
*/
function value_chk(ind, msg, flag) {	
	var chk_val = ind.value;
		var messag = "";
		if (flag == "id") {
		var numstr = /^[a-zA-Z0-9]+$/;
		messag = " english and number are available in "
		} else if (flag =="knum") {
			var numstr = /^[0-9.]+$/;
		messag = " number and (.) are available "
		} else if (flag == "E_Name") {
		var numstr = /^[a-zA-Z-[:space:]]+$/;
		messag = " english is available "
		} else if (flag == "tel") {
		var numstr = /([0-9]{2,4}[-])?[0-9]{3,4}[-][0-9]{3,4}$/;
		messag = " is incorrect format (of a phone number) "
		} else if (flag == "htel") {
		var numstr = /^[0][0-9]{2}[-][0-9]{3,4}[-][0-9]{3,4}$/;
		messag = " is incorrect format (of a mobile number) "
		} else if (flag == "num") {
		var numstr = /^[0-9]+$/;
		messag = " number is available "
		} else if (flag == "ymd") {
		var numstr = /^[1-9][0-9]{3}[/][0-9]{2}[/][0-9]{2}$/;
		messag = " is incorrect format (of a data) "
		} else if (flag == "ymd2") {
		var numstr = /^[1-9][0-9]{3}[/][0-9]{1,2}$/;
		messag = " only put year and month "
		} else if (flag == "ymd3") {
		var numstr = /^[1-9][0-9]{3}$/;
		messag = " only put year "
		} else if (flag == "img")  {
		var numstr = /.+[.]+([jJ][pP][gG]|[gG][iI][fF])$/;
		messag = " only jpg and gif are available "
		}
	
	if( !numstr.test(chk_val) ) {
		alert("\n"+msg+messag);
	  	ind.focus();
	  	return false;
	}
	return true;
}
		
/*
필수입력 체크
*/
function chkValue(ind, msg){	
	flag = true;
	if(ind.value.length!=0) {
		for(var i=0;i<ind.value.length;i++)
		{
			if(ind.value.charAt(i)==" ")flag= false;break;
		}
	} else {
		flag = false;
	}
	if (msg.length > 0){
		if (!flag) {
			alert(msg+" (Please enter) ");
			ind.focus();
			ind.select();
		}
	}
	return flag;
}


/*
Comment: 업로드 파일타입 및 길이 체크
*/
function checkFileLenOrType(ind, chkLen, chkType, imgType) {

	var fieldValue = ind.value;
	
	if (fieldValue.indexOf("'") != -1) {
		alert("파일이름에 잘못된 문자가 있습니다.");		
		ind.select();
		ind.focus();		
		return false;
	}
	
	if (fieldValue.indexOf("\"") != -1) {
		alert("파일이름에 잘못된 문자가 있습니다.");
		ind.select();
		ind.focus();		
		return false;
	}
	
	if (chkLen && !checkFilenameLen(fieldValue) ) {
	  ind.select();
		ind.focus();
		return false;
	}
	
	if (chkType && wrongAttFormat(fieldValue)) {
		alert("보안을 위해 업로드를 지원하지 않는 파일형식입니다.");
		ind.select();
		ind.focus();
		return false;
	}
	
	if (imgType && wrongImgFormat(fieldValue)) {
		alert("이미지를 첨부하지 않았거나 지원하지 않는 파일형식입니다.\n\n[jpg, gif, bmp 포맷을 지원합니다.]");
		ind.select();
		ind.focus();
		return false;
	}

	return true;
 }

/*
길이체크
*/
function checkFilenameLen (imgPath) {
	var len = imgPath.length;
	var idx = imgPath.lastIndexOf("\\");
	var sFilename = imgPath.substring(idx+1,len-4);
	if ( FilenameSize(sFilename) > 50 ) {
		alert("파일이름 길이가 제한값을 초과하였습니다.\n\n" + imgPath.substring(idx+1,len));
		return false
	} else {
		return true
	}
}

/*
파일명 체크
*/
function FilenameSize (s) {
	var i;
	var len = 0;
	for ( i=0 ; i<s.length; i++) {
		if ( s.charCodeAt(i) > 255 ) {
			len += 2;
		} else {
			len ++;
		}
	}
	return len;
}

/*
잘못된 첨부파일 포맷
*/
function wrongAttFormat(filePath) {
	var slen = filePath.lastIndexOf(".");
	var sFormat = filePath.substring(slen).toLowerCase();

	if ( sFormat == ".asp" || sFormat == ".aspx" ||
		sFormat == ".ascx" || sFormat == ".js" || sFormat == ".html" || sFormat == ".exe" || sFormat == ".com"|| sFormat == ".bat"|| sFormat == ".cs") {
		return 1
	}

	return 0
}

/*
맞는 이미지 파일 포맷
*/
function wrongImgFormat(imgPath) {
	var slen = imgPath.lastIndexOf(".");
	var sFormat = imgPath.substring(slen).toLowerCase();

	if ( sFormat == ".jpg" || sFormat == ".jpeg" ||
		sFormat == ".gif" || sFormat == ".bmp") {
		return 0
	}

	return 1
}

