
function fnOnlyNum(){											// 숫자만 입력

	if((event.keyCode > 47) && (event.keyCode < 60) || (event.keyCode ==9)|| (event.keyCode ==8)||(event.keyCode > 95) && (event.keyCode < 106)){
		event.returnValue=true;
	}
	else {
		event.returnValue=false ;
	}
}


function fnSearchGo(frm){

	if(frm.searchStr.value == ""){
	
		alert("검색어를 입력하세요.");
		frm.searchStr.focus();
		return false;

	}


	else{
		return true;
	}

}

function fnJuminCheck(str_serial1,str_serial2){				//주민번호 채크
 
		var digit=0
		for (var i=0;i<str_serial1.length;i++){
			var str_dig=str_serial1.substring(i,i+1);
			if (str_dig<'0' || str_dig>'9'){ 
				digit=digit+1 
			}
		}

		if ((str_serial1 == '') || ( digit != 0 )){
			return "0";   
		}

		var digit1=0
		for (var i=0;i<str_serial2.length;i++){
			var str_dig1=str_serial2.substring(i,i+1);
			if (str_dig1<'0' || str_dig1>'9'){ 
				digit1=digit1+1 
			}
		}

		if ((str_serial2 == '') || ( digit1 != 0 )){
			return "0";   
		}

		if (str_serial1.substring(2,3) > 1){
			return "0";     
		}

		if (str_serial1.substring(4,5) > 3){
			return "0";     
		} 

		if (str_serial2.substring(0,1) > 4 || str_serial2.substring(0,1) == 0){
			return "0";     
		}

		var a1=str_serial1.substring(0,1)
		var a2=str_serial1.substring(1,2)
		var a3=str_serial1.substring(2,3)
		var a4=str_serial1.substring(3,4)
		var a5=str_serial1.substring(4,5)
		var a6=str_serial1.substring(5,6)

		var check_digit=a1*2+a2*3+a3*4+a4*5+a5*6+a6*7

		var b1=str_serial2.substring(0,1)
		var b2=str_serial2.substring(1,2)
		var b3=str_serial2.substring(2,3)
		var b4=str_serial2.substring(3,4)
		var b5=str_serial2.substring(4,5)
		var b6=str_serial2.substring(5,6)
		var b7=str_serial2.substring(6,7)

		var check_digit=check_digit+b1*8+b2*9+b3*2+b4*3+b5*4+b6*5 

		check_digit = check_digit%11
		check_digit = 11 - check_digit
		check_digit = check_digit%10

		if (check_digit != b7){
			return "0";   
		}

		else{
			return "1";   
		}
}


function fnCheckSpace( str )				//빈공간 채크
{
     if(str.search(/\s/) != -1){
     	return 1;
     }

     else {
         return "";
     } 
}

function fnIsNumer(s)							//숫자인지를 판멸
{
     var isNum = /^[\d]+$/;
     if( s.search(isNum) ) return 0;
     return 1;
}

	
function fnValidID(str)								//아이디 채크
{

     if( str == ""){
//     	alert("아이디를 입력하세요.");
//     	return 0;

		return "0!!아이디를 입력하세요.";
     }

     var retVal = fnCheckSpace( str );

     if( retVal != "" ) {
//         alert("아이디는 빈 공간 없이 연속된 영문 소문자와 숫자만 사용할 수 있습니다.");
//         return 0;
			
			return "0!!아이디는 빈 공간 없이 연속된 영문 소문자와 숫자만 사용할 수 있습니다.";
     }
     if( str.charAt(0) == '_') {
//	 alert("아이디의 첫문자는 '_'로 시작할수 없습니다.");
//	 return 0;
			return "0!!아이디의 첫문자는 '_'로 시작할수 없습니다.";
     }

     /* checkFormat  */
     var isID = /^[a-z0-9_]{6,12}$/;
     if( !isID.test(str) ) {
//         alert("아이디는 6~12자의 영문 소문자와 숫자,특수기호(_)만 사용할 수 있습니다.");
//         return 0;
			return "0!!아이디는 6~12자의 영문 소문자와 숫자,특수기호(_)만 사용할 수 있습니다.";
			
     }

			return "1!!";
//     return 1;
}


