// À¯Æ¿¸®Æ¼ ÇÔ¼ö
if(typeof(config_home)== "undefined"){
	var config_home = "/";
} // config_home º¯¼ö°ªÀÌ Á¸Àç ÇÏ´Â°¡ ÆÇ´Ü

function openWin(url,width,height) {
	var argv = openWin.arguments;
	var argc = openWin.arguments.length;
	var scl=(argc>3)?"yes":"no";
	var str,top,left;
	top = parseInt(screen.height/3 - height/2);
	left = parseInt(screen.width/3 - width/2);
	if(top<0) top=0;
	if(left<0) left=0;
	str="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars="+scl+",resizable=no,copyhistory=no,";
	str=str+"width="+width+",height="+height;
	str=str+",top="+top;
	str=str+",left="+left;
	var st = window.open(url,"",str);
	st.focus();
	return st;
}
function openWinS(url,width,height,pname) {
	var argv = openWinS.arguments;
	var argc = openWinS.arguments.length;
	var scl=(argc>4)?"yes":"no";
	var str,top,left;
	top = parseInt(screen.height/3 - height/2);
	left = parseInt(screen.width/3 - width/2);
	if(top<0) top=0;
	if(left<0) left=0;
	str="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars="+scl+",resizable=no,copyhistory=no,";
	str=str+"width="+width+",height="+height;
	str=str+",top="+top;
	str=str+",left="+left;
	var st = window.open(url,pname,str);
	st.focus();
	return st;
}
function openWinSr(url,width,height,pname) {
	var argv = openWinSr.arguments;
	var argc = openWinSr.arguments.length;
	var scl=(argc>4)?"yes":"no";
	var str,top,left;
	top = parseInt(screen.height/3 - height/2);
	left = parseInt(screen.width/3 - width/2);
	if(top<0) top=0;
	if(left<0) left=0;
	str="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars="+scl+",resizable=yes,copyhistory=no,";
	str=str+"width="+width+",height="+height;
	str=str+",top="+top;
	str=str+",left="+left;
	var st = window.open(url,pname,str);
	st.focus();
	return st;
}
function openWinStop(url,width,height,pname){
	var argv = openWinStop.arguments;
	var argc = openWinStop.arguments.length;
	var scl=(argc>4)?"yes":"no";
	str="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars="+scl+",resizable=yes,copyhistory=no,";
	str=str+"width="+width+",height="+height;
	str=str+",top=0,left=0";
	var st = window.open(url,pname,str);
	st.focus();
	return st;
}
function readdoc(st){
	var width=780,height=570;
	var str,top,left;
	top = parseInt(screen.height/3 - height/2);
	if(top<0) top=0;
	left = parseInt(screen.width/3 - width/2);
	str="toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,";
	str=str+"width="+width+",height="+height;
	str=str+",top="+top;
	str=str+",left="+left;
	var st = window.open(st,"Read_Doc_Win",str);
	st.focus();
	return st;
}

