function isNum(s) {
	if (parseInt(s) > 0) {
		return true;
	}
	return false;
}


function IsNumber2(str,msg) {

      for(var i = 0; i < str.length; i++) {
         var chr = str.substr(i,1);
         if(chr < '0' || chr > '9') {          
			popMsg(msg);			 
            return false;
         }
      }
      return true;   
   }

function checkNum(finput,msg) {
	if(isNum(finput.value)) {
		return true;
	} else {
		if(msg) {
			window.alert(msg);
		}
		finput.focus();
		return false;
	}
}

function isValidEmail(f) {
	var re=new RegExp("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$","gi"); 
	var str = f.value;
	var matchArray=str.match(re); 
	if (matchArray) {
		return true; 
	} else {
		alert("Email ÁÖ¼Ò°¡ Àß ¸ø ±âÀÔµÇ¾ú½À´Ï´Ù.!!");
		f.select();
		f.focus();
		return false; 
	}
}



function checkDate(finput) {
	var check = true;
	var myDate = finput.value.replace(/-/g,"");
	myDate = myDate.replace(/\s/g,"");
	myDate = myDate.replace(/\//g,"");
	if(myDate.length != 8) {
		check = false;
	}
	var year = parseInt(myDate.substr(0,4));
	var month = parseInt(myDate.substr(4,2));
	var day = parseInt(myDate.substr(6,2));
	var today = new Date();
	if(year<0 || year> today.getFullYear()) {
		check = false;
	}
	if(month<0 || month>12) {
		check = false;
	}
	if(day<0 || day>31) {
		check = false;
	}
	var pub_date = new Date(year,month,day);
	if(pub_date > today) {
		check = false;
	}
	if(!check) {
		window.alert("Àß¸øµÈ ³¯Â¥Çü½ÄÀÔ´Ï´Ù.");
		finput.focus();
	}
	return check;
}

function checkLen(finput, minLen, maxLen, inputName) {
	len=0;

	// String ±æÀÌ¸¦ ±¸ÇÏ´Â ºÎºÐ..
	for(i=0;i < finput.value.length; i++) {
		if(finput.value.charCodeAt(i) > 255) {
			len = len + 2;
		} else {
			len = len + 1;
		}
	}

	// ±æÀÌ È®ÀÎ.
	if (minLen > len) {
		if(minLen == maxLen) {
			msg = inputName + "Àº(´Â) " + minLen + "ÀÚ·Î ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù(ÇÑ±ÛÀº ±ÛÀÚ´ç 2ÀÚ·Î °è»êµË´Ï´Ù.)";
		} else {
			msg = inputName + "Àº(´Â) " + minLen + "ÀÚ¸¦ ÀÌ»ó ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù(ÇÑ±ÛÀº ±ÛÀÚ´ç 2ÀÚ·Î °è»êµË´Ï´Ù.)";
		}
		window.alert(msg);
		finput.focus();
		return false;
	}
	if (maxLen < len) {
		window.alert(inputName + "Àº(´Â) " + maxLen + "ÀÚ¸¦ ³ÑÀ» ¼ö ¾ø½À´Ï´Ù(ÇÑ±ÛÀº ±ÛÀÚ´ç 2ÀÚ·Î °è»êµË´Ï´Ù.)");
		finput.focus();
		return false;
	}
	return true;
}

function checkEmpty(finput,msg) {
	if(finput.value) {
		return true;
	} else {
		if(msg) {
			window.alert("\"" + msg + "\"¸¦(À») ÀÔ·ÂÇØÁÖ½Ê½Ã¿À.");
			finput.focus();
		}
		return false;
	}
}

function checkEmptyContent(finput,msg) {
	if(finput.value) {
		return true;
	} else {
		if(msg) {
			window.alert("\"" + msg + "\"¸¦(À») ÀÔ·ÂÇØÁÖ½Ê½Ã¿À.");
			blogeditor.focus();
		}
		return false;
	}
}

function checkEmptyPhoto(finput,msg) {
	if(finput.value) {
		return true;
	} else {
		if(msg) {
			window.alert("\"" + msg + "\"¸¦(À») ÇÑÀåÀÌ¶óµµ °°ÀÌ ¿Ã·ÁÁÖ¼¼¿ä!");
		}
		return false;
	}
}


function checkSelection(finput,msg) {
	//window.alert(finput.name);
	var i = finput.selectedIndex;
	if(finput.options[i].value == 0 || finput.options[i].value == "") {
		if(msg) {
			window.alert("\"" + msg + "\"ÀÌ(°¡) ¼±ÅÃµÇÁö ¾Ê¾Ò½À´Ï´Ù.");
			finput.focus();
		}
		return false;
	} else {
		return true;
	}
}

function checkRadio(finput,msg) {
	for( i = 0; i < finput.length; i++ ) {
		if(finput[i].checked == true) {
			return true;
		}
	}
	if(msg) {
		window.alert("\"" + msg + "\"À»(¸¦) ¼±ÅÃÇØ ÁÖ¼¼¿ä!!");
	}
	return false;
}

function checkCheck(finput,msg) {

	if (finput.length > 1) {

			for( i = 0; i < finput.length; i++ ) {
				if(finput[i].checked == true) {
					return true;
				}
			}
			if(msg) {
				window.alert("\"" + msg + "\"À»(¸¦) ¼±ÅÃÇØ ÁÖ¼¼¿ä!!");
			}
			return false;

	} else {

		finput.checked = true;
		return true;

	}
}


function setSelect(sel, value) {
	//window.alert(sel.name + ":" + value);
	if(value != "") {
		len = sel.length;
		for( i = 0; i < len; i++ ) {
			o = sel.options[i];
			//window.alert(o.value);
			if(o.value == value) {
				o.selected = true;
				break;
			}
		}
	}
}

function setRadio(rad, value) {
	if(value != "") {
		for( i = 0; i < rad.length; i++ ) {
			if( rad[i].value == value ) {
				rad[i].checked = true;
				break;
			}
		}
	}
}

function setCheck(chk, value) {
	if(value != "") {
		chk.checked = true;
	}
}

function hanCheck(finput, msg) {
	for(i=0;i<finput.value.length;i++) {
		var code=finput.value.charCodeAt(i);
		if (code > 128) {
			alert( msg + '¿¡´Â ÇÑ±ÛÀ» ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.');
			finput.value="";
			finput.focus();
			return false;
		}
	}
	return true;
}

function onlyNumber() {
	if (event.keyCode < 45 || event.keyCode > 57) {
		window.alert("¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù");
		event.keyCode = 0;
	}
}

function pl(str) {
	document.write("Javascript Debug:  ");
	document.write(str + "<br>\n");
}

function popMsg(msg) {
	window.alert(msg);
}

function popUp( url,name,toolbar,location,status,menubar,scrollbars,resizable,width,height) {
	features = "toolbar=" + toolbar + ",location=" + location + ",status=" + status + ",menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",width=" + width + ",height=" + height;
	window.open( url, name, features);
}

function link( url ) {
	if(url.length > 0) {
		url = "http://" + url;
		popUp(url,"link","yes","yes","yes","yes","yes","yes",800,600);
	}
}


function goTo(url) {
	if(url != "") {
		document.location.href = url;
	}
}

function go(target) {
	var url = "";
	switch(target) {
		case"home":
			url = "/index.php";
			break;
		case "login" :
			url = "/user/login.php";
			break;
		case "logout" :
			url = "/user/logout.php";
			break;
		case "reg" :
			url = "/pages2.php?page=user/register";
			break;
		case "findpass" :
			url = "/user/find_idpass.php";
			break;
		case "mypage" :
			url = "/mypage/mypage_list.php";
			break;
		case "customer" :
			//url = "/user/customer_center.php";
			break;
		case "sitemap" :
			//url = "/sitemap.html";
			break;
		case "intro" :
			//url = "/intro.html";
			break;
		case "usage" :
			url = "/pages2.php?page=etc/guest_use";
			break;
		case "priv" :
			url = "/pages2.php?page=user/priv_protect";
			break;
		
		case "invest" :
			url = "/invest/invest_list.php";
			break;
		case "search" :
			url = "/pages2.php?page=etc/refer_service_bank";
			break;
		default :
			//window.alert(target + " ¸Þ´º´Â Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.");
			break;
	}
	goTo(url);
}

/*
function hideMsg() {
  window.status='';
  document.MM_returnValue = true;
}

function hidestatus()
{
window.status='';
setTimeout("hidestatus()", 500);
return true

}
if (document.layers)
document.captureEvents(Event.mouseover | Event.mouseout)
document.onmouseover=hidestatus
document.onmouseout=hidestatus
document.onmousedown=hidestatus
hidestatus();
*/

function reSize()
{
	    var ParentFrame	    =	papermain.document.body;
	    var ContentFrame	=	document.all["papermain"];
	    ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight);
		//ContentFrame.style.width = ParentFrame.scrollWidth + (ParentFrame.offsetWidth - ParentFrame.clientWidth);
}



