
var	objPattern1 =/^[a-zA-Z]{1}[a-zA-Z0-9_]+$/; // Ã¹±ÛÀÚ ¿µ¹®, ¿µ,¼ý,¹® »ç¿ë°¡
var	objPattern2 =/^[0-9]+$/;                   // ¼ýÀÚ¸¸ »ç¿ë°¡
var	objPattern3 =/^[a-zA-Z]+$/;                // ¿µ¹®¸¸ »ç¿ë°¡
var	objPattern4 =/^[°¡-ÆR]+$/;                 // ÇÑ±Û¸¸ »ç¿ë°¡
var	objPattern5 =/^[°¡-ÆRa-zA-Z]+$/;           // ÇÑ±Û,¿µ¹®¸¸ »ç¿ë°¡
var	objPattern6 =/^[°¡-ÆRa-zA-Z0-9]+$/;        // ÇÑ±Û,¿µ¹®,¼ýÀÚ¸¸ »ç¿ë°¡
var	objPattern7 =/^[°¡-ÆR0-9]+$/;              // ÇÑ±Û,¼ýÀÚ¸¸ »ç¿ë°¡
var	objPattern8 =/[°¡-ÆR]/;                    // ÇÑ±ÛÆ÷ÇÔ


/** ===========================================================================
Return :
Comment: Prototype
Usage  :
------------------------------------------------------------------------------*/
String.prototype.trim=function( str )
{

	str = this!=window ? this : str;

	return str.replace(/^\s+/g, "").replace(/\s+$/g, "");

}


String.prototype.hasFinalConsonant=function( str )
{

	str = this!=window ? this : str;

	var l_strTemp = str.substr(str.length - 1);

	return ((l_strTemp.charCodeAt(0)-16)%28!=0);

}


String.prototype.bytes=function( str )
{

	str=this!=window?this:str;

	var l_intLength=0;

	for(var l_intIndex = 0; l_intIndex < str.length; l_intIndex++) {
		var l_strChar=str.charAt(l_intIndex);
		l_intLength+=(l_strChar.charCodeAt() > 128) ? 2 : 1;
	}

	return l_intLength;

}


String.prototype.finalConsonant	=function()
{
	var	l_text					=this;
	l_text						=l_text.substr(l_text.length - 1);
	return	((l_text.charCodeAt(0) - 16) % 28 != 0);
}


String.prototype.postposition	=function(tail)
{
	var	l_text					=this;
	return	(l_text.trim().finalConsonant()) ? tail.substring(0,1) : tail.substring(1,2);
}


String.prototype.comma			=function()
{
	var	l_text					=this;
	var	l_pattern				=/^(-?\d+)(\d{3})($|\..*$)/;
	if (l_pattern.test(l_text))
	{
		l_text						=l_text.replace(l_pattern,function(str,p1,p2,p3)
		{
			return	p1.comma() + ("," + p2 + p3);
		});
	}
	return	l_text;
}


String.prototype.endsWith			= function(with_char,is_pattern)
{
	var	l_textLength					= this.length;
	var	l_charLength					= with_char.length;

	if (l_textLength < l_charLength)
		return	false;

	if (is_pattern)
	{
		var	l_pattern						= new	RegExp(with_char + '$','i');
		return	l_pattern.test(this);
	}
	else
		return	(l_charLength == 0 || this.substr(l_textLength - l_charLength, l_charLength) == with_char);
}


String.prototype.join			=function(addstring,delimiter)
{
	var	l_text					=this.trim();

	if (l_text == "")
		return	addstring;
	else
	{
		l_text					=(addstring.trim() == "") ? l_text : (l_text + delimiter + addstring);
		return	l_text;
	}
}


String.prototype.stripTags		=function()
{
	var	l_text					=this;

	l_text						=l_text.replace(/\n/g,"");
	l_text						=l_text.replace(/<(\/?)([^<>]*)?>/gi,"");
	return	l_text;
}