function fnValidPwd(str)								//비밀번호 채크
{

     if( str == ""){
     	//alert("비밀번호를 입력하세요.");
     	//return 0;

		return "0!!비밀번호를 입력하세요."
     }

     var retVal = fnCheckSpace( str );

     if( retVal != "" ) {
         //alert("비밀번호는 빈 공간 없이 연속된 영문 소문자와 숫자만 사용할 수 있습니다.");
         //return 0;

		 return "0!!비밀번호는 빈 공간 없이 연속된 영문,소문자와 숫자만 사용할 수 있습니다."
     }

     /* checkFormat  */
     var isID = /^[a-z0-9]{6,12}$/;
     if( !isID.test(str) ) {
         //alert("비밀번호는 6~12자의 영문 소문자와 숫자만 사용할 수 있습니다.");
         //return 0;

		 return "0!!비밀번호는 6~12자의 영문,소문자와 숫자만 사용할 수 있습니다."

     }

		return "1!!"

     //return 1;
}



function fnValidImgFile(FileNameValue){			//이미지파일인지 채크

	if(FileNameValue != ""){

			var ImagePoint = FileNameValue.lastIndexOf("\\")
			var ImageLength = FileNameValue.length;
				  ImageFileName = FileNameValue.substring(ImagePoint+1,ImageLength);


			var ImageExtPoint = ImageFileName.lastIndexOf(".")
				  ImageLength = ImageFileName.length;
			var ImageExt = ImageFileName.substring(ImageExtPoint+1,ImageLength);
				  ImageExt  = ImageExt.toUpperCase();
			
				if(ImageExt != "GIF" && ImageExt != "JPG" && ImageExt != "JPEG" ){ return "0" }

				else { return "1"}
		}
}


function fnValidMovieFile(FileNameValue){				//무비파일인지 채크

				if(FileNameValue != ""){

						var ImagePoint = FileNameValue.lastIndexOf("\\")
						var ImageLength = FileNameValue.length;
						      ImageFileName = FileNameValue.substring(ImagePoint+1,ImageLength);


						var ImageExtPoint = ImageFileName.lastIndexOf(".")
						      ImageLength = ImageFileName.length;
						var ImageExt = ImageFileName.substring(ImageExtPoint+1,ImageLength);
						      ImageExt  = ImageExt.toUpperCase();
						
							if(ImageExt != "ASF" && ImageExt != "WMV" && ImageExt != "ASX"){ return "0" }

							else { return "1"}
					}
}


function fnPopModalWindow(pageUrl, windowWith, windowHeight){			//모달 팝업 띄우기

		strAppVersion = navigator.appVersion; 
		if (strAppVersion.indexOf('MSIE')!=-1 && 
			strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4) { 

			winstyle = "dialogWidth="+windowWith+"px; dialogHeight:"+windowHeight+"px; center:yes;scroll:no"; 
			window.showModelessDialog(pageUrl, null, winstyle); 
		} 
		else { 
			winpos = "left=" + ((window.screen.width-380)/2)+",top=" + ((window.screen.height-110)/2); 
			  winstyle = "width="+windowWith+",height="+windowHeight+",status=no,toolbar=no,menubar=no," + "location=no,resizable=no,scrollbars=no,copyhistory=no," + winpos; 
			  window.open(pageUrl,null,winstyle); 
		} 

}



function fnConvertWon(OBJ){				//숫자를 원으로 변경

		var ctmp = '';
		var i = 0;
		var result = '';
		var Value ='';
		
		aValue = OBJ.value.split(',');
		ArrayCnt = aValue.length;

		for(i = 0; i < ArrayCnt ; i++){

			Value = Value + aValue[i];
		}

		VLength = Value.length;
			
		for(i = 0; i < VLength; i++){
			ctmp =  Value.substring(i,i+1) + ctmp;
		}
				
		for(i = 1; i <= VLength; i++)	{
			result = ctmp.substring(i-1,i) + result;

			if(i % 3 == 0 && i < VLength) result = ','+result;
		
		}

		OBJ.value = result;
}