function AddFileList(text,value){
   
   var obj = document.all.filelist;
   obj[obj.length] = new Option(text, value);

	

	
	TotalFilesList();


}

function TotalFilesList() {

	var obj = document.all.filelist;

	if(obj.options.length ==1) {
				document.all.totalfilelist.value = "";
	}

	for (i=1; i <= obj.options.length-1;  i++) {
			if (i==1) {
				document.all.totalfilelist.value = obj.options[i].value;
			} else {
				document.all.totalfilelist.value  = document.all.totalfilelist.value + "," + obj.options[i].value;
			}
		}


}

function DelFileList(upDir){
	try{
		var idx = document.all.filelist.options.selectedIndex;
		if (idx == 0)
		{
			alert("»èÁ¦ÇÏ½Ç ÆÄÀÏÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä.")
			return;
		}

		var objvalue = document.all.filelist.options[idx].value;
		
		window.open("/common/edit_common/fileDelete.asp?filename=" + objvalue + "&upDir=" + upDir,"filedel","fullscreen=no,titlebar=no,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no, width=100, height=100, top=0");
		//?blogId=" + paperId + "&idx=" + idx + "&logNo=" + logNo + "&filename=" + objvalue+"&addDate="+addDate,"filedel","scrollbars=no,width=100,height=100");

	}
	catch(e){
		alert("»èÁ¦ÇÏ½Ç ÆÄÀÏÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä.")
	}
}