/** ===========================================================================
Return :
Comment: URL ÀÌµ¿
Usage  :
------------------------------------------------------------------------------*/
function goLinks( oUrl, oTarget, oType )
{

	if(!oTarget) {
		document.location = oUrl;
	} else if(oTarget == "1") {
		window.open(oUrl, oType, "");
	} else if(oTarget == "Home") {
		parent.document.location = oUrl;
	}

}


function goMovePage( oUrl, oTarget )
{

var	oFrame = document.getElementById(oTarget);

	if(oTarget) {
		switch(oTarget) {
			default:
				if(oFrame)
					oFrame.src = oUrl;

				break;
		}
	} else {
		window.location.href = oUrl;
	}

}

/** ===========================================================================
Return :
Comment: ÀÚµ¿ Æû Ã¼Å©
Usage  :
------------------------------------------------------------------------------*/
function onCheckFormValue( pForm )
{

	for(ii = 0; ii < pForm.elements.length; ii++) {
		if(!isCheckForm(pForm.elements[ii])) {
			return false;
		}
	}

	return true;

}


/** ===========================================================================
Return :
Comment: Æ÷Ä¿½º ÀÌµ¿
Usage  :
------------------------------------------------------------------------------*/
function onFocus( vObj, vLength, vFocus ) {

	if(vObj.value.length == vLength) {
		vFocus.focus();

		return ;
	}

}


/** =============================================================
Return :
Comment: ¾ÆÀÌÇÁ·¹ÀÓ ÀÚµ¿ ¸®»çÀÌÁî
Usage  :
---------------------------------------------------------------*/
function urlChange( vUrl, vName )
{

var tObj = document.getElementById( vName );

	tObj.src = vUrl;

}


/** =============================================================
Return :
Comment: ¾ÆÀÌÇÁ·¹ÀÓ ÀÚµ¿ ¸®»çÀÌÁî
Usage  :
---------------------------------------------------------------*/
function iFrameResize( oFrame )
{

var newHeight = oFrame.contentWindow.document.body.scrollHeight;

	oFrame.height = newHeight;

}


/** =============================================================
Return :
Comment: ¹®ÀÚ¿­ °Ë»ç
Usage  :
---------------------------------------------------------------*/
function IsNull( pObj, nLen, strError )
{

	if(nLen == 0) {
		if(pObj.value == "") {
			alert( strError );
			pObj.focus();
			return false;
		} else {
			return true;
		}
	} else {
		if(pObj.value.length < nLen) {
			alert( strError );
			pObj.focus();
			return false;
		} else {
			return true;
		}
	}

}


/** ===========================================================================
Return :
Comment: ÇÑ±ÛÀÎÁö °Ë»ç
Usage  :
------------------------------------------------------------------------------*/
function IsKorean( vObject, vLen, vTitle )
{

var vRequire = '';

	if(isKoreanChar(vObject.value) && vObject.value.length >= vLen ) {
		return true;
	}

	if(vLen > 0)
		vRequire = "\n\n'"+ vTitle +"' Ç×¸ñÀº ÇÊ¼öÇ×¸ñÀÔ´Ï´Ù.";

	alert( "'" + vTitle + "' Ç×¸ñÀº ÇÑ±Û¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù." + vRequire );
	vObject.focus();

	return false;

}


function isKoreanChar( obj )
{

var	ii;

	for(ii = 0; ii < obj.value.length; ii++) {
		var a = obj.value.charCodeAt(i);

		if(a > 128) {
			return true;
		}
	}

	return false;

}