function fnConvertWonValue(inValue){				//숫자를 원으로 변경

		var ctmp = '';
		var i = 0;
		var result = '';
		var Value ='';
		
		inValue = inValue.toString();
		aValue = inValue.split(',');
		ArrayCnt = aValue.length;

		for(i = 0; i < ArrayCnt ; i++){

			Value = Value + aValue[i];
		}

		VLength = Value.length;
			
		for(i = 0; i < VLength; i++){
			ctmp =  Value.substring(i,i+1) + ctmp;
		}
				
		for(i = 1; i <= VLength; i++)	{
			result = ctmp.substring(i-1,i) + result;

			if(i % 3 == 0 && i < VLength) result = ','+result;
		
		}

		return result;
}



function fnCalStrBytes(strValue){									//byte 길이를 리턴해주는 함수

	var strLen = 0;

	for(i = 0; i < strValue.length;i++){
		if(escape(strValue.charAt(i)).length >= 4){
			strLen +=2;
		}
		else{
			if(escape(strValue.charAt(i)) !="%0D")
				strLen++;
		}
	}

		return strLen;
}




function fnGetRadioButtonCheckedValue(radioButtonName){

	var i, index;

	

	if(radioButtonName != undefined){

		for(i = 0; i < radioButtonName.length; i++){
			if(radioButtonName[i].type == "radio"){
				if(radioButtonName[i].checked == true){ index = i;}
			}
		}

		return radioButtonName[index].value;
	}

	else{

		return radioButtonName.value;
	}
	
}


function fnRadioButtonCheckCount(radioButtonName){

	alert(radioButtonName);

	var i, checkCount = 0;
	if(radioButtonName != undefined){
		for(i = 0; i < radioButtonName.length; i++){
			if(radioButtonName[i].type == "radio"){
				if(radioButtonName[i].checked == true){ checkCount++;}
			}
		}
	}

	else{

			if(radioButtonName != undefined){

				if(radioButtonName.checked == true){
					checkCount++;
				}

			else{
				
				}
			}
		}

	return checkCount;
}


function fnCheckboxCheckCount(checkBoxName){			//채크박스의 채크된 갯수를 리턴

	var i, checkCount = 0;

		if(checkBoxName != undefined){
			if(checkBoxName.length != undefined){
				for(i = 0 ; i < checkBoxName.length ; i++){
					if(checkBoxName[i].type == 'checkbox'){
						if(checkBoxName[i].checked){ checkCount++;}
					}
		
				}
			}

			else{

					if(checkBoxName != undefined){

						if(checkBoxName.checked == true){
							checkCount = checkCount + 1;
						}
					}

					else{
					
					}

			}
		}

	return checkCount;
}



function fnCheckboxSelectAll(checkBoxName, obj){			//채크박스를 전채 채크해주는 함수

	var i;

	if(obj.checked == true){
		checkValue = true;
	}

	else{
		checkValue = false;
	}

	if(checkBoxName != undefined){

		if(checkBoxName.length != undefined)
		{
			for(i = 0 ; i < checkBoxName.length ; i++){
				if(checkBoxName[i].type == 'checkbox'){
					if(checkBoxName[i].checked != checkValue){
						checkBoxName[i].checked = checkValue;
					}
				}
			}
		}

		else{
			checkBoxName.checked = checkValue;
		}
	}

	else{
			alert("선택할 항목이 없습니다.");
			obj.checked = false;
	}
}



