var str_number = "0123456789";
var str_email = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.-_";
var str_id = "abcdefghijklmnopqrstuvwxyz0123456789-_";
var str_pw = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

// ¾ÕÂÊ °ø¹é Á¦°Å
function Left_Trim(str) {
	i = 0;

	while(i < str.length) {
		if(str.charAt(i) == " ") {
			str = str.substring(i + 1);
			i = 0;
		} else {
			break;
		}
	}

	return str;	
}

// µÚÂÊ °ø¹é Á¦°Å
function Right_Trim(str) {
	i = str.length - 1;

	while(i >= 0) {
		if(str.charAt(i) == " ") {
			str = str.substring(0, i);
			i = str.length - 1;
		} else {
			break;
		}
	}

	return str;
}

// ¾çÂÊ °ø¹é Á¦°Å
function Trim(str) {
	str = Left_Trim(str);
	str = Right_Trim(str);

	return str;
}

// ÀÔ·Â¿©ºÎÃ¼Å©
function Fill_Check(str) {
	str = Trim(str);

	if(str.length == 0)
		return false
	else 
		return true;
}

// Ã¹¹øÂ° ÆÄ¶ó¸ÞÅ¸¸¦ º¸¿©ÁÖ°í, µÎ¹øÂ° ÆÄ¶ó¸ÞÅ¸¸¦ ¼û±ä´Ù.
function Update_UI(view, hidden) {
	document.getElementById(view).style.display = "inline";
	document.getElementById(hidden).style.display = "none";
}

function Total_Check(fm, type) {
	if(!fm["check[]"].length) {
		return;
	}

	for(i = 1; i < fm["check[]"].length; i++) {
		if(type == "1")
			fm["check[]"][i].checked = true;
		else
			fm["check[]"][i].checked = false;
	}
}

// strÀÇ °¢ ¹®ÀÚ°¡ valid_str ¿¡ Æ÷ÇÔµÇ´ÂÁö Ã¼Å© 
function Filter_Check(str, valid_str) {
	for(i = 0; i < str.length; i++) {
		if(valid_str.indexOf(str.substring(i, i + 1)) < 0) {
			return false;
		}
	}

	return true;
}

// ¾ÆÀÌµð Ã¼Å©
function Id_Check(str) {
	if(Filter_Check(str, str_id) && str.length >= 4 && str.length <= 15) {
		return true;
	}

	return false;
}

// ºñ¹ø Ã¼Å©
function Pw_Check(str) {
	if(Filter_Check(str, str_pw) && str.length >= 6 && str.length <= 16) {
		return true;
	}

	return false;
}

// ¼ýÀÚ¿©ºÎÃ¼Å©
function Is_Number(str) {
	if(Filter_Check(str, str_number)) {
		return true;
	}

	return false;
}

// ÀÌ¸ÞÀÏ Ã¼Å©
function Email_Check(str) {
	if(!Filter_Check(str, str_email)) {
		return false;
	}

	if(str.indexOf('@', 0) == -1 || str.indexOf ('.', 0) == -1) {
		return false;
	}

	return true;
}

// ÇÚµåÆù ¹øÈ£ Ã¼Å©
function Tel_Check(str) {

	if(!Is_Number(str) || str.length < 7 || str.length > 8) {
		return false;
	}
	
	return true;
}

// ÇÚµåÆù ¹øÈ£ Ã¼Å©
function Tel_Check2(str) {

	if(!Is_Number(str) || str.length < 10 || str.length > 11) {
		return false;
	}
	
	return true;
}

// ¿ìÆí¹øÈ£ Ã¼Å©
function Zip_Check(str) {

	if(!Is_Number(str) || str.length != 6) {
		return false;
	}
	
	return true;
}

// ÆË¾÷Ã¢À» ¸ð´ÏÅÍ °¡¿îµ¥ ¶ç¿ì±â
function PopUpOpen(url, name, width, height) {
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;

	winprops = "height=" + height + ", width=" + width + ", top=" + wint+ ", left=" + winl + ", scrollbars=no, resizable=no";
	window.open(url, name, winprops);
}

function PopUpOpenScroll(url, name, width, height) {
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;

	winprops = "height=" + height + ", width=" + width + ", top=" + wint+ ", left=" + winl + ", scrollbars=yes, resizable=no";
	window.open(url, name, winprops);
}

function Get_Byte_Cnt(str) {
	var len = str.length;
	var chr;
	var byte_cnt = 0;

	for(i = 0; i < len; i++) {
		chr = str.charAt(i);

		if(escape(chr).length > 4) {
			byte_cnt += 2;			
		} else {
			byte_cnt += 1;
		}
	}

	return byte_cnt;
}

function Tag_Check(Word) {
	a = Word.indexOf("<");
	b = Word.indexOf(">");

	len = Word.length;
	c = Word.substring(0, a);

	if(b == -1)
		b = a;
	
	d = Word.substring((b + 1), len);

	Word = c + d;

	tagCheck = Word.indexOf("<");

	if(tagCheck != -1)
		return false;
}

// ÇÏ´Ü ÆÐ¹Ð¸®»çÀÌÆ® ¸µÅ©
function Go_Family() {
	var url = document.getElementById("family_site").value;

	if(url != "") {
		window.open(url);
	}
}