function PicPrevWin(st){
	var str,top,left, width, height;
	width=200;
	height=200;
	top = parseInt((screen.availHeight / 3) - (height / 2));
	left = parseInt((screen.availWidth / 3) - (width / 2));
	str="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,";
	str=str+"width=" + width + ",height=" + height;
	str=str+",top=" + top;
	str=str+",left="+left;
	ff = window.open(config_home + "usr/imgview.php?p="+st,"Image_View_Win",str);
	ff.focus();
	return ff;
}
function VODPrevWin(st){
	var str,top,left, width, height;
	width=360;
	height=400;
	top = parseInt((screen.availHeight / 3) - (height / 2));
	left = parseInt((screen.availWidth / 3) - (width / 2));
	str="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,";
	str=str+"width=" + width + ",height=" + height;
	str=str+",top=" + top;
	str=str+",left="+left;
	ff = window.open(config_home + "usr/vodview.php?p="+st,"VOD_View_Win",str);
	ff.focus();
	return ff;
}
function checkemail(st){
	if(st=="") return true;
	var email=/^([A-Za-z0-9_\.\-]{1,15})(@{1})([A-Za-z0-9_\-]{1,15})(.{1})([A-Za-z0-9_\-]{2,10})(.{1}[A-Za-z]{2,10})?(.{1}[A-Za-z\-]{2,10})?$/;
	if (!email.test(st)){
		if(checkemail.arguments.length>1){
			alert(checkemail.arguments[1]);
		}else{
			alert("eMail Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.\n\nÀÔ·ÂÇÏÁö ¾ÊÀ»°æ¿ì »èÁ¦ ÇÏ½Ê½Ã¿À");
		}
		return false;
	}
	return true;
}
function checkTelNum(st){
	var telF = /^0[0-9]{1,2}[\-\) ]{0,1}[0-9]{3,4}[\- ]{0,1}[0-9]{4}$/;
	if(st=="") return true
	if(!telF.test(st)){
		alert("ÀüÈ­¹øÈ£°¡ ¾Æ´Õ´Ï´Ù.\n\n033)1234-5678 ÇüÅÂ·Î ÀÔ·ÂÇÏ½Ê½Ã¿À\n\nÀÔ·ÂÇÏÁö ¾ÊÀ»°æ¿ì »èÁ¦ ÇÏ½Ê½Ã¿À");
		return false;
	}
	return true;
}
function chkresno(resno) {
	if(resno=="") return true;
	var fmt = /^\d{6}-[1234]\d{6}$/;
	if (!fmt.test(resno)) {
		alert("ÁÖ¹Îµî·Ï ¹øÈ£ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.\n\n¼ýÀÚ6ÀÚ¸®-¼ýÀÚ7ÀÚ¸®");
		return false;
	}
	var buf = new Array(13);
	for (i = 0; i < 6; i++) buf[i] = parseInt(resno.charAt(i));
	for (i = 6; i < 13; i++) buf[i] = parseInt(resno.charAt(i + 1));
	multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
	for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);
	if ((11 - (sum % 11)) % 10 != buf[12]) {
		alert("¿Ã¹Ù¸¥ ÁÖ¹Îµî·Ï ¹øÈ£°¡ ¾Æ´Õ´Ï´Ù.");
		return false;
	}
	return true;
}
function checkNum(){
//  onkeydown="return checkNum()" style="ime-mode:disabled" onPaste="return false"
	var argv = checkNum.arguments;
	var argc = checkNum.arguments.length;
	var ch = event.keyCode;
	if(argc>0){
		if(ch==190 || ch==110) return true;
	}
	if(ch<32 || ch==46 || ch==37 || ch==38 || ch==39 || ch==40 || (ch>=96 && ch<=105)){
		return true;
	}
	if(ch>57 || ch<48){
		return false;
	}
	return true;
}
// onmousedown="InsertTextarea(obj,str,sel)" onmouseup="obj.focus()"
function InsertTextarea(obj, text, selected) {
	if(document.selection){ // IE
		var selection = document.selection.createRange(); 
		if(selection.text)
			document.selection.clear(); 
		selection.text = text; 
		if(selected)
			selection.moveStart('character', -text.length); 
		selection.select(); 
	}else{ // FF
		var scroll = obj.scrollTop; 
		var start = obj.selectionStart; 
		var end = obj.selectionEnd; 
		obj.value = obj.value.substring(0, start) + text 
			+ obj.value.substring(end, obj.value.length); 
		if(selected)
			obj.setSelectionRange(start, start+text.length); 
		else
			obj.setSelectionRange(start+text.length, start+text.length); 
		obj.scrollTop = scroll; 
	}
}
function check_next(l1,l2,obj){
	if(l1>=l2){
		obj.focus();
	}
}
function getByte(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 == '\n') {
			if (message.charAt(i-1) != '\r') {
				nbytes += 1;
			}
		} else if (ch == '<' || ch == '>') {
		nbytes += 4;
		} else {
		nbytes += 1;
		}
	}
	return nbytes;
}
function trim(strSource) { 
	re = /^ +| +$|^\n+|\n+$|^\r+$|\r+$/g; 
	return strSource.replace(re, ''); 
} 

function ActiveXStart(id){
	var AgntUsr=navigator.userAgent.toLowerCase();
	if(AgntUsr.indexOf('msie')!=-1){ // IEÀÌ¸é
		document.write(id.text);
	}
	id.id = '';
}

//ÅØ½ºÆ® ±æÀÌ¸¦ Á¶»çÇØ ¸Æ½º length¿¡ µµ´ÞÇÏ¸é ´ÙÀ½ Ä­À¸·Î ÀÌµ¿
function moveNextTextBox(strlength,nowTextBoxId,nextTextBoxId){

	var NTB = document.getElementById(nowTextBoxId);
	var NeTB = document.getElementById(nextTextBoxId);

	var maxNum = strlength;
	if(maxNum==0) maxNum = NTB.maxLengh; 
	if(NTB.value.length >= maxNum){
		NeTB.focus();
	}
}

/*==========================================================================================
		ÄíÅ° À¯Æ¿¸®Æ¼
------------------------------------------------------------------------------------------*/
function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
   }
   return null;
}

function SetCookie (name, value) {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
      ((expires == null) ? "" : 
         ("; expires=" + expires.toGMTString())) +
      ((path == null) ? "" : ("; path=" + path)) +
      ((domain == null) ? "" : ("; domain=" + domain)) +
      ((secure == true) ? "; secure" : "");
} 