function fnCheckboxSelectButton(checkBoxName, checkYn){			//채크박스를 전채 채크해주는 함수

	var i;

	if(checkYn == "Y"){
		checkValue = true;
	}

	else{
		checkValue = false;
	}

	if(checkBoxName != undefined){

		if(checkBoxName.length != undefined)
		{
			for(i = 0 ; i < checkBoxName.length ; i++){
				if(checkBoxName[i].type == 'checkbox'){
					if(checkBoxName[i].checked != checkValue){
						checkBoxName[i].checked = checkValue;
					}
				}
			}
		}

		else{
			checkBoxName.checked = checkValue;
		}
	}

	else{
			alert("선택할 항목이 없습니다.");
			obj.checked = false;
	}
}



function fnIsValidDate(yyyy, mm, dd) {				//유효한 날짜인지를 채크해주는 함수
    var m = parseInt(mm,10) - 1;
    var d = parseInt(dd,10);

    var end = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
    if ((yyyy % 4 == 0 && yyyy % 100 != 0) || yyyy % 400 == 0) {
        end[1] = 29;
    }

    return (d >= 1 && d <= end[m]);
}


function fnDateDiff(startDate, endDate){

	var startDates = "";
	var endDates = "";
	var returnValue;

	startDates = startDate.split("-");
	endDates = endDate.split("-");

	sDate = new Date(startDates[0], startDates[1], startDates[2]).getTime();
	eDate = new Date(endDates[0], endDates[1], endDates[2]).getTime();
	
	returnValue = (eDate - sDate) / (1000*60*60*24);
	
	return returnValue;
}



var request = false;