function isKoreanLastChar( pObj, type )
{

var	hanTable = new Array();
var	cho = new Array();
var	m = new Array();
var	b = pObj.charCodeAt(0);

	hanTable[0] = "¤¡¤¢¤¤¤§¤¨¤©¤±¤²¤³¤µ¤¶¤·¤¸¤¹¤º¤»¤¼¤½¤¾";
	hanTable[1] = "¤¿¤À¤Á¤Â¤Ã¤Ä¤Å¤Æ¤Ç¤È¤É¤Ê¤Ë¤Ì¤Í¤Î¤Ï¤Ð¤Ñ¤Ò¤Ó";
	hanTable[2] = " ¤¡¤¢¤£¤¤¤¥¤¦¤§¤©¤ª¤«¤¬¤­¤®¤¯¤°¤±¤²¤´¤µ¤¶¤·¤¸¤º¤»¤¼¤½¤¾";

	hcode = b - 0xAC00;

	cho[0] = parseInt(hcode / 588);
	hcode2 = hcode % 588;

	cho[1] = parseInt(hcode2 / 28);
	cho[2] = hcode2 % 28;

	m[0] = Math.floor((b - 0xAC00) / (21 * 28));
	m[1] = Math.floor(((b - 0xAC00) % (21 * 28)) / 28);
	m[2] = (b - 0xAC00) % 28;

	if(type == "1") {
		if(m[2]) {
			return "À»";
		} else {
			return "¸¦";
		}
	} else if(type == "2") {
		if(m[2]) {
			return "Àº";
		} else {
			return "´Â";
		}
	} else if(type == "3") {
		if(m[2]) {
			return "ÀÌ";
		} else {
			return "°¡";
		}
	}

}


/** ===========================================================================
Return :
Comment: ¿µ¹®ÀÎÁö °Ë»ç
Usage  :
------------------------------------------------------------------------------*/
function ObjectIsAlphabet( vObject, vLen, vTitle )
{

var vRequire = '';

	if(isAlphabet(vObject.value) && vObject.value.length >= vLen ) {
		return true;
	}

	if(vLen > 0 )
		vRequire = "\n\n'"+vTitle+"' Ç×¸ñÀº ÇÊ¼öÇ×¸ñÀÔ´Ï´Ù.";

	alert( "'" + vTitle + "' Ç×¸ñÀº ¿µ¹®¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù." + vRequire );
	vObject.focus();

	return false;

}


function isEnglish( obj ) {

var	ii;

	for(ii = 0; ii < obj.value.length; ii++) {
		var a = obj.value.charCodeAt(ii);

		if((a >= 65 && a <= 90 ) || ( a >= 97 && a <= 122)) {
			continue;
		} else {
			return false;
		}
	}

	return true;

}


/** ===========================================================================
Return :
Comment: Æ¯¼ö¹®ÀÚ °Ë»ç
Usage  :
------------------------------------------------------------------------------*/
function isChar( obj )
{

var	alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var	numeric = '1234567890';
var	nonkorean = alpha + numeric;
var	ii ;

	for(ii = 0; ii < obj.length; ii++) {
		if(nonkorean.indexOf(obj.substring(ii, ii + 1)) < 0) {
			break ;
		}
	}

	if(ii != obj.length ) {
		return false ;
	}

	else {
		return true ;
	}

	return true;

}


/** ===========================================================================
Return :
Comment: ¼ýÀÚ °Ë»ç
Usage  :
------------------------------------------------------------------------------*/
function isNum( obj )
{

var	isnum = true;

	if(obj == null || obj == "") {
		isnum = false;

		return isnum;
	}

	for(var j = 0; j < obj.length; j++) {
		if(obj.substring(j, j + 1) != "0"
			&& obj.substring(j, j + 1) != "1"
			&& obj.substring(j, j + 1) != "2"
			&& obj.substring(j, j + 1) != "3"
			&& obj.substring(j, j + 1) != "4"
			&& obj.substring(j, j + 1) != "5"
			&& obj.substring(j, j + 1) != "6"
			&& obj.substring(j, j + 1) != "7"
			&& obj.substring(j, j + 1) != "8"
			&& obj.substring(j, j + 1) != "9" ) {
			isnum = false;
		}
	}

	return isnum;

}


/** ===========================================================================
Return :
Comment: ID Check
Usage  :
------------------------------------------------------------------------------*/
function isUserId( val, len )
{

var	valid = true;
var	cmp = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890.";

	if(!len) {
		len = 4;
	}

	if(val.length < len)
		return false;

	for(var ii = 0; ii < val.length; ii++) {
		if(cmp.indexOf(val.charAt(ii)) < 0) {
			valid = false;
			break;
		}
	}

	return valid;

}


