//	3ÀÚ¸®¸¶´Ù ÄÞ¸¶ Âï±â
String.prototype.number_format=function(){
	return this.replace(/(\d)(?=(?:\d{3})+(?!\d))/g,'$1,');
}

// ¼ýÀÚ 3ÀÚ¸®¸¶´Ù ÄÞ¸¶ »ðÀÔ
function commaNum(num)
{  
	if (num < 0) {

		num *= -1;
		var minus = true;
	}
	else var minus = false;
	 
	var dotPos = (num+"").split(".");
	var dotU = dotPos[0];
	var dotD = dotPos[1];
	var commaFlag = dotU.length%3;

	if(commaFlag) {

		var out = dotU.substring(0, commaFlag);
		if (dotU.length > 3) out += ",";
	} 
	else var out = "";

	for (var i = commaFlag ; i < dotU.length ; i+=3) {

		out += dotU.substring(i, i+3);
		if( i < dotU.length-3) out += ",";
	}

	if(minus) out = "-" + out;
	if(dotD) return out + "." + dotD;
	else return out;
}

var n4 = (document.layers)?true:false; 
var e4 = (document.all)?true:false; 

//	¼ýÀÚ¸¸ÀÔ·Â
function keyCheck(e)
{ 
	if(n4) var keyValue = e.which 
	else if(e4) var keyValue = event.keyCode 
	if (((keyValue >= 48) && (keyValue <= 57))  || keyValue==13) return true; 
	else return false 
} 

//	ÆË¾÷
function popup(width, height, left, top, url, name, scroll)
{
	window.open(url,name,'height='+ height +', width ='+ width +',left='+ left +',top='+ top +', scrollbars='+ scroll +',resizable=yes,menubar=no,toolbar=no,location=no,status=yes');
}

// ÀÏ°ýÃ¼Å©
function Select_All()
{
	var frm = document.frm_list;
	if(frm.code_check.value == "check")
	{
		for(i=0; i < frm.elements.length ; i++) {

			if(frm.elements[i].name.substring(0,5) == "check") {

				frm.elements[i].checked = true;
				frm.code_check.value = "";
				frm.bt.value = "ÀüÃ¼Ãë¼Ò"; 
			}
		}
	}
	else {

		for(i=0; i < frm.elements.length ; i++) {

			if(frm.elements[i].name.substring(0,5) == "check") {

				frm.elements[i].checked = false;
				frm.code_check.value = "check";
				frm.bt.value = "ÀüÃ¼¼±ÅÃ"; 
			}
		}
	}
}

//	¼±ÅÃÁ¤º¸
function list_check(frm_list)
{
	for(i=0; i < frm_list.elements.length ; i++) {

		if(frm_list.elements[i].name.substring(0,5) == "check" && frm_list.elements[i].checked == true) {

			if(frm_list.mtype.value == "update") {

				msg_str="¼±ÅÃÇÑ Ç×¸ñÀ» ¼öÁ¤ÇÏ½Ã°Ú½À´Ï±î?";
			}
			else if(frm_list.mtype.value == "delete") {

				msg_str="¼±ÅÃÇÑ Ç×¸ñÀ» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?";
			}

			if(confirm(msg_str)) return true;	else return false;
		}
	}
	alert("¼±ÅÃµÈ Ç×¸ñÀÌ ¾ø½À´Ï´Ù.");
	return false;     
}

//	ÀÏ°ý Ã¼Å©
function check_all(chk_fg)
{
	var chk = document.getElementsByName('check[]');

	for(i = 0; i < chk.length; i++)
		chk[i].checked = chk_fg;
}

//	ÀÌ¹ÌÁö ¹Ì¸®º¸±â
function showPicture(src) {
  var imgObj = new Image();
  imgObj.src = src;
  var wopt = "scrollbars=no,status=no,resizable=no";
  wopt += ",width=" + imgObj.width;
  wopt += ",height=" + imgObj.height;
  var wbody = "<head><title>Image</title>";
  wbody += "<script language='javascript'>";
  wbody += "function finalResize(){";
  wbody += "  var oBody=document.body;";
  wbody += "  var oImg=document.images[0];";
  wbody += "  var xdiff=oImg.width-oBody.clientWidth;";
  wbody += "  var ydiff=oImg.height-oBody.clientHeight;";
  wbody += "  window.resizeBy(xdiff,ydiff);";
  wbody += "}";
  wbody += "</"+"script>";
  wbody += "</head>";
  wbody += "<body onLoad='finalResize()' style='margin:0'>";
  wbody += "<a href='javascript:window.close()'><img src='" + src + "' border=0></a>";
  wbody += "</body>";
  winResult = window.open("about:blank","",wopt);
  winResult.document.open("text/html", "replace");
  winResult.document.write(wbody);
  winResult.document.close();
  return;
}

