//»õÃ¢ ¶ç¿ì±â
function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable) {
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  //statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  statusbar_str = 'yes';
  height = height + 25;

  window.open(url, '91tv_' + name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

//·Î±×ÀÎ È®ÀÎ
function check_login() {
	window.alert("·Î±×ÀÎ ÈÄ »ç¿ëÇÏ½Ê½Ã¿À.¡¡");
	top.document.top_login_form.submit();
}

//°ø¹é Á¦°Å
function clear_space(t_item) {
	var li_length = t_item.value.length;
	if (li_length > 0) {
		if (t_item.value.substring(li_length - 1, li_length) == " ") {
			t_item.value = t_data.value.substring(0, li_length - 1);
		}
	}
}

//¼ýÀÚ ÀÔ·Â È®ÀÎ
function numeric_item_onblur(t_item) {
	if (isNaN(t_item.value) == true) {
		window.alert("¼ýÀÚ·Î ÀÔ·ÂÇÏ½Ê½Ã¿À.");
		t_item.focus();	
		return false;
	}
}


//ÇÊ¼ö ÀÔ·ÂÇ×¸ñ È®ÀÎ
function check_must(t_data) {
	var ls_space = " ";
	var lb_check_ok = true;

	if (t_data.length == 0) {
		return false;
	}

	for (var i=0; i < t_data.length; i++) {
		if (ls_space.indexOf(t_data.charAt(i)) != -1) {
			lb_check_ok = false;
		}
		else {
			lb_check_ok = true;
			break;
		}
	}

	if (lb_check_ok == false) {
		return false;
	}
	
	return true;
}


//¼ýÀÚ È®ÀÎ
function check_numeric(t_data) {
	if (isNaN(t_data) == true) {
		return false;
	}
	
	return true;
}


//ID, PW È®ÀÎ
function check_id_pw(t_id_pw) {
	if (t_id_pw.length < 4) { 
	    return false;
	}

	var ls_tmp_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

	for (var i=0; i < t_id_pw.length; i++) {
		if (ls_tmp_str.indexOf(t_id_pw.charAt(i)) == -1) {
			return false;
		}
	}

	return true;
}


//e-mail È®ÀÎ
function check_email(t_email) {
	if (t_email.length = 0) {
		return false;
	}

	var ls_tmp_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.-_;";

	for (var i=0; i < t_email.length; i++) {
		if (ls_tmp_str.indexOf(t_email.charAt(i)) == -1) {
			return false;
		}
	}
		
	if (t_email.indexOf("@") == -1) {
		return false;
	}
		
	if (t_email.indexOf(".") == -1) {
		return false;
	}
	
	return true;
}


//URL È®ÀÎ
function check_url(t_url) {
	if (t_url.length = 0) {
		return false;
	}

	var ls_tmp_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/:";

	for (var i=0; i < t_url.length; i++) {
		if (ls_tmp_str.indexOf(t_url.charAt(i)) == -1) {
			return false;
		}
	}
	
	return true;
}


//³¯Â¥ È®ÀÎ
function check_date(t_year, t_month, t_day) {
	if ((t_year.length = 0) || (t_month.length = 0) || (t_day.length = 0)) {
		return false;
	}

	if ((isNaN(t_year) == true) || (isNaN(t_month) == true) || (isNaN(t_day) == true)) {
		return false;
	}

	if (t_year.length != 4) { 
	    return false;
	}
	if (t_month.length > 2) { 
	    return false;
	}
	if (t_day.length > 2) { 
	    return false;
	}
    t_month = double_figures(t_month);
    t_day = double_figures(t_day);
		
	/*
	if ((t_year <= 2000) || (t_year >= 2010)) {
		return false;
	}
	*/
			
	if ((t_month < 1) || (t_month > 12)) {
		return false;
	}
			
	if ((t_month == 1) || (t_month == 3) || (t_month == 5) || (t_month == 7) || (t_month == 8) || (t_month == 10) || (t_month == 12)) {
		if ((t_day < 1) || (t_day > 31)) {
			return false;
		}
	}
			
	if ((t_month == 4) || (t_month == 6) || (t_month == 9) || (t_month == 11)) {
		if ((t_day < 1) || (t_day > 30)) {
			return false;
		}
	}
			
	if (t_month == 2) {
		if ((t_year % 4) == 0 && ((t_year % 100) != 0 || (t_year % 400) == 0)) {
	    	if ((t_day < 1) || (t_day > 29)) {
				return false;
			}
		}
		else {
			if ((t_day < 1) || (t_day > 28)) {
				return false;
			}
		}
	}
	
	return true;
}


//ÁÖ¹Îµî·Ï¹øÈ£È®ÀÎ
function check_ss_no(t_ssn1, t_ssn2) {
	if (t_ssn1.length != 6) {
		return false;
	}
	if (t_ssn2.length != 7) {
		return false;
	}

	var ls_space = " ";

	for (var i=0; i < t_ssn1.length; i++) {
		if (ls_space.indexOf(t_ssn1.charAt(i)) != -1) {
			return false;
		}
	}
	for (var i=0; i < t_ssn2.length; i++) {
		if (ls_space.indexOf(t_ssn2.charAt(i)) != -1) {
			return false;
		}
	}

   	if (isNaN(t_ssn1) == true) {
		return false;
	}
   	if (isNaN(t_ssn2) == true) {
		return false;
	}

   	var ls_tmp_year = t_ssn1.substring(0,2);
   	var ls_tmp_month = t_ssn1.substring(2,4);
   	var ls_tmp_day = t_ssn1.substring(4,6);
   	var ls_tmp_gender = t_ssn2.substring(0,1);

	if ((ls_tmp_gender < 1) || (ls_tmp_gender > 4)) {
		return false;
	}

	if ((ls_tmp_gender == 1) || (ls_tmp_gender == 2)) {
    	ls_tmp_year	= '19' + ls_tmp_year;
    }
    else {
    	ls_tmp_year	= '20' + ls_tmp_year;
    }
    
    if ((ls_tmp_year <= 1900) || (ls_tmp_year >= 3000)) {
    	return false;
    }
    if ((ls_tmp_month < 1) || (ls_tmp_month > 12))  {
    	return false;
    }
    
    if ((ls_tmp_month == 1) || (ls_tmp_month == 3) || (ls_tmp_month == 5) || (ls_tmp_month == 7) || (ls_tmp_month == 8) || (ls_tmp_month == 10) || (ls_tmp_month == 12)) {
    	if ((ls_tmp_day < 1) || (ls_tmp_day > 31)) {
    		return false;
    	}
    }
    if ((ls_tmp_month == 4) || (ls_tmp_month == 6) || (ls_tmp_month == 9) || (ls_tmp_month == 11)) {
    	if ((ls_tmp_day < 1) || (ls_tmp_day > 30)) {
    		return false;
    	}
    }
    if (ls_tmp_month == 2) {
    	if ((ls_tmp_year % 4) == 0 && ((ls_tmp_year % 100) != 0 || (ls_tmp_year % 400) == 0)) {
	    	if ((ls_tmp_day < 1) || (ls_tmp_day > 29)) {
    			return false;
    		}
    	}
    	else {
    		if ((ls_tmp_day < 1) || (ls_tmp_day > 28)) {
    			return false;
    		}
    	}
    }

	var ls_tmp11 = t_ssn1.substring(0,1);
	var ls_tmp12 = t_ssn1.substring(1,2);
	var ls_tmp13 = t_ssn1.substring(2,3);
	var ls_tmp14 = t_ssn1.substring(3,4);
	var ls_tmp15 = t_ssn1.substring(4,5);
	var ls_tmp16 = t_ssn1.substring(5,6);

	var ls_tmp_total = ls_tmp11 * 2 + ls_tmp12 * 3 + ls_tmp13 * 4 + ls_tmp14 * 5 + ls_tmp15 * 6 + ls_tmp16 * 7;
	
	var ls_tmp21 = t_ssn2.substring(0,1);
	var ls_tmp22 = t_ssn2.substring(1,2);
	var ls_tmp23 = t_ssn2.substring(2,3);
	var ls_tmp24 = t_ssn2.substring(3,4);
	var ls_tmp25 = t_ssn2.substring(4,5);
	var ls_tmp26 = t_ssn2.substring(5,6);
	var ls_tmp27 = t_ssn2.substring(6,7);
	
	ls_tmp_total = ls_tmp_total + ls_tmp21 * 8 + ls_tmp22 * 9 + ls_tmp23 * 2 + ls_tmp24 * 3 + ls_tmp25 * 4 + ls_tmp26 * 5;
	ls_tmp_total = ls_tmp_total % 11;
	ls_tmp_total = 11 - ls_tmp_total;
	ls_tmp_total = ls_tmp_total % 10;

	if (ls_tmp_total != ls_tmp27) {
    	return false;
	}

	return true;
}


//ÀüÈ­¹øÈ£ È®ÀÎ
function check_tel(t_tel1, t_tel2, t_tel3) {
   	if (isNaN(t_tel1) == true) {
		return false;
	}
   	if (isNaN(t_tel2) == true) {
		return false;
	}
   	if (isNaN(t_tel3) == true) {
		return false;
	}

	if (t_tel1.length < 2) {
		return false;
	}
	if (t_tel2.length < 2) {
		return false;
	}
	if (t_tel3.length < 3) {
		return false;
	}
	
   	if (t_tel1.substring(0,1) != '0') {
		return false;
	}
	
	return true;
}


//ÇÑ ÀÚ¸®¼ö·Î º¯È¯
function single_figures(t_number) {
	if ((t_number.length == 2) && (t_number.substring(0,1) == "0")) { 
	    t_number = t_number.substring(1,2);
	}
	return t_number;
}


//µÎ ÀÚ¸®¼ö·Î º¯È¯
function double_figures(t_number) {
	if (t_number.length == 1) { 
	    t_number = "0" + t_number;
	}
	return t_number;
}


//Currency ÇüÅÂ·Î º¯È¯
function currency_type(t_number) {
	var t_string = t_number + '';
	var li_length = t_string.length; 
	var n_string = ''; 
		
	for (var i=0; i < li_length; i++) { 
	    n_string += t_string.substring(i, i + 1);         
	    if (((li_length - i-1) % 3) == 0 && (li_length - i - 1) > 0 ) n_string += ','; 
	} 
	
	return n_string;
}


//ÀÌ¹ÌÁö Å©±â º¯È¯
function img_resize(obj_t_nm, li_t_width, li_t_height) {
	var li_obj_width = obj_t_nm.width;
	var li_obj_height = obj_t_nm.height;
	var li_resize_width = li_obj_width;
	var li_resize_height = li_obj_height;

	if (li_resize_width > li_t_width) {
		li_resize_width = li_t_width;
		li_resize_height = parseInt((li_obj_height * li_resize_width) / li_obj_width);
	}
	if(li_resize_height > li_t_height) {
		li_resize_width = parseInt((li_resize_width * li_t_height) / li_resize_height);
		li_resize_height = li_t_height;
	}
	obj_t_nm.width = li_resize_width;
	obj_t_nm.height = li_resize_height;
}


//ÀÌ¹ÌÁö º¸±â
function btn_img_disp_onclick(t_img_file) {
	window.open("/common/img_disp.asp?img_file=" + t_img_file, "win_img_disp", "width=1, height=1, left=0, top=0, marginwidth=0, marginheight=0, menubar=no, directories=no, resizable=no, status=yes, scrollbars=yes");
}


//iframe Å©±â º¯°æ
function resize_iframe(t_iframe_nm, t_width, t_height) {
    var ls_iframe_body = document.frames(t_iframe_nm).document.body;
    var ls_iframe_nm = document.all(t_iframe_nm);

    var li_resize_width = ls_iframe_body.scrollWidth + (ls_iframe_body.offsetWidth - ls_iframe_body.clientWidth);
    var li_resize_height = ls_iframe_body.scrollHeight + (ls_iframe_body.offsetHeight - ls_iframe_body.clientHeight);
    
    ls_iframe_nm.style.width = li_resize_width;
    
    if (li_resize_width < t_width) {
		li_resize_width = t_width;
	}
    if (li_resize_height < t_height) {
		li_resize_height = t_height;
	}

    ls_iframe_nm.style.width = li_resize_width;
    ls_iframe_nm.style.height = li_resize_height;
}

//À¯·á À½¿ø µè±â ½ÅÃ»
function charged_music() {
	window.alert("À¯·áÀ½¿ø µè±â ½ÅÃ» ÈÄ »ç¿ëÇÏ½Ê½Ã¿À.¡¡");
	document.top_login_form.action = "/members/talent/cmapply/cmapply.asp";
	document.top_login_form.submit();
}


//À½¿ø »óÅÂ È®ÀÎ
function music_status(t_status) {
	if (t_status == '0') {
		window.alert("°¨»óÇÒ ¼ö ¾ø´Â À½¿øÀÔ´Ï´Ù.¡¡");
	}
}

//¿ÞÂÊ °ø¹é Á¦°Å
String.prototype.ltrim = function() {
	var Rtn = /\s*((\S+\s*)*)/;
	return this.replace(Rtn, "$1");
}

//¿À¸¥ÂÊ °ø¹é Á¦°Å
String.prototype.rtrim = function() {
	var Rtn = /((\s*\S+)*)\s*/;
	return this.replace(Rtn, "$1");
}

//°ø¹é Á¦°Å
String.prototype.trim = function() {
	return this.ltrim().rtrim();
}