/** ===========================================================================
Return :
Comment: Form Check
Usage  :
------------------------------------------------------------------------------*/
function isCheckForm( pObj )
{

var	len = pObj.title.length;
var length = pObj.Length;

	if(!length) {
		length = 1;
	}

	switch(pObj.type) {
		case "text":
		case "textarea":
		case "password":
			if(eval(pObj.Valid)) {
				if(!pObj.value) {
					alert(""+ pObj.title +""+ isKoreanLastChar(pObj.title.substring(len - 1, len), 1) +" ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
					pObj.focus();
					return false;
				}

				if(pObj.value.length <= length - 1) {
					alert(""+ pObj.title +""+ isKoreanLastChar(pObj.title.substring(len - 1, len), 3) +" Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù.\nÈ®ÀÎ ÈÄ ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
					pObj.focus();
					return false;
				}
			}

			if(pObj.Charset) {
				switch(pObj.Charset) {
					case 'HO':
						if(!isNum(pObj.value)) {
							alert(""+ pObj.title +""+ isKoreanLastChar(pObj.title.substring(len - 1, len), 2) +" ¼ýÀÚ¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
							pObj.value = "";
							pObj.focus();
							return false;
						}

						break;

					case 'EO':
						if(!isNum(pObj.value)) {
							alert(""+ pObj.title +""+ isKoreanLastChar(pObj.title.substring(len - 1, len), 2) +" ¿µ¹®À¸·Î¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
							pObj.value = "";
							pObj.focus();
							return false;
						}

						break;

					case 'NO':
						if(!isNum(pObj.value)) {
							alert(""+ pObj.title +""+ isKoreanLastChar(pObj.title.substring(len - 1, len), 2) +" ¼ýÀÚ¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
							pObj.value = "";
							pObj.focus();
							return false;
						}

						break;
				}
			}

			return true;
			break;

		case "select-multiple":
			if(eval(pObj.Valid)) {
				if(pObj.options.length >= 1) {
					for(var ii = 0; ii < pObj.options.length; ii++) {
						if(pForm.category.options[ii].value != "")
							pForm.category.options[ii].selected	= true;
					}
				} else {
					alert(""+ pObj.title +""+ isKoreanLastChar(pObj.title.substring(len - 1, len), 1) +" ¼±ÅÃÇØ ÁÖ¼¼¿ä.");
					return false;
				}
			}

			return true;
			break;

		case "select-one":
			if(eval(pObj.Valid)) {
				if(pObj.selectedIndex == 0) {
					alert(""+ pObj.title +""+ isKoreanLastChar(pObj.title.substring(len - 1, len), 1) +" ¼±ÅÃÇØ ÁÖ¼¼¿ä.");
					pObj.focus();
					return false;
				}
			}

			return true;
			break;

		case "checkbox":
		case "radio":
			if(eval(pObj.Valid)) {
				var cObj = eval("document.forms['"+ pObj.form.name +"']."+ pObj.name);

				for(ii = 0; ii < cObj.length; ii++) {
					if(cObj[ii].checked) {
						return true;
						break;
					}
				}

				alert(""+ pObj.title +""+ isKoreanLastChar(pObj.title.substring(len - 1, len), 1) +" ¼±ÅÃÇØ ÁÖ¼¼¿ä.");
				return false;
				break;
			} else {
				return true;
				break;
			}

		case "file":
			if(eval(pObj.Valid)) {
				if(pObj.value.length < 1) {
					alert(""+ pObj.title +""+ isKoreanLastChar(pObj.title.substring(len - 1, len), 1) +" ¼±ÅÃÇØ ÁÖ¼¼¿ä.");
						pObj.focus();
						return false;
					}
				}

				return true;
				break;

		default:
			return true;
			break;

	}

}


/** ===========================================================================
Return :
Comment: Email Check
Usage  :
------------------------------------------------------------------------------*/
function onEmail( email1, email2 )
{

var	objPattern =/^[_a-zA-Z0-9-\.]+@+[\.a-zA-Z0-9-]+\.[a-zA-Z]+$/;
var	email = email1 +"@"+ email2;

	if(!objPattern.test(email)) {
		return false ;
	}

	return true;

}


/** ===========================================================================
Return :
Comment: Email Check
Usage  :
------------------------------------------------------------------------------*/
function onEmail2( email )
{

var	objPattern =/^[_a-zA-Z0-9-\.]+@+[\.a-zA-Z0-9-]+\.[a-zA-Z]+$/;

	if(!objPattern.test(email)) {
		return false ;
	}

	return true;

}


/** ===========================================================================
Return :
Comment: Popup
Usage  :
------------------------------------------------------------------------------*/
function onPopup( fileName, winName, winWidth, winHeight, Scroll )
{

var	winPosLeft = (screen.width - winWidth) / 2;
var	winPosTop = (screen.height - winHeight) / 2;
var	winOpt = "width="+ winWidth +", height="+ winHeight +", top="+ winPosTop +", left="+ winPosLeft +", scrollbars="+ Scroll +", menubar=No, resizable=No, status=No, toolbar=No";

var	Wins = window.open(fileName, winName, winOpt + "");

	Wins.focus();

}


function onWindow( fileName, winName, Scroll )
{

var winWidth = (screen.width);
var winHeight = (screen.height);
var	winPosLeft = winWidth / 2;
var	winPosTop = winHeight / 2;
var	winOpt = "width="+ winWidth +", height="+ winHeight +", top="+ winPosTop +", left="+ winPosLeft +", scrollbars="+ Scroll +", menubar=Yes, resizable=Yes, status=Yes, toolbar=Yes";

var	Wins = window.open(fileName, winName, winOpt + "");

	Wins.focus();

}



function onClose( val )
{

	if(opener)
		opener.focus();

	self.window.close();

}


/** ===========================================================================
Return :
Comment: Dialog
Usage  :
------------------------------------------------------------------------------*/
function onDialog( HtmlFile, vOptions, nWidth, nHeight )
{

var qResult = window.showModalDialog( HtmlFile, vOptions,
          				"dialogwidth:"+ nWidth +"px;dialogheight:"+ nHeight +"px;toolbar:no;location:no;help:no;directories:no;status:no;menubar:no;scrollbars=no;resizable:no");

	return qResult;

}


/** ===========================================================================
Return :
Comment: Id, Passwd Popup
Usage  :
------------------------------------------------------------------------------*/
function onSearchIdPass( mode )
{

var Wins = "/Member/?mode="+ mode;

	onPopup(Wins, "SearchPost", 450, 386, "No", "");

}


function onShowContent( mode, code )
{


var Wins = "/Musician/?mode="+ mode +"&code="+ code;

	onPopup(Wins, "ShowContent", 930, 580, "No", "");

}


function onShowContentMovie( code, nums )
{


var Wins = "/Musician/?mode=Player&code="+ code +"&nums="+ nums;

	onPopup(Wins, "ShowContentMovie", 50, 50, "No", "");

}


function onErrorMovie()
{

var Wins = "/Help/?mode=MediaGuide";

	onPopup(Wins, "ErrorMovie", 685, 537, "No", "");

}


function onErrorLogin()
{

var Wins = "/Help/?mode=LoginGuide";

	onPopup(Wins, "ErrorLogin", 685, 537, "No", "");

}


function onShowSchool( mode, code, type )
{


var Wins = "/School/?mode="+ mode +"&code="+ code +"&type="+ type;

	onPopup(Wins, "ShowSchool", 930, 540, "No", "");

}


/** ===========================================================================
Return :
Comment: Resize
Usage  :
------------------------------------------------------------------------------*/
function onResize()
{

var	eleBody       = document.body;
var	intBodyWidth  = eleBody.scrollWidth;
var	intBodyHeight = eleBody.scrollHeight;

	intBodyHeight   = (intBodyHeight > screen.availHeight) ? screen.availHeight - 50 : intBodyHeight;
	intBodyWidth    = (intBodyWidth > screen.availWidth) ? screen.availWidth - 50 : intBodyWidth;

	eleBody.oncontextmenu = function() { return false };
	eleBody.ondreagstart  = function() { return false };
	eleBody.onselectstart = function() { return false };

	window.resizeTo(intBodyWidth + 10, intBodyHeight + 49);

}



function printPage(id)
{

	print();

}


function getFileExtension( filePath )
{

var	lastIndex = -1;
var extension = "";

	lastIndex = filePath.lastIndexOf('.');

	if(lastIndex != -1) {
		extension = filePath.substring( lastIndex + 1, filePath.len);
	} else {
		extension = "";
	}

	return extension;

}


function uploadImageCheck( obj, maxsize )
{

var	value = obj.value;
var	src   = getFileExtension(value);

	if(src == "") {
		alert('¿Ã¹Ù¸¥ ÆÄÀÏÀ» ÀÔ·ÂÇÏ¼¼¿ä!');
		resetImage(obj);
		return;
	}

	alert(obj.fileSize);
	imageCall(obj, value, maxsize);

}


function imageCall( obj, value, maxsize )
{

var	imgInfo = new Image();

	imgInfo.onload = imageLoad;
	imgInfo.maxsize = maxsize;
	imgInfo.obj = obj;
	imgInfo.src = value;

}


function imageLoad()
{

var	imgSrc, imgWidth, imgHeight, imgFileSize;
var	maxFileSize;

  imgObj = this.obj
  imgSrc = this.src;
  imgWidth = this.width;
  imgHeight = this.height;
  imgFileSize = this.fileSize;
  imgMaxSize = this.maxsize;

	if(imgMaxSize == "512") {
		maxFileSize = 51200; // ÃÖ´ë 512KB±îÁö
	} else if(imgMaxSize == "1024") {
		maxFileSize = 1024000; // ÃÖ´ë 1MB±îÁö
	} else if(imgMaxSize == "1512") {
		maxFileSize = 1512000; // ÃÖ´ë 1.5MB±îÁö
	} else if(imgMaxSize == "2048") {
		maxFileSize = 2048000; // ÃÖ´ë 2MB±îÁö
	} else if(imgMaxSize == "4096") {
		maxFileSize = 4096000; // ÃÖ´ë 4MB±îÁö
	} else if(imgMaxSize == "8192") {
		maxFileSize = 8192000; // ÃÖ´ë 8MB±îÁö
	}


	if(imgFileSize > maxFileSize) {
		if(maxFileSize / 1024 >= 1000) {
			var fileSizeDisp = maxFileSize/1024000 + "MB";
		} else {
			var fileSizeDisp = maxFileSize/1024 + "KB";
		}

		alert('¼±ÅÃÇÏ½Å ÆÄÀÏÀº Çã¿ë ÃÖ´ëÅ©±âÀÎ ' + fileSizeDisp + ' ¸¦ ÃÊ°úÇÏ¿´½À´Ï´Ù.');
		resetImage(imgObj);
		this.onload = tempBlank;

		return;
	}

}


function resetImage( obj )
{

	obj.outerHTML = obj.outerHTML;

}


function getFileSize( fileName ) {

	if(document.layers) {
		if(navigator.javaEnabled()) {
			var file = new java.io.File(fileName);

			if(location.protocol.toLowerCase() != "file:") {
				netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');
			}

			return file.length();
		} else {
			return -1;
		}
	} else if (document.all) {
		window.oldOnError = window.onerror;
		window.onerror = function (err) {

		if(err.indexOf('utomation') != -1) {
			alert('file access not possible');
			return true;
		} else {
			return false;
		}
	}

var	fso = new ActiveXObject('Scripting.FileSystemObject');
var file = fso.GetFile(fileName);

		window.onerror = window.oldOnError;
		return file.Size;
	}

}


function reloadImages( oImg ) {

var	strURL     = oImg.src;
var	objPattern = /\[+(domain)+\]+\s*/;

	strURL = (objPattern.test(strURL)) ? strURL.replace(objPattern, DEFAULT_URL) : strURL;
	oImg.src = strURL;

}


function resizeImages( oImg )
{

var	width = oImg.width;

	if(width > 1200) {
		oImg.width=1200;
	}

}