// ·Î±×ÀÎ Ã¼Å©
function login_check(frm)
{
	if(frm.mem_id.value == "") {

		alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä");
		frm.mem_id.focus();
	}
	else if(frm.mem_pw.value == "") {

		alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä");
		frm.mem_pw.focus();
	}
	else return true;
	return false;
}

// »ç¿ëÈÄ±â / »óÇ°¹®ÀÇ »èÁ¦ º¸ÀÌ°í ¼û±â±â
var old_menu = '';
var old_cell = '';
function menuclick(submenu,cellbar)
{
	if( old_menu != submenu ) {

		if( old_menu !='' ) {

			old_menu.style.display = 'none';
		}

		submenu.style.display = 'block';
		old_menu = submenu;
		old_cell = cellbar;
  }
  else if( old_menu == submenu ) {

		submenu.style.display = 'none';
		old_menu = '';
		old_cell = '';
	}
}

//	°Ë»ö¾î ÇÊÅÍ
function f_search(frm)
{
	if(frm.search_name.value == "") {

		alert('°Ë»ö¾î¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä');
		frm.search_name.focus();
	}
	else return true;
	return false;
}

//	search btn º¯°æ
function imgChang(idx)
{
	//	ÀÌ¹ÌÁö Á¤º¸
	var def_artist	= document.getElementById('aimg['+ idx +']');
	var def_title	= document.getElementById('timg['+ idx +']');

	document.getElementById('aimg').src	= def_artist.value ;
	document.getElementById('timg').src = def_title.value ;
	document.getElementById('did1').style.display	= (idx == 1) ? "block" : "none" ;
	document.getElementById('did2').style.display	= (idx == 1) ? "none" : "block" ;
}

//	¹è¼ÛÁ¶È¸
function deli_chk()
{
	var iXPos;
	var iYPos;

	//Ã¢À» È­¸éÀÇ Áß¾Ó¿¡ À§Ä¡
	iXPos = (window.screen.width - 950) / 2;
	iYPos = (window.screen.height - 700) / 2;

	//ESAFE Ã¢ ¶ç¿ì±â
	window.open("about:blank", "deli", "width=950, height=660, scrollbars=yes, resizable=yes, left="+iXPos+", top="+iYPos);

	//ÁÖ¹®Á¤º¸ FORM À» ¾ÏÈ£È­ÇÏ¿© »õÃ¢À» ÅëÇØ ESAFE ¿¡°Ô Á¦ÃâÇÏ±â
	document.deli_frm.target = "deli";
	document.deli_frm.submit();	
}

/*****	ÆË¾÷Ã¢ ½ÃÀÛ	*****/
function getCookie( name ){
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}

function popupView(code, p_width, p_height, p_left, p_top, target)
{
	// ÆË¾÷ÄíÅ°È®ÀÎ
	if ( getCookie(target) != "done" ) {

		popup(p_width, p_height, p_left, p_top, "use.htm?mode=popup&code=" + code + "&target="+ target, target, 'yes');
	}
}
/*****	ÆË¾÷Ã¢ ³¡	*****/

function popup_chk(idx)
{
	obj = document.getElementsByName('p_cnt');

	for(i = 1; i <= obj.length; i++) {

		document.getElementById('p['+ i +']').src = "../images/main/t_popup_"+ i +".gif"; 
		document.getElementById('o['+ i +']').style.display = "none"; 
	}
	document.getElementById('p['+ idx +']').src = "../images/main/t_popup_"+ idx +"_on.gif";
	document.getElementById('o['+ idx +']').style.display = "block"; 
}

/***** ¸ÞÀÎ ÆË¾÷Ã¢ ½ÃÀÛ *****/
function setCookie( name, value, expiredays ) 
{ 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 

function closeWin(target) 
{ 
	setCookie(target, "done" , 1);
} 

function layerView(layer_id, target)
{
	// ÆË¾÷ÄíÅ°È®ÀÎ
	if ( getCookie(target) != "done" ) document.getElementById(layer_id).style.display = 'block';
	else document.getElementById(layer_id).style.display = 'none';
}