function CreateRequest(){								//Ajax 초기화함수

	try {
		request = new XMLHttpRequest();
	} 

	catch (trymicrosoft) {
		try {
			request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (othermicrosoft) {
			try {
				request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (failed) {
				request = false;
			}
		}
	}

	if (!request){ return false;}
	else{ return true;}

}

function fnValidEmail( str )
{
     /* check whether input value is included space or not  */
     if(str == ""){
     	alert("이메일 주소를 입력하세요.");
     	return 0;
     }
     var retVal = fnCheckSpace( str );
     if( retVal != "") {
         alert("이메일 주소를 빈공간 없이 넣으세요.");
         return 0;
     }

     /* checkFormat */
     var isEmail = /[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+(\.[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+)*@[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+(\.[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+)*/;
     if( !isEmail.test(str) ) {
         alert("이메일 형식이 잘못 되었습니다.");
         return 0;
     }
     if( str.length > 60 ) {
         alert("이메일 주소는 60자까지 유효합니다.");
         return 0;
     }
/*
	 if( str.lastIndexOf("daum.net") >= 0 || str.lastIndexOf("hanmail.net") >= 0 ) {
 		 alert("다음 메일 계정은 사용하실 수 없습니다.");
		 document.forms[0].email.focus();
		 return 0;
	 }
*/

     return 1;
}


function fnMemberLoginCheck(frm){

	if(frm.memberId.value == ""){
		alert("아이디를 입력하세요.");
		frm.memberId.focus();
		return false;
	}

	else if(frm.memberPwd.value == ""){
		alert("비밀번호를 입력하세요.");
		frm.memberPwd.focus();
		return false;
	}

	else{
		frm.submit();
	}

}

/*
function fnCheckSlipPaper(memberNo, memberValue){			//쪽지채크함수

	if(CreateRequest() == true){
	
		var URL = "/Common/slip_paper_check.asp?memberNo="+memberNo+"&memberValue="+memberValue;
		request.open("GET", URL, true);
		request.onreadystatechange = fnGetSlipPaper;
		request.send(null);
	}

	else{
		alert("Request Create Fail !!");
	}
}


function fnGetSlipPaper() {											//쪽지 보여주기 함수

	if (request.readyState == 4){

		 if (request.status == 404){
			alert("Request URL does not exist");
			}

		else if (request.status == 200){
		//--------------------- 정상적일때 처리
			var response = request.responseText;
		
			if(response == "1"){

				url = '/slip_paper/slip_paper.asp';
				window.open(url,"slip_paper_check","width=400,height=300");

			}

			else{

				

			}

		//-------------------------------------
		}

		else{
			alert("Error: status code is " + request.status);
		}
	}
}

*/


// len 길이만큼 prev 텍스트가 찼으면 다음(next) input으로 이동한다. 
function fnMoveFocusNext(prev, next, len)
{
	if(eval(prev).value.length == len) 
	{
		eval(next).focus();
	}
}

function fnShowDivCourseCategoryList(obj, categoryListId){

		if(categoryListId.style.visibility == "hidden"){

			categoryListId.style.visibility = "visible";

		}

		else if(categoryListId.style.visibility == "visible"){

				categoryListId.style.visibility = "hidden";

		}
}


function fnGetDefaultSelectIndex(obj){		//Select 의 기본선택인덱스를 구한다.

	for(i = 0;i < obj.length ;i++ ){

		if(obj.options[i].defaultSelected == true)
			selectIndex = i;
	}

	return selectIndex;


}



function fnShowHideLodingWindow(actionValue){

	if(actionValue == "show"){

		document.all.loading.style.filter = "alpha(opacity=30)";
		
		document.all.loading.style.top = 0;
		document.all.loading.style.left = 0;

		document.all.loading2.style.top = 0;
		document.all.loading2.style.left = 0;

		document.all.loading.style.display = "block";
		document.all.loading2.style.display = "block";

		setTimeout("fnLoadingTextBlink()", 500); 
	}

	else{
		document.all.loading.style.display = "none";
		document.all.loading2.style.display = "none";
	}
}

function fnLoadingTextBlink(){

	setTimeout("fnLoadingTextBlink()", 500); 

	if(document.all.loading_str.style.display == "block"){
		document.all.loading_str.style.display = "none";
	}

	else{
		document.all.loading_str.style.display = "block";
	}

}



function fnFileUploadingView(displayValue){

	if(displayValue == "show"){
		document.all.loading_bg.style.filter = "alpha(opacity=30)";
			
		document.all.loading_bg.style.top = 0;
		document.all.loading_bg.style.left = 0;
		document.all.fileUploding.style.top = 0;
		document.all.fileUploding.style.left = 0;

		document.all.loading_bg.style.display = "block";
		document.all.fileUploding.style.display = "block";

	}

	else{

		document.all.loading_bg.style.display = "none";
		document.all.fileUploding.style.display = "none";
		

	}

}


function fnFileZipView(displayValue){

	if(displayValue == "show"){
		document.all.loading_bg.style.filter = "alpha(opacity=30)";
			
		document.all.loading_bg.style.top = 0;
		document.all.loading_bg.style.left = 0;
		document.all.fileZip.style.top = 0;
		document.all.fileZip.style.left = 0;

		document.all.loading_bg.style.display = "block";
		document.all.fileZip.style.display = "block";

	}

	else{

		document.all.loading_bg.style.display = "none";
		document.all.fileZip.style.display = "none";
		

	}

}

function fnValidFileExt(FileNameValue, Ext){			//파일 확장자 채크

	if(FileNameValue != ""){

			var ImagePoint = FileNameValue.lastIndexOf("\\")
			var ImageLength = FileNameValue.length;
				  ImageFileName = FileNameValue.substring(ImagePoint+1,ImageLength);

			var ImageExtPoint = ImageFileName.lastIndexOf(".")
				  ImageLength = ImageFileName.length;
			var ImageExt = ImageFileName.substring(ImageExtPoint+1,ImageLength);
				  ImageExt  = ImageExt.toUpperCase();

				Exta = Ext.split("|");


				if(Exta.length > 1){

					retValue = 0;
					
					for(i = 0; i < Exta.length; i++){

						if(ImageExt == Exta[i].toUpperCase()){

							retValue = 1;
				
						}

					}
	
					return retValue;
				}
				
				else{
		
					if(ImageExt == Ext.toUpperCase()){

						return 1;
			
					}

					else{ return 0; }

				}
			
				
		}
}


function fnGotoPage(gotoPage){

	document.frmPageNavi.gotoPage.value = gotoPage;
	document.frmPageNavi.submit();

}

