﻿// 공백입력 체크(전부다)
function check_space(str) {
	if (str.value.length=="0") {
	return true;
	}

	for (var i=0; i<str.value.length; i++) {
		var ch=str.value.charAt(i);

		if (ch==" " || ch=="\t") {
			return true;
		}
	}
	return false;
}

// 공백입력 체크(앞부분만)
function check_null(str) {
	if (str.value.length=="0") {
		return true;
	}

	var ch=str.value.charAt(0);
	if (ch==" " || ch=="\t") {
		return true;
	}
	return false;
}

// 글자수 제한
function chk_length(textObj,min_len,max_len) {
	if(textObj.value.length >= min_len && textObj.value.length <= max_len) {
		return false;
	} else {
		return true;
	}
}

// 이메일 형식이 올바른지 체크
function emailValidator(target, isNotNull, errmsg) {
	if (!isNotNull && target.value.trim().length == 0)
	return true;

	return requiredValidator(target, errmsg) && reqularExpValidator(target, /[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+(\.[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+)*@[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+(\.[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+)*/, errmsg);
}



//GMT 시간 변환
function f_gmt(str) {

					var gmt_time 	= new Date();
					var viewHours;
					var viewMinutes;
					var viewSeconds;
					var viewMonth;
					var viewDate;
					var gmtHours 	= parseInt(gmt_time.getTimezoneOffset()/-60) ; 	//timestamp를 시간으로 나눠줌.
					var gmtMinute = gmt_time.getTimezoneOffset()%(-60) ;					//timestamp를 분으로 나눠줌.

					var now_stamp = parseInt(str)-(540*60) - gmtHours;
					gmt_time.setTime(now_stamp + "000");
					//alert(gmt_time.getHours());
					if(gmt_time.getHours() > 11) {
																											//시간에 따라 오전 오후 표시
						viewHours = 12 - gmt_time.getHours();
						if(viewHours < 0)
						  viewHours = (-1)*viewHours;
						apm="PM";
						if(viewHours == 0)
						viewHours = 12;
					} else {
						viewHours = gmt_time.getHours();
						apm="AM";
					}

					if (gmtMinute<0) {																						//분 표시를 위해서 -1을 곱함.
						gmtMinute = (-1)*gmtMinute
					}
					//시간
					if(viewHours.toString().length==1) {
					 		viewHours="0"+viewHours;
				 	}
				 	//분
					if(gmt_time.getMinutes().toString().length==1) {
					 		viewMinutes="0"+gmt_time.getMinutes();
				 	} else {
				 			viewMinutes=gmt_time.getMinutes()
				 	}
				 	//초
					if(gmt_time.getSeconds().toString().length==1) {
					 		viewSeconds="0"+gmt_time.getSeconds();
				 	}	else {
				 			viewSeconds=gmt_time.getSeconds();
				 	}

				 	//달
				 	viewMonth = gmt_time.getMonth()+1;

			  	if(viewMonth.toString().length==1) {
	 					viewMonth="0"+viewMonth;
				 	}

				 	//일
				 	if(gmt_time.getDate().toString().length==1) {
					 		viewDate="0"+gmt_time.getDate();
				 	}	else {
				 			viewDate=gmt_time.getDate();
				 	}


					//시간
					if(gmtHours.toString().length==1) {
					 		gmtHours="0"+gmtHours; 																		//10보다 작은수는 앞에 0으로 붙임
					}

					//분
					if(gmtMinute.toString().length==1) {
					 		gmtMinute="0"+gmtMinute; 																	//10보다 작은수는 앞에 0으로 붙임
				 	}

					document.write(viewHours +":");
					document.write(viewMinutes+":");
					document.write(viewSeconds+"  ");
					document.write(apm);

					if (gmtHours > 0) {
					document.write(" (GMT + " +gmtHours+" :" +gmtMinute+")  ");
					}	else if (0 > gmtHours) {
					document.write(" (GMT " +gmtHours + " :" +gmtMinute+ ")  ");
					}

					document.write(viewMonth+".");  //앞에 0붙이기
					document.write(viewDate+".");
					document.write(gmt_time.getFullYear()+"");
		}


	/*
' ------------------------------------------------------------------
' Function    : fc_chk_byte(aro_name)
' Description : 입력한 글자수를 체크
' Argument    : Object Name(글자수를 제한할 컨트롤)
' Return      :
' ------------------------------------------------------------------
*/
function fc_chk_byte(aro_name,ari_max)
{
   var ls_str     = aro_name.value; // 이벤트가 일어난 컨트롤의 value 값
   var li_str_len = ls_str.length;  // 전체길이

   // 변수초기화
   var li_max      = ari_max; // 제한할 글자수 크기
   var i           = 0;  // for문에 사용
   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( "More than " + li_max + " bytes cannot be inserted!");
      ls_str2 = ls_str.substr(0, li_len);
      aro_name.value = ls_str2;

   }
   aro_name.focus();
}

	function img_move(arrow) {
		for (i=0;i<10;i++) {
			dEI("image_li"+i).style.display="none";
		}
		if (arrow=="left") {
			for (i=0;i<5;i++) {
				dEI("image_li"+i).style.display="block";
			}
		} else if (arrow=="right") {
			for (i=5;i<10;i++) {
				dEI("image_li"+i).style.display="block";
			}
		}
	}


	function img_move1(num,arrow) {
		for (i=0;i<10;i++) {
			dEI("image_li"+num+i).style.display="none";
		}
		if (arrow=="left") {
			if(arrow != '1'){
			for (i=0;i<5;i++) {
				dEI("image_li"+num+i).style.display="block";
			}
		}
		} else if (arrow=="right") {
			for (i=5;i<10;i++) {
				dEI("image_li"+num+i).style.display="block";
			}
		}
	}
