function check_email(email) 
{
	var pattern = "^(.+)@(.+)$";
	var atom = "\[^\\s\\(\\)<>#@,;:!\\\\\\\"\\.\\[\\]\]+";
	var word="(" + atom + "|(\"[^\"]*\"))";
	var user_pattern = new RegExp("^" + word + "(\\." + word + ")*$");
	var ip_pattern = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var domain_pattern = new RegExp("^" + atom + "(\\." + atom +")*$");

	var arr = email.match(pattern);
	if (!arr) return "Email address seems incorrect (check @ and .'s)";
	if (!arr[1].match(user_pattern)) return "The username doesn't seem to be valid.";

	var ip = arr[2].match(ip_pattern);
	if (ip) {
		for (var i=1; i<5; i++) if (ip[i] > 255) return "Destination IP address is invalid!";
	}
	else {
		if (!arr[2].match(domain_pattern)) return "The domain name doesn't seem to be valid.";
		var domain = arr[2].match(new RegExp(atom,"g"));
		if (domain.length<2) return "This address is missing a hostname!";
		if (domain[domain.length-1].length<2 || domain[domain.length-1].length>3)
				return "The address must end in a three-letter domain, or two letter country.";
	}
	return false;
}

function onlyEng( objtext1 ) {
	var inText = objtext1.value;
	var ret;
	for( var i=0; i<inText.length; i++ ) {
		ret = inText.charCodeAt(i);
		if( ( ret>126 ) ) {
			alert( "Only in English" );
			objtext1.value = "";
			objtext1.focus();
			return false;
		}
	}
}

function onlyKor( objtext1 )
{
	var str = objtext1.value;

	for(i=0; i<str.length; i++){
		if(!((str.charCodeAt(i) > 0x3130 && str.charCodeAt(i) < 0x318F) || (str.charCodeAt(i) >= 0xAC00 && str.charCodeAt(i) <= 0xD7A3)))
		{
			alert("Only Korean");
			objtext1.value = "";
			return false;
		}
	}
}


function changeCase(frmObj) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
		tmpStr = frmObj.value.toLowerCase();
		strLen = tmpStr.length;
	if (strLen > 0) {
		for (index = 0; index < strLen; index++) {
			if (index == 0) {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}else {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1)) {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
frmObj.value = tmpStr;
}

function CheckCheckbox( obj, obj_no, field_name )
{
	// ===============================
	// Obj_name Type: name_number 
	// -------------------------------
	// obj_name = obj.name.split('_');
	// obj_name[0] : Name;
	// obj_name[1] : Number;
	// ===============================

//	var obj = document.getElementById(obj_id);
	var obj_name = obj.name.split('_');

	for( i=0; i<obj_no; i++ ){
		document.getElementById( obj_name[0]+"_"+i ).checked = false;
	}

	obj.checked = true;

	document.getElementById( field_name ).value = obj.value;
}

function num_only( objtext1 ){

	var inText = objtext1.value;
	var ret;
	for( var i=0; i<inText.length; i++ ) {
		ret = inText.charCodeAt(i);
		if( ( ret<48 ) || ( ret>57 ) ) {
			alert( "Please write numbers only" );
			objtext1.value = "";
			objtext1.focus();
			return false;
		}
	}
}

function check_phone( obj )
{
	if( obj.value.substring(0,1) == "0" ){
		obj.value = obj.value.substring( 1, obj.value.length );
	}

	num_only(obj);
}