function DelFileListOption(filename) {
		
		for (i=document.all.filelist.options.length-1; i > 0; i--) {
			if (document.all.filelist.options[i].value == filename) {
				document.all.filelist.options[i] = null;
				break;
			}
		}

		
		TotalFilesList();
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function date_add(name)
	{
		url = "/admin/common/calendar.asp?name=" + name;
		window.open(url,"calendar","toolbar=0,location=0,menubar=0,scrollbars=no,resizable=0,width=260,height=195");
	}

	function Open_ZipCode(str) {
  
    var win;
																	
    win = window.open("common/zipcode/zipcode.asp?mode=" + str,"ZipCode","width=380,height=400,toolbar=no,memubar=no,statusbar=no,scrollbars=yes,resizable=no");
    win.focus();
}


// select box(ÄÞº¸)¿¡ ¸®½ºÆ® Ãß°¡ÇÏ±â
function ValueInsert(sel, strText,strValue) {
			var f = eval("document.writeform." + sel);
			newOptionName = new Option(strText, strValue, false, false);
			f.options[f.options.length]=newOptionName;
}

// select box(ÄÞº¸)¿¡ ¸®½ºÆ® »èÁ¦ÇÏ±â
function ValueDelete(sel,strValue) {
			var f = eval("document.writeform." + sel);
			for (i=f.options.length-1; i >= 0; i--) {
				if (f.options[i].value == strValue) {
					f.options[i] = null;
					break;
				}
			}
}