
document.onkeydown=KeyEventHandle;

function KeyEventHandle() {
	if(event.keyCode == 113) {
		// ÀÌ¹ÌÁö ¸ÞÀÏ
		if(document.URL.indexOf("/Contents/IMail/") != -1) {
			helpWin = window.open('/Contents/Service/HelpMainPop.jsp?code=image','help', 'left=10, top=10, toolbar=no, location=no, directories=no, 	status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=700');

		// Å×¸¶ ¸ÞÀÏ
		}else if(document.URL.indexOf("/Contents/TMail/") != -1) {
			helpWin = window.open('/Contents/Service/HelpMainPop.jsp?code=theme','help', 'left=10, top=10, toolbar=no, location=no, directories=no, 	status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=700');

		 // ºí·Î±×
		}else if(document.URL.indexOf("/Contents/MHome/") != -1) {
			helpWin = window.open('/Contents/Service/HelpMainPop.jsp?code=minicafe','help', 'left=10, top=10, toolbar=no, location=no, directories=no, 	status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=700');

		// ¿­¸° ±ÛÅÍ
		}else if(document.URL.indexOf("/Contents/Community/") != -1) {
			helpWin = window.open('/Contents/Service/HelpMainPop.jsp?code=community','help', 'left=10, top=10, toolbar=no, location=no, directories=no, 	status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=700');

		// Çàº¹ ÀÌ¾î°¡±â
		}else if(document.URL.indexOf("/Contents/Happy/") != -1) {
			helpWin = window.open('/Contents/Service/HelpMainPop.jsp?code=happy','help', 'left=10, top=10, toolbar=no, location=no, directories=no, 	status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=700');

		// My¾î¿ï¸²
		}else if(document.URL.indexOf("/Contents/Member/") != -1) {
			helpWin = window.open('/Contents/Service/HelpMainPop.jsp?code=myawoollim','help', 'left=10, top=10, toolbar=no, location=no, directories=no, 	status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=700');

		// ·Î±×ÀÎ
		}else if(document.URL.indexOf("/Contents/Join/") != -1) {
			helpWin = window.open('/Contents/Service/HelpMainPop.jsp?code=login','help', 'left=10, top=10, toolbar=no, location=no, directories=no, 	status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=700');

		// ±×¿Ü
		}else{
			helpWin = window.open('/Contents/Service/HelpMainPop.jsp','help', 'left=10, top=10, toolbar=no, location=no, directories=no, 	status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=700');
		}
	}
}


// ¢Æ¢Æ ·ÎÄÃÆÄÀÏ·Î ÀúÀåÇÏ±â ¢Æ¢Æ 
function doSaveAs(saveAs){
	if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) {
		content = hidden_frame.document.body.innerHTML;
		content = replace(content, "*<!--", "", "", "");
		content = replace(content, "-->*", "", "", "");
		hidden_frame.document.open();
		hidden_frame.document.write("<html>");
		hidden_frame.document.write("<head>");
		hidden_frame.document.write("<title>¢Æ 'ï×'ÀÌ ÀÖ´Â ÀÎÅÍ³Ý, ¾î¿ï¸² ¢Æ</title>");
		hidden_frame.document.write("<meta http-equiv=Content-Type content=text/html; charset=euc-kr>");
		hidden_frame.document.write("<meta http-equiv=imagetoolbar content=no>");
		hidden_frame.document.write("<link rel=stylesheet href=http://www.awoollim.com/Conf/aw.css type=text/css>");
		hidden_frame.document.write("<script>");
		hidden_frame.document.write("function move(direction) {");
		hidden_frame.document.write("	marq1.start();");
		hidden_frame.document.write("	if(document.all['marq2'] != null) {");
		hidden_frame.document.write("		marq2.start();");
		hidden_frame.document.write("	}");
		hidden_frame.document.write("	if(direction == 'UP' || direction == 'up') {");
		hidden_frame.document.write("		marq1.direction = 'down';");
		hidden_frame.document.write("		if(document.all['marq2'] != null) {");
		hidden_frame.document.write("			marq2.direction = 'down';");
		hidden_frame.document.write("		}");
		hidden_frame.document.write("	}");
		hidden_frame.document.write("	else {");
		hidden_frame.document.write("		marq1.direction = 'up';");
		hidden_frame.document.write("		if(document.all['marq2'] != null) {");
		hidden_frame.document.write("			marq2.direction = 'up';");
		hidden_frame.document.write("		}");
		hidden_frame.document.write("	}");
		hidden_frame.document.write("}");
		hidden_frame.document.write("function stop() {");
		hidden_frame.document.write("	marq1.stop();");
		hidden_frame.document.write("	if(document.all['marq2'] != null) {");
		hidden_frame.document.write("		marq2.stop();");
		hidden_frame.document.write("	}");
		hidden_frame.document.write("}");
		hidden_frame.document.write("function Resize(imgZ){");
		hidden_frame.document.write("	if(document.all['img'] != null) {");
		hidden_frame.document.write("		document.all['img'].style.zoom = imgZ + '0%';");
		hidden_frame.document.write("	}");
		hidden_frame.document.write("}");
		hidden_frame.document.write(" var sRepeat=null;");
		hidden_frame.document.write(" function doScrollerIE(dir, src, amount) {");
		hidden_frame.document.write("   if (amount==null) amount=1;");
		hidden_frame.document.write("   if (dir=='up')");
		hidden_frame.document.write("      document.all[src].scrollTop-=amount;");
		hidden_frame.document.write("   else");
		hidden_frame.document.write("      document.all[src].scrollTop+=amount;");
		hidden_frame.document.write("   if (sRepeat==null)");
		hidden_frame.document.write("      sRepeat = setInterval(\"doScrollerIE('\" + dir + \"','\" + src + \"',\" + amount + \")\",100);");
		hidden_frame.document.write("   return false");
		hidden_frame.document.write(" }");
		hidden_frame.document.write("window.document.onmouseout = new Function('clearInterval(sRepeat);sRepeat=null');");
		hidden_frame.document.write("window.document.ondragstart = new Function('return false');");
		hidden_frame.document.write("var it=0;");
		hidden_frame.document.write("var typeObj;");
		hidden_frame.document.write("var mytext;");
		hidden_frame.document.write("function JJTypeWriter(){");
		hidden_frame.document.write("	it=0;");
		hidden_frame.document.write("	mytext = '';");
		hidden_frame.document.write("	mytext = condiv.innerText;");
		hidden_frame.document.write("	var myheight=condiv.offsetHeight;");
		hidden_frame.document.write("	condiv.innerText = '';");
		hidden_frame.document.write("	document.all.condiv.style.height = myheight;");
		hidden_frame.document.write("	document.all.condiv.style.visibility = 'visible';");
		hidden_frame.document.write("	typeit();");
		hidden_frame.document.write("}");
		hidden_frame.document.write("function typeit(){");
		hidden_frame.document.write("	var charText = mytext.charAt(it);");
		hidden_frame.document.write("	charText = replace(charText, '\\\r', '', true, true);");
		hidden_frame.document.write("	condiv.insertAdjacentText('beforeEnd',charText);");
		hidden_frame.document.write("	if (it < mytext.length-1){");
		hidden_frame.document.write("		it++;");
		hidden_frame.document.write("		typeObj = setTimeout('typeit()',200);");
		hidden_frame.document.write("	}	else {");
		hidden_frame.document.write("		return");
		hidden_frame.document.write("	}");
		hidden_frame.document.write("}");
		hidden_frame.document.write("function replace(target,oldTerm,newTerm,caseSens,wordOnly) { ");
		hidden_frame.document.write("  var work = target;");
		hidden_frame.document.write("  var ind = 0;");
		hidden_frame.document.write("  var next = 0; ");
		hidden_frame.document.write("  if (!caseSens) {");
		hidden_frame.document.write("    oldTerm = oldTerm.toLowerCase();");
		hidden_frame.document.write("    work = target.toLowerCase();");
		hidden_frame.document.write("  } ");
		hidden_frame.document.write("  while ((ind = work.indexOf(oldTerm,next)) >= 0) {");
		hidden_frame.document.write("    if (wordOnly) {");
		hidden_frame.document.write("      var before = ind - 1;");
		hidden_frame.document.write("      var after = ind + oldTerm.length;");
		hidden_frame.document.write("}");
		hidden_frame.document.write("    target = target.substring(0,ind) + newTerm + target.substring(ind+oldTerm.length,target.length);");
		hidden_frame.document.write("    work = work.substring(0,ind) + newTerm + work.substring(ind+oldTerm.length,work.length);");
		hidden_frame.document.write("    next = ind + newTerm.length;");
		hidden_frame.document.write("    if (next >= work.length) { break; }");
		hidden_frame.document.write("  } ");
		hidden_frame.document.write("  return target; ");
		hidden_frame.document.write("} ");
		hidden_frame.document.write("function space(check) { ");
		hidden_frame.document.write("  var space = \" .,/<>?!`';:@#$%^&*()=-|[]{}\" + '\"' + \"\\\n\t\"; ");
		hidden_frame.document.write("  for (var i = 0; i < space.length; i++)");
		hidden_frame.document.write("    if (check == space.charAt(i)) { return true; } ");
		hidden_frame.document.write("  if (check == \"\") { return true; }");
		hidden_frame.document.write("  if (check == null) { return true; } ");
		hidden_frame.document.write("  return false; ");
		hidden_frame.document.write("} ");
		hidden_frame.document.write("function filter(message) {");
		hidden_frame.document.write("	var result;");
		hidden_frame.document.write("	message = replace(message, '&', '&amp;', true, true);");
		hidden_frame.document.write("	message = replace(message, '\"', '&quot;', true, true);");
		hidden_frame.document.write("	message = replace(message, '<', '&lt;', true, true);");
		hidden_frame.document.write("	message = replace(message, '>', '&gt;', true, true);");
		hidden_frame.document.write("	return message;");
		hidden_frame.document.write("}");
/*
		hidden_frame.document.write("var embedSrc = '';");
		hidden_frame.document.write("function makeEmbed(src) {");
		hidden_frame.document.write("	embedSrc += src;");
		hidden_frame.document.write("}");
		hidden_frame.document.write("function viewEmbed() {");
		hidden_frame.document.write("	document.write(embedSrc);");
		hidden_frame.document.write("	embedSrc = '';");
		hidden_frame.document.write("}");
*/
		hidden_frame.document.write("</script>");
		hidden_frame.document.write("</head>");
		hidden_frame.document.write("<body>");
		hidden_frame.document.write(content);
		hidden_frame.document.write("</body>");
		hidden_frame.document.write("</html>");
		hidden_frame.document.close();
		hidden_frame.document.focus();
		hidden_frame.document.execCommand("SaveAs",false,saveAs);
	}else{
		alert("Áö¿øµÇÁö ¾Ê´Â ºê¶ó¿ìÀúÀÔ´Ï´Ù.    ");
	}
}


// ¢Æ¢Æ ÅøÆÁ ÀÌ¿ë¾È³» ¢Æ¢Æ 
var n = (document.layers) ? 1:0;
var ie = (document.all) ? 1:0;
function overTip(boxObj) {
if (ie) {
boxObj.style.visibility = "visible";
boxObj.filters.item(0).stop();
}
}
function outTip(boxObj) {
if (ie) {
boxObj.style.visibility = "visible";
boxObj.filters.item(0).transition = 23;
boxObj.filters.item(0).apply();
boxObj.style.visibility = "hidden";
boxObj.filters.item(0).play();
}
}


// ¢Æ¢Æ ÆË¾÷Ã¢ ½ºÅ©¸³Æ® (°æ·Î, ÆË¾÷Ã¢¸í, ¼Ó¼º) ¢Æ¢Æ 
function openNewWindow(url, name, attr) {
    open (url,name,attr);
}


// ¢Æ¢Æ ÆË¾÷Ã¢ ½ºÅ©¸³Æ® ¼¾ÅÍ¿¡ ¶ç¿ì±â(°æ·Î, ÆË¾÷Ã¢¸í, ¼Ó¼º) ¢Æ¢Æ 
var mHome;
function openCenterWindow(url, name, attr) {
	var widths = attr.lastIndexOf("width");
	var widthe = attr.indexOf(",", widths);

	var heights = attr.lastIndexOf("height");
	var heighte = attr.indexOf(",", heights);
	if(heighte == -1) {
		heighte = attr.length;
	}

	var widthstr	= attr.substring(widths, widthe);
	var heightstr= attr.substring(heights, heighte);
	var width = "";
	var height = "";

    var chars = "0123456789";
    for (var inx = 0; inx < widthstr.length; inx++) {
       if (chars.indexOf(widthstr.charAt(inx)) != -1) {
		   width += widthstr.charAt(inx); 
	   }
    }

    for (var inx = 0; inx < heightstr.length; inx++) {
       if (chars.indexOf(heightstr.charAt(inx)) != -1) {
		   height += heightstr.charAt(inx); 
	   }
    }

	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;

	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		if(name == "report_detail") {
			str += ",toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes ";
		}else if(name == "choiceMusic" || name == "search") {
			str += ",toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no ";
		}else{
			str += ",toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no ";
		}
	}
    mHome = open (url,name,str);
}


// ¢Æ¢Æ ¸¶¹ý»ç ÆíÁöÁö ÀÌ¹ÌÁö ÁÜ ¢Æ¢Æ 
function Resize(imgZ){
	if(document.all['img'] != null) {
		document.all['img'].style.zoom = imgZ + '0%';
	}
}


// ¢Æ¢Æ ÀÌ¸ÞÀÏÀÔ·Â ½ºÅ©¸³Æ® ¢Æ¢Æ 
function changeEmail()
{
	mailadd = join.emailselect.value;

	if (mailadd == "0")
	{
		alert('ÀÌ¸ÞÀÏÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä.	');
		return;
	}
	
	if (mailadd == "1")
	{
		alert('Á÷Á¢ ÀÔ·ÂÀ» ¼±ÅÃÇÏ¼Ì½À´Ï´Ù.	');
		join.email.value = join.email_id.value + "@" + join.email_addres.value;
		join.email_addres.value = "";
	}
	else
	{
		join.email.value = join.email_id.value + "@" + mailadd;
		join.email_addres.value = mailadd;
	}
}

// ¢Æ¢Æ ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å© ÇÔ¼ö ¢Æ¢Æ
function checkRegion(form) {
	var a1 = form.PassNum1.value.length;
	var a2 = form.PassNum2.value.length;
	var b1 = form.PassNum1.value;
	var b2 = form.PassNum2.value;
	var b3 = b1 + b2;
	var b4 = new Array(13);

	if (a1 != 6) { 
		alert("ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕÀÚ¸®¸¦ Á¤È®È÷ ÀÔ·Â ÇÏ¼¼¿ä.    ");
		form.PassNum1.value = "";
		form.PassNum1.focus();
		return false;
	}

	if (a2 != 7) { 
		alert("ÁÖ¹Îµî·Ï¹øÈ£ µÞÀÚ¸®¸¦ Á¤È®È÷ ÀÔ·Â ÇÏ¼¼¿ä.    ");
		form.PassNum2.value = "";
		form.PassNum2.focus();
		return false;
	}
	
	for(var i=0;i < 6;i++) b4[i]=b1.substr(i,1);
	for(var i=0;i < 7;i++) b4[i+6]=b2.substr(i,1);
	for(var sum=0,i=0;i<12;i++) sum+=b4[i]*((i>7)?(i-6):(i+2));
	var mod=11-sum%11;
	if(mod>=10) mod-=10;
	if(mod!=b4[12] || b3=="1111111111118" ) {
		alert("¿Ã¹Ù¸¥ ÁÖ¹Îµî·Ï ¹øÈ£°¡ ¾Æ´Õ´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØÁÖ¼¼¿ä.    ");
		form.PassNum1.value = "";
		form.PassNum2.value = "";
		form.PassNum1.focus();
		return false;
	}

	return true;
}

function loginCheck() {
	alert("·Î±×ÀÎ ÇÏ½Å ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.    ");
	if(document.login.name != null) {
		document.login.name.focus();
	}
}

// ÇÑ±Û ÀÔ·Â±ÝÁö
function hanCheck(x) {
	for(i=0;i<x.userID.value.length;i++) {
		var a=x.userID.value.charCodeAt(i);
		if (a > 128) {
			return false;
		}
	}
	return true;
}


/**
 * ÀÔ·Â°ªÀÌ NULLÀÎÁö Ã¼Å©
 */
function isNull(input) {
    if (input.value == null || input.value == "") {
        return true;
    }
    return false;
}


/**
 * ¼ýÀÚÇü½ÄÀ» È­Æó´ÜÀ§·Î ,¸¦ Âï¾îÁÖ´Â ÇÔ¼ö
 */
function commaSplit(srcNumber) {
	var txtNumber = '' + srcNumber;
	if (isNaN(txtNumber) || txtNumber == "") {
		alert("¼ýÀÚ¸¸ ÀÔ·Â ÇÏ¼¼¿ä    ");
		fieldName.select();
		fieldName.focus();
	} else {
		var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
		var arrNumber = txtNumber.split('.');
		arrNumber[0] += '.';
		do {
			arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
		} while (rxSplit.test(arrNumber[0]));
			if (arrNumber.length > 1) {
			return arrNumber.join('');
		} else {
			return arrNumber[0].split('.')[0];
		}
	}
}


/**
 * ÀÔ·Â°ª¿¡ ½ºÆäÀÌ½º ÀÌ¿ÜÀÇ ÀÇ¹ÌÀÖ´Â °ªÀÌ ÀÖ´ÂÁö Ã¼Å©
 */
function isEmpty(input) {
    if (input.value == null || input.value.replace(/ /gi,"") == "") {
        return true;
    }
    return false;
}

/**
 * ÀÔ·Â°ª¿¡ Æ¯Á¤ ¹®ÀÚ(chars)°¡ ÀÖ´ÂÁö Ã¼Å©
 * Æ¯Á¤ ¹®ÀÚ¸¦ Çã¿ëÇÏÁö ¾ÊÀ¸·Á ÇÒ ¶§ »ç¿ë
 * ex) if (containsChars(form.name,"!,*&^%$#@~;")) {
 *         alert("ÀÌ¸§ ÇÊµå¿¡´Â Æ¯¼ö ¹®ÀÚ¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
 *     }
 */
function containsChars(input,chars) {
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) != -1)
           return true;
    }
    return false;
}

/**
 * ÀÔ·Â°ª¿¡ Æ¯Á¤ ¹®ÀÚ(chars)°¡ ÀÖ´ÂÁö Ã¼Å©
 * Æ¯Á¤ ¹®ÀÚ¸¦ Çã¿ëÇÏÁö ¾ÊÀ¸·Á ÇÒ ¶§ »ç¿ë
 * ex) if (containsChars(form.name,"!,*&^%$#@~;")) {
 *         alert("ÀÌ¸§ ÇÊµå¿¡´Â Æ¯¼ö ¹®ÀÚ¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
 *     }
 */
function containsCharsValue(input,chars) {
    for (var inx = 0; inx < input.length; inx++) {
       if (chars.indexOf(input.charAt(inx)) != -1)
           return true;
    }
    return false;
}

/**
 * ÀÔ·Â°ª¿¡ Æ¯Á¤ ¹®ÀÚ(chars)ÀÇ °¹¼ö Ã¼Å©
 * ex) if (containsCharsNum(form.name,"!,*&^%$#@~;")) {
 *         alert("ÀÌ¸§ ÇÊµå¿¡´Â Æ¯¼ö ¹®ÀÚ¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
 *     }
 */
function containsCharsNum(input,chars) {
	var count = 0;
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) != -1)
           count++;
    }
    return count;
}

/**
 * ÀÔ·Â°ªÀÌ Æ¯Á¤ ¹®ÀÚ(chars)¸¸À¸·Î µÇ¾îÀÖ´ÂÁö Ã¼Å©
 * Æ¯Á¤ ¹®ÀÚ¸¸ Çã¿ëÇÏ·Á ÇÒ ¶§ »ç¿ë
 * ex) if (!containsCharsOnly(form.blood,"ABO")) {
 *         alert("Ç÷¾×Çü ÇÊµå¿¡´Â A,B,O ¹®ÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.");
 *     }
 */
function containsCharsOnly(input,chars) {
    for (var inx = 0; inx < input.length; inx++) {
       if (chars.indexOf(input.charAt(inx)) == -1)
           return false;
    }
    return true;
}

/**
 * ÀÔ·Â°ªÀÌ ¾ËÆÄºªÀÎÁö Ã¼Å©
 * ¾Æ·¡ isAlphabet() ºÎÅÍ isNumComma()±îÁöÀÇ ¸Þ¼Òµå°¡
 * ÀÚÁÖ ¾²ÀÌ´Â °æ¿ì¿¡´Â var chars º¯¼ö¸¦ 
 * global º¯¼ö·Î ¼±¾ðÇÏ°í »ç¿ëÇÏµµ·Ï ÇÑ´Ù.
 * ex) var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 *     var lowercase = "abcdefghijklmnopqrstuvwxyz"; 
 *     var number    = "0123456789";
 *     function isAlphaNum(input) {
 *         var chars = uppercase + lowercase + number;
 *         return containsCharsOnly(input,chars);
 *     }
 */
function isAlphabet(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    return containsCharsOnly(input,chars);
}

/**
 * ÀÔ·Â°ªÀÌ ¾ËÆÄºª ´ë¹®ÀÚÀÎÁö Ã¼Å©
 */
function isUpperCase(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    return containsCharsOnly(input,chars);
}

/**
 * ÀÔ·Â°ªÀÌ ¾ËÆÄºª ¼Ò¹®ÀÚÀÎÁö Ã¼Å©
 */
function isLowerCase(input) {
    var chars = "abcdefghijklmnopqrstuvwxyz";
    return containsCharsOnly(input,chars);
}

/**
 * ÀÔ·Â°ª¿¡ ¼ýÀÚ¸¸ ÀÖ´ÂÁö Ã¼Å©
 */
function isNumber(input) {
    var chars = "0123456789";
    return containsCharsOnly(input,chars);
}

/**
 * ÀÔ·Â°ª¿¡ ¼ýÀÚ¸¸ ÀÖ´ÂÁö Ã¼Å©(value¸¦ ¹Þ¾Æ¼­)
 */
function isNumberValue(input) {
    var chars = "0123456789";
    for (var inx = 0; inx < input.length; inx++) {
       if (chars.indexOf(input.charAt(inx)) == -1)
           return false;
    }
	return true;
}

/**
 * ÀÔ·Â°ªÀÌ ¾ËÆÄºª,¼ýÀÚ·Î µÇ¾îÀÖ´ÂÁö Ã¼Å©
 */
function isAlphaNum(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    return containsCharsOnly(input,chars);
}

/**
 * ÀÔ·Â°ªÀÌ ¼ýÀÚ,´ë½Ã(-)·Î µÇ¾îÀÖ´ÂÁö Ã¼Å©
 */
function isNumDash(input) {
    var chars = "-0123456789";
    return containsCharsOnly(input,chars);
}

/**
 * ÀÔ·Â°ªÀÌ ¼ýÀÚ,ÄÞ¸¶(,)·Î µÇ¾îÀÖ´ÂÁö Ã¼Å©
 */
function isNumComma(input) {
    var chars = ",0123456789";
    return containsCharsOnly(input,chars);
}

/**
 * ÀÔ·Â°ª¿¡¼­ ÄÞ¸¶¸¦ ¾ø¾Ø´Ù.
 */
function removeComma(input) {
    return input.value.replace(/,/gi,"");
}

/**
 * ÀÔ·Â°ª¿¡¼­ (-)¸¦ ¾ø¾Ø´Ù.
 */
function removeSlash(input) {
    return input.replace(/-/gi,"");
}

/**
 * ÀÔ·Â°ªÀÌ »ç¿ëÀÚ°¡ Á¤ÀÇÇÑ Æ÷¸Ë Çü½ÄÀÎÁö Ã¼Å©
 * ÀÚ¼¼ÇÑ format Çü½ÄÀº ÀÚ¹Ù½ºÅ©¸³Æ®ÀÇ 'regular expression'À» ÂüÁ¶
 */
function isValidFormat(input,format) {
    if (input.value.search(format) != -1) {
        return true; //¿Ã¹Ù¸¥ Æ÷¸Ë Çü½Ä
    }
    return false;
}

/**
 * ÀÔ·Â°ªÀÌ »ç¿ëÀÚ°¡ Á¤ÀÇÇÑ Æ÷¸Ë Çü½ÄÀÎÁö Ã¼Å©
 * ÀÚ¼¼ÇÑ format Çü½ÄÀº ÀÚ¹Ù½ºÅ©¸³Æ®ÀÇ 'regular expression'À» ÂüÁ¶
 * value¸¦ ¹ÞÀ½
 */
function isValidValueFormat(input,format) {
    if (input.search(format) != -1) {
        return true; //¿Ã¹Ù¸¥ Æ÷¸Ë Çü½Ä
    }
    return false;
}

/**
 * ÀÔ·Â°ªÀÌ ÀÌ¸ÞÀÏ Çü½ÄÀÎÁö Ã¼Å©
 */
function isValidEmail(input) {
//    var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/;
    var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
    return isValidFormat(input,format);
}

/**
 * ÀÔ·Â°ªÀÌ ÀÌ¸ÞÀÏ Çü½ÄÀÎÁö Ã¼Å©(value)
 */
function isValidValueEmail(input) {
//    var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/;
    var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
    return isValidValueFormat(input,format);
}

/**
* ÀÌ¸ÞÀÏÀÇ ÁÖ¼ÒºÎºÐ¸¸ Ã¼Å©(value)
*/
function isValidValueEmailAddress(input) {
//    var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/;
    var format = /^((\w|[\-\.])+)\.([A-Za-z]+)$/;
    return isValidValueFormat(input,format);
}

/**
 * ÀÔ·Â°ªÀÌ ÀüÈ­¹øÈ£ Çü½Ä(¼ýÀÚ-¼ýÀÚ-¼ýÀÚ)ÀÎÁö Ã¼Å©
 */
function isValidPhone(input) {
    var format = /^(\d+)-(\d+)-(\d+)$/;
    return isValidFormat(input,format);
}

/**
 * ¼±ÅÃµÈ ¶óµð¿À¹öÆ°ÀÌ ÀÖ´ÂÁö Ã¼Å©
 */
function hasCheckedRadio(input) {
	if(input != null ) {
		if (input.length > 1) {
			for (var inx = 0; inx < input.length; inx++) {
				if (input[inx].checked) return true;
			}
		} else {
			if (input.checked) return true;
		}
	}
    return false;
}

/**
 * ¼±ÅÃµÈ ¶óµð¿À¹öÆ°ÀÇ value¸®ÅÏ
 */
function getRadioValue(input) {
    if (input.length > 1) {
        for (var inx = 0; inx < input.length; inx++) {
            if (input[inx].checked) return input[inx].value;
        }
    } else {
        if (input.checked) return input.value;
    }
    return '0';
}

/**
 * ¼±ÅÃµÈ Ã¼Å©¹Ú½º°¡ ÀÖ´ÂÁö Ã¼Å©
 */
function hasCheckedBox(input) {
    return hasCheckedRadio(input);
}

/**
 * ÀÔ·Â°ªÀÇ ¹ÙÀÌÆ® ±æÀÌ¸¦ ¸®ÅÏ
 * Author : Wonyoung Lee
 */
function getByteLength(input) {
    var byteLength = 0;
    for (var inx = 0; inx < input.value.length; inx++) {
        var oneChar = escape(input.value.charAt(inx));
        if ( oneChar.length == 1 ) {
            byteLength ++;
        } else if (oneChar.indexOf("%u") != -1) {
            byteLength += 2;
        } else if (oneChar.indexOf("%") != -1) {
            byteLength += oneChar.length/3;
        }
    }
    return byteLength;
}


/**
 * Ã¼Å©¹Ú½º ÀüÃ¼¼±ÅÃ ¹× ÇØÁ¦
 */
function clearAll(all, choice)
{
	var check;
	if(all.checked == 0) check	= 0;
	else check = 1;

	if(choice != null) {
		if(choice.length == null) {
			choice.checked = check;
		}else{
			for(x = 0; x < choice.length;x++)
			{
				choice[x].checked = check;
			}
		}
	}
}

/**
 * Ã¼Å©¹Ú½º ÀüÃ¼¼±ÅÃ ¹× ÇØÁ¦
 */
function clearAll2(chk, choice)
{
	var check;
	if(chk == '1') {
		check	= 0;
		state	= '0';
	}else {
		check	= 1;
		state	= '1';
	}

	if(choice != null) {
		if(choice.length == null) {
			choice.checked = check;
		}else{
			for(x = 0; x < choice.length;x++)
			{
				choice[x].checked = check;
			}
		}
	}
}


/*
 * remove space F&L
 */
function trim(str) {
	var count	= str.length;
	var len		= count;                
	var st		= 0;
		
	while ((st < len) && (str.charAt(st) <= ' ')) {
		 st++;
	}
	while ((st < len) && (str.charAt(len - 1) <= ' ')) {
		 len--;
	}                
	return ((st > 0) || (len < count)) ? str.substring(st, len) : str ;
}

/*
/**  ¾ÆÀÌÅÛ Âò¸®½ºÆ®¿¡ Ãß°¡
*/
function buyItem(type, no) {
	window.open("/Contents/MHome/Add_CartList.jsp?type="+type+"&no="+no,"addItem","top=0, left=3000, width=1,height=1");		
}

/*
/**  MyÀ½¾Ç¾Ù¹ü ¶ç¿ì±â(°ü¸®)
*/
function awmusicAlbum() {
	openCenterWindow('/Contents/mAlbum/mAlbum_List.jsp','musicAlbum', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=740, height=550');
}

/*
/**  MyÀ½¾Ç¾Ù¹ü ¶ç¿ì±â(À½¾Ç¼±ÅÃ)
*/
function choiceMusic() {
	openCenterWindow('/Contents/IMail/myAlbum_List.jsp','choiceMusic', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=760, height=598');
}

/*
/**  ¹ÂÁ÷ÇÃ·¹ÀÌ¾î °¡»ç(ÇÑ°î)
*/
function awmusicGasa(no) {
	openNewWindow('/Contents/MPlayer/Gasa_View.jsp?no='+no,'awmusicWords', 'left=350, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=520, height=570');
}

/*
/**  ¹ÂÁ÷ÇÃ·¹ÀÌ¾î Ã¢¶ç¿ì±â(ÇÑ°î)
*/
function awmusicPlayer(no) {
	openNewWindow('/Contents/MPlayer/MusicPlayer.jsp?m_idx='+no,'awmusicPlayer', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=339, height=360');
}

/*
/**  ¹ÂÁ÷ÇÃ·¹ÀÌ¾î Ã¢¶ç¿ì±â(¾Ù¹ü)
*/
function awmusicAPlayer(no) {
	openNewWindow('/Contents/MPlayer/MusicPlayer.jsp?type=album&m_idx='+no,'awmusicPlayer', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=339, height=360');
}

/*
/**  ¹ÂÁ÷ÇÃ·¹ÀÌ¾î Ã¢¶ç¿ì±â(º¸À¯ÇÑ ¸ðµç¸ñ·Ï)
*/
function awmusicAllPlayer() {
	openNewWindow('/Contents/MPlayer/MusicPlayer.jsp?type=tot&m_idx=','awmusicPlayer', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=339, height=360');
}

/*
/**  ¹ÂÁ÷ÇÃ·¹ÀÌ¾î Ã¢¶ç¿ì±â(º¸À¯ÇÑ ¸ðµç¸ñ·ÏÁß ¼±ÅÃÇÑ°î)
*/
function awmusicAllCPlayer(type) {
	var musicCode = "";

	if(form.choiceMusic != null) {
		if(type == 'all') {
			// list°¡ ÇÏ³ª¶ó¸é
			if(form.choiceMusic.length == null) {
				musicCode += "&m_idx="+form.choiceMusic.value;
			// list°¡ ¿©·¯°³¶ó¸é
			}else{
				for(var i = 0; i < form.choiceMusic.length; i++) {
					musicCode += "&m_idx="+form.choiceMusic[i].value;
				}
			}
		}else{
			if(form.choiceMusic.length == null) {
				if(form.choiceMusic.checked) {
					musicCode += "&m_idx="+form.choiceMusic.value;
				}
			// list°¡ ¿©·¯°³¶ó¸é
			}else{
				for(var i = 0; i < form.choiceMusic.length; i++) {
					if(form.choiceMusic[i].checked) {
						musicCode += "&m_idx="+form.choiceMusic[i].value;
					}
				}
			}
		}
		if(musicCode == "") {
			alert("Àç»ýÇÒ °î¸ñÀÌ ¾ø½À´Ï´Ù.    \n\nÀç»ýÇÒ °î¸ñÀ» ¼±ÅÃÇÏ¼¼¿ä.        ");
		}else{
			openNewWindow('/Contents/MPlayer/MusicPlayer.jsp?type=toc&'+musicCode,'awmusicPlayer', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=339, height=360');
		}
	}else{
		alert("Àç»ýÇÒ °î¸ñÀÌ ¾ø½À´Ï´Ù.    ");
	}
}

/*
/**  ¹ÂÁ÷ÇÃ·¹ÀÌ¾î Ã¢¶ç¿ì±â(My¾Ù¹üÁß ¿©·¯°î)
*/
function awmusicMyPlayer(type, album_no) {
	var musicCode = "";

	if(form.choiceMusic != null) {
		if(type == 'all') {
			// list°¡ ÇÏ³ª¶ó¸é
			if(form.choiceMusic.length == null) {
				musicCode += "&m_idx="+form.choiceMusic.value;
			// list°¡ ¿©·¯°³¶ó¸é
			}else{
				for(var i = 0; i < form.choiceMusic.length; i++) {
					musicCode += "&m_idx="+form.choiceMusic[i].value;
				}
			}
		}else{
			if(form.choiceMusic.length == null) {
				if(form.choiceMusic.checked) {
					musicCode += "&m_idx="+form.choiceMusic.value;
				}
			// list°¡ ¿©·¯°³¶ó¸é
			}else{
				for(var i = 0; i < form.choiceMusic.length; i++) {
					if(form.choiceMusic[i].checked) {
						musicCode += "&m_idx="+form.choiceMusic[i].value;
					}
				}
			}
		}
		if(musicCode == "") {
			alert("Àç»ýÇÒ °î¸ñÀÌ ¾ø½À´Ï´Ù.    \n\nÀç»ýÇÒ °î¸ñÀ» ¼±ÅÃÇÏ¼¼¿ä.        ");
		}else{
			openNewWindow('/Contents/MPlayer/MusicPlayer.jsp?type=my&album_no='+album_no+musicCode,'awmusicPlayer', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=339, height=360');
		}
	}else{
		alert("Àç»ýÇÒ °î¸ñÀÌ ¾ø½À´Ï´Ù.    ");
	}
}

/*
/**  ¹ÂÁ÷ÇÃ·¹ÀÌ¾î Ã¢¶ç¿ì±â(¾ÆÀÌÅÛ¼¥Áß¿¡¼­ ¿©·¯°î)
*/
function awmusicMPlayer(type) {
	var musicCode = "";

	if(form.choiceMusic != null) {
		if(type == 'all') {
			// list°¡ ÇÏ³ª¶ó¸é
			if(form.choiceMusic.length == null) {
				musicCode += "&m_idx="+form.choiceMusic.value;
			// list°¡ ¿©·¯°³¶ó¸é
			}else{
				for(var i = 0; i < form.choiceMusic.length; i++) {
					musicCode += "&m_idx="+form.choiceMusic[i].value;
				}
			}
		}else{
			if(form.choiceMusic.length == null) {
				if(form.choiceMusic.checked) {
					musicCode += "&m_idx="+form.choiceMusic.value;
				}
			// list°¡ ¿©·¯°³¶ó¸é
			}else{
				for(var i = 0; i < form.choiceMusic.length; i++) {
					if(form.choiceMusic[i].checked) {
						musicCode += "&m_idx="+form.choiceMusic[i].value;
					}
				}
			}
		}
		if(musicCode == "") {
			alert("Àç»ýÇÒ °î¸ñÀÌ ¾ø½À´Ï´Ù.    \n\nÀç»ýÇÒ °î¸ñÀ» ¼±ÅÃÇÏ¼¼¿ä.        ");
		}else{
			openNewWindow('/Contents/MPlayer/MusicPlayer.jsp?type=all'+musicCode,'awmusicPlayer', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=339, height=360');
		}
	}else{
		alert("Àç»ýÇÒ °î¸ñÀÌ ¾ø½À´Ï´Ù.    ");
	}
}

/*
/**  ¿©·¯°î µ¿½Ã Âò
*/
function choiceAllBuy(type) {
	var musicCode = "";

	if(form.choiceMusic != null) {
		if(form.choiceMusic.length == null) {
			if(form.choiceMusic.checked) {
				musicCode += "&no="+form.choiceMusic.value;
			}
		// list°¡ ¿©·¯°³¶ó¸é
		}else{
			for(var i = 0; i < form.choiceMusic.length; i++) {
				if(form.choiceMusic[i].checked) {
					musicCode += "&no="+form.choiceMusic[i].value;
				}
			}
		}
	}

	if(musicCode == "") {
		alert("±¸¸ÅÇÒ ¹è°æÀ½¾ÇÀ» ¼±ÅÃÇÏ¼¼¿ä.        ");
	}else{
		if(type == 'pop') {
			location.href = "/Contents/IMail/mShop_Cart.jsp?type=music"+musicCode;
		}else{
			location.href = "/Contents/ItemShop/Cart_List.jsp?type=music"+musicCode;
		}
	}
}

// ¾ÆÀÌÅÛ Âò Ã¼Å©
function addZZim(type, code, mode) {
	openCenterWindow('/Contents/ItemShop/Item_ZZim.jsp?mode='+mode+'&type='+type+code,'checkZZim', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=300, height=175');
}

function checkAll(chk, choice)
{
	var check;
	if(chk == '1') {
		check	= 0;
		state	= '0';
	}else {
		check	= 1;
		state	= '1';
	}

	var musicCode		= "";

	if(choice != null) {
		if(choice.length == null) {
			choice.checked = check;
		}else{
			for(x = 0; x < choice.length;x++)
			{
				choice[x].checked = check;
				if (check == '1')
				{
					musicCode += "&musicCode="+choice[x].value;
				} else {
					musicCode = "";
				}
			}
		}
	}
}


/*
*	 ÁÁÀº±Û ºÒ·¯¿À±â
*/
function set_goodText(text) {
	if(trim(document.form.contents.value) != "") {
		alert("ÀÛ¼ºÁßÀÎ ÆíÁö ³»¿ëÀÌ ÀÖ½À´Ï´Ù.\n\nÀÎ¿ëµÇ´Â ½Ã/ÁÁÀº±Û ÇÏ´Ü¿¡\nÀÛ¼ºÁßÀÎ ÆíÁö ³»¿ëÀÌ µ¡ºÙ¿©Áý´Ï´Ù.    ");
	}
	text = replace(text, "<br>","\r", "", "");
	text = replace(text, "<BR>","\r", "", "");
	text = replace(text, "<p>","", "", "");
	text = replace(text, "</p>","", "", "");
	text = trim(text);

	document.form.contents.value = text+"\r\r"+document.form.contents.value;
}


/*
*	 ¼±ÅÃÇÑ ÆíÁö »èÁ¦
*/
function goRemoveLetter(form)
{
	if(!hasCheckedBox(form.choiceLetter)){
		alert("¸ÕÀú »èÁ¦ÇÏ°íÀÚÇÏ´Â ÆíÁö¸¦ ¼±ÅÃÇÏ¼¼¿ä. ");
		return;
	}

	if (confirm('»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?')) {
		var letterCode		= "";

		// list°¡ ÇÏ³ª¶ó¸é
		if(form.choiceLetter.length == null) {
			if(form.choiceLetter.checked) {
				letterCode += "&letterCode="+form.choiceLetter.value;
			}
		// list°¡ ¿©·¯°³¶ó¸é
		}else{
			for(var i = 0; i < form.choiceLetter.length; i++) {
				if(form.choiceLetter[i].checked) {
					letterCode += "&letterCode="+form.choiceLetter[i].value;
				}
			}
		}
		location.href = "/Contents/Meet/FirstLoveMyListProcess.jsp?member="+letterCode;
	}
}


/*
*	 ¼±ÅÃÇÑ Áö¸í¼ö¹è »èÁ¦
*/

function goRemoveFind(form)
{
	if(!hasCheckedBox(form.choiceFind)){
		alert("¸ÕÀú »èÁ¦ÇÏ°íÀÚÇÏ´Â °ø°³¼ö¹è¸¦ ¼±ÅÃÇÏ¼¼¿ä. ");
		return;
	}

	if (confirm('»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?')) {
		var findCode		= "";

		// list°¡ ÇÏ³ª¶ó¸é
		if(form.choiceFind.length == null) {
			if(form.choiceFind.checked) {
				findCode += "&findCode="+form.choiceFind.value;
			}
		// list°¡ ¿©·¯°³¶ó¸é
		}else{
			for(var i = 0; i < form.choiceFind.length; i++) {
				if(form.choiceFind[i].checked) {
					findCode += "&findCode="+form.choiceFind[i].value;
				}
			}
		}
		location.href = "/Contents/Meet/FindMyListProcess.jsp?member="+findCode;
	}
}


/*
*	 ¼±ÅÃÇÑ º´¿¡´ãÀº ÆíÁö »èÁ¦
*/
function goRemoveBottle(form)
{
	if(!hasCheckedBox(form.choiceBottle)){
		alert("¸ÕÀú »èÁ¦ÇÏ°íÀÚÇÏ´Â ÆíÁö¸¦ ¼±ÅÃÇÏ¼¼¿ä. ");
		return;
	}

	if (confirm('»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?')) {
		var bottleCode		= "";

		// list°¡ ÇÏ³ª¶ó¸é
		if(form.choiceBottle.length == null) {
			if(form.choiceBottle.checked) {
				bottleCode += "&bottleCode="+form.choiceBottle.value;
			}
		// list°¡ ¿©·¯°³¶ó¸é
		}else{
			for(var i = 0; i < form.choiceBottle.length; i++) {
				if(form.choiceBottle[i].checked) {
					bottleCode += "&bottleCode="+form.choiceBbottle[i].value;
				}
			}
		}
		location.href = "/Contents/Meet/BottleMyListProcess.jsp?member="+bottleCode;
	}
}



/*
*	 ³â¿ùÀÏ ¸®½ºÆ® ¹Ú½º
*/
function setDate(FORM, year, month, day)
{
  var current, year, month, day, days, i, j;
  current = new Date();
  year = (year) ? year : current.getFullYear();
  for (i=0, j=current.getFullYear()-1; i < 4; i++, j++) FORM.year.options[i] = new Option(j, j);
  month = (month) ? month : current.getMonth()+1;
  for (i=0; i < 12; i++) {
    j = (i < 9) ? '0'+(i+1) : i+1;
    FORM.month.options[i] = new Option(j, j);
  }
  day = (day) ? day : current.getDate();
  days = new Date(new Date(year, month, 1)-86400000).getDate();
  FORM.day.length = 0;
  for (i=0, j; i < days; i++) {
    j = (i < 9) ? '0'+(i+1) : i+1;
    FORM.day.options[i] = new Option(j, j);
  }
  FORM.year.value = year;
  FORM.month.options[month-1].selected = true;
  FORM.day.options[day-1].selected = true;
}

/**
 * Time ½ºÆ®¸µÀ» ÀÚ¹Ù½ºÅ©¸³Æ® Date °´Ã¼·Î º¯È¯
 * parameter time: Time Çü½ÄÀÇ String
 */
function toTimeObject(time) { //parseTime(time)
    var year  = time.substr(0,4);
    var month = time.substr(4,2) - 1; // 1¿ù=0,12¿ù=11
    var day   = time.substr(6,2);
    var hour  = time.substr(8,2);
    var min   = time.substr(10,2);

    return new Date(year,month,day,hour,min);
}

/**
 * ÀÚ¹Ù½ºÅ©¸³Æ® Date °´Ã¼¸¦ Time ½ºÆ®¸µÀ¸·Î º¯È¯
 * parameter date: JavaScript Date Object
 */
function toTimeString(date) { //formatTime(date)
    var year  = date.getFullYear();
    var month = date.getMonth() + 1; // 1¿ù=0,12¿ù=11ÀÌ¹Ç·Î 1 ´õÇÔ
    var day   = date.getDate();
    var hour  = date.getHours();
    var min   = date.getMinutes();

    if (("" + month).length == 1) { month = "0" + month; }
    if (("" + day).length   == 1) { day   = "0" + day;   }
    if (("" + hour).length  == 1) { hour  = "0" + hour;  }
    if (("" + min).length   == 1) { min   = "0" + min;   }

    return ("" + year + month + day + hour + min)
}

/**
 * ÁÖ¾îÁø Time °ú y³â m¿ù dÀÏ h½Ã Â÷ÀÌ³ª´Â TimeÀ» ¸®ÅÏ
 * ex) var time = form.time.value; //'20000101000'
 *     alert(shiftTime(time,0,0,-100,0));
 *     => 2000/01/01 00:00 À¸·ÎºÎÅÍ 100ÀÏ Àü Time
 */
function shiftTime(time,y,m,d,h) { //moveTime(time,y,m,d,h)
    var date = toTimeObject(time);

    date.setFullYear(date.getFullYear() + y); //y³âÀ» ´õÇÔ
    date.setMonth(date.getMonth() + m);       //m¿ùÀ» ´õÇÔ
    date.setDate(date.getDate() + d);         //dÀÏÀ» ´õÇÔ
    date.setHours(date.getHours() + h);       //h½Ã¸¦ ´õÇÔ

    return toTimeString(date);
}

/**
 * µÎ TimeÀÌ ¸çÄ¥ Â÷ÀÌ³ª´ÂÁö ±¸ÇÔ
 * time1ÀÌ time2º¸´Ù Å©¸é(¹Ì·¡¸é) minus(-)
 */
function getDayInterval(time1,time2) {
    var day   = 1000 * 3600 * 24; //24½Ã°£
    return parseInt((time2 - time1) / day, 10);
}


/**
 * ¹®ÀÚ¿­ Ä¡È¯
 */
function replace(target,oldTerm,newTerm,caseSens,wordOnly) { 

  var work = target;
  var ind = 0;
  var next = 0; 

  if (!caseSens) {
    oldTerm = oldTerm.toLowerCase();
    work = target.toLowerCase();
  } 

  while ((ind = work.indexOf(oldTerm,next)) >= 0) {
    if (wordOnly) {
      var before = ind - 1;
      var after = ind + oldTerm.length;

/*      if (!(space(work.charAt(before)) && space(work.charAt(after)))) {
        next = ind + oldTerm.length;
        continue;
      }
*/}
    target = target.substring(0,ind) + newTerm + target.substring(ind+oldTerm.length,target.length);

    work = work.substring(0,ind) + newTerm + work.substring(ind+oldTerm.length,work.length);
    next = ind + newTerm.length;
    if (next >= work.length) { break; }

  } 

  return target; 

} 




// ¸Þ´º ·¹ÀÌ¾î ½ÃÀÛ
var n_id = "";
var n_tid = "";
var open_type = "";
var n_nick = "";

function ui(lv_tid, lv_open_type, nick) {
	n_tid = lv_tid;
	open_type = lv_open_type;
	n_nick = nick;
}

function exec_menuitem(key) {

	switch(key) {
		case "EVENT1" :
			goUIBlog(n_tid);
			break;
		case "EVENT2" :
			sendmemo(n_tid,n_nick);
			break;
		case "EVENT3" :
			buddyAdd(n_tid, n_nick);
			break;
		case "EVENT4" :
			giftVitamin(n_tid);
			break;
		case "EVENT5" :
			giftMusic(n_tid);
			break;
		case "EVENT6" :
			giftFont(n_tid);
			break;
		case "EVENT7" :
			giftSkin(n_tid);
			break;
	}

}

// ¹Ì´ÏÈ¨ÇÇ ¸¸µé±â
function goBlogMake() {
	openCenterWindow('/Contents/MHome/MHome_Make.jsp', '', 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=620, height=770');
}

// ºí·Î±×¿¡¼­ »õÃ¢À¸·Î ´Ù¸¥ÆäÀÌÁö °¡±â(ºÎ¸ðÃ¢ÀÖÀ»¶§¿Í ¾øÀ»¶§ ±¸ºÐ)
function goIndex(url) {
	if(!top.opener.closed) {
		top.window.opener.location.href = url;
		top.window.opener.focus();
	}else{
		top.window.open(url);
	}
}

// ºí·Î±× ÀÌµ¿(UI·¹ÀÌ¾î¸¦ ÅëÇÑ ÀÌµ¿)
function goUIBlog(id) {
	// ÆË¾÷¶ç¿ì±â
	if(open_type == "1") {
		goBlogPop(id);
	}else if(open_type == "2") {
		goPBlog(id);
	}
}

// ºí·Î±× ÀÌµ¿(ºí·Î±× ÀÎµ¦½º È­¸é)
function goBlog(id) {
	if(id != "") {
		location.href = '/Contents/MHome/MHome_Set.jsp?memberBID='+id;
	}
}

// ºí·Î±× ÀÌµ¿(ºí·Î±× IFRAME³»¿¡¼­ÀÇ ÀÌµ¿)
function goPBlog(id) {
	if(id != "") {
		parent.location.href = '/Contents/MHome/MHome_Set.jsp?memberBID='+id;
	}
}

// ºí·Î±× ¶ç¿ì±â(ÆË¾÷)
function goBlogPop(id) {
	if(id != "") {
		var url = id;
		if(id.indexOf("&") != -1) {
			url = id.substring(0, id.indexOf("&"));
		}
		openCenterWindow('/Contents/MHome/MHome_Set.jsp?memberBID='+id, url, 'left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=1000, height=700');
		mHome.focus();
	}
}


function openDiary() {
	var width	= "1000";
	var height	= "620";
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		str += ",toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=yes ";
	}
	openNewWindow('/Contents/MHome/Diary_Login.jsp','Coupon', str)
}

function sendmemo(id,nick) {
	window.open("/Contents/Member/MSend_Popup.jsp?to_id="+id+"&tnick="+nick,"popWin","width=520,height=380,scrollbars=no,resizable=no,top=" + ((screen.height - 500) / 2) + ", left=" + ((screen.width - 330) / 2));
}

function buddyAdd(id, nick) {
	window.open("/Contents/MHome/MHome_AddFriend.jsp?owner="+id,"buddyAdd","top=0, left=10000, width=1,height=1,scrollbars=no, resizable=no");
}

// ºñÅ¸¹Î¼±¹°
function giftVitamin(id) {
	if(open_type == "1") {
		location.href = "/Contents/ItemShop/Gift_IDCheck.jsp?mode=vitamin&to_id="+id;
	}else if(open_type == "2") {
		goIndex("/Contents/ItemShop/Gift_IDCheck.jsp?mode=vitamin&to_id="+id);
	}
}

// ¹è°æÀ½¾Ç¼±¹°
function giftMusic(id) {
	if(open_type == "1") {
		location.href = "/Contents/ItemShop/Gift_IDCheck.jsp?mode=music&to_id="+id;
	}else if(open_type == "2") {
		goIndex("/Contents/ItemShop/Gift_IDCheck.jsp?mode=music&to_id="+id);
	}
}

// ²Ù¹Ò±Û²Ã¼±¹°
function giftFont(id) {
	if(open_type == "1") {
		location.href = "/Contents/ItemShop/Gift_IDCheck.jsp?mode=font&to_id="+id;
	}else if(open_type == "2") {
		goIndex("/Contents/ItemShop/Gift_IDCheck.jsp?mode=font&to_id="+id);
	}
}

// È¨ÇÇ½ºÅ²¼±¹°
function giftSkin(id) {
	if(open_type == "1") {
		location.href = "/Contents/ItemShop/Gift_IDCheck.jsp?mode=skin&to_id="+id;
	}else if(open_type == "2") {
		goIndex("/Contents/ItemShop/Gift_IDCheck.jsp?mode=skin&to_id="+id);
	}
}
//	IE Script

	var NS4;
	var IE4;
	var mouse_top;
	var mouse_left;
	var scroll_top;
	var scroll_left;
	var event_id = "none";
	var status_over = false;	
	var parent_menu_name = "menu_parent";
	var child_menu_array = ["menu_child1"];
//	var child_menu_array = ["menu_child1", "menu_child2", "menu_child3"];
	var submenu_left_indent = 70;
	var column_height = 18;
	var submenu_top_indent = 0;
	var mainmenu_top_indent = 0;	
	var menuover_bgcolor = "#e0eebf";
	var menuover_fgcolor = "#ffffff";
	var default_menuover_bgcolor = "#ffffff";
	var default_menuover_fgcolor = "#000000";
	
	NS4 = (document.layers);
	IE4 = (document.all);
	isWin = (navigator.appVersion.indexOf("Win") != -1)
	
	if (NS4) {
		document.captureEvents(Event.CLICK)
		document.onclick = MouseDown;
	} else if (IE4) {
		document.onclick = MouseDown;
	}
	
	function startIt() {
	}
	
	function menuOver(ar_obj, ar_id) {
		status_over = true;
		changeColor(ar_obj);
		hideChild(event_id);
		viewSubMenu(event, ar_obj, ar_id);
				
	}
	
	function SubmenuOver(ar_obj) {
		status_over = true;
		changeColor(ar_obj);
	}
	
	function MouseDown(e) {
		event_target = event.srcElement;
		event_target = event_target.toString();
		event_check = event_target.indexOf("javascript:ui(");		
		
		
		if (!status_over) hideAll();
		if (!event_check) 
			viewMenu(event,  parent_menu_name);
		else {
			if (!status_over) hideAll();
			return;
		}
	}	
	
	function hideChild(ar_id) {
		if (event_id == "none") return;
		var menu_len = child_menu_array.length;
		for (i=0; i<menu_len; i++) eval(child_menu_array[i] + ".style.display = \"none\"");
	}
	
	function hideAll() {
		eval(parent_menu_name + ".style.display = \"none\"");
		if (event_id == "none") return;
		var menu_len = child_menu_array.length;
		for (i=0; i<menu_len; i++) eval(child_menu_array[i] + ".style.display = \"none\"");
	}

	function viewMenu(e, ar_id) {
		if (ar_id == "none") return;
		menuLocBod = window.document.body;
		xPos = menuLocBod.scrollLeft + event.clientX;
		yPos = event.clientY + menuLocBod.scrollTop;
		screen_height = window.document.body.offsetHeight;
		screen_width = window.document.body.offsetWidth;
		mouse_top = e.y;
		mouse_left = e.x;
		eval("mainmenu_top_indent = " + parent_menu_name + ".children[0].children[0].children.length");
		mainmenu_top_indent = mainmenu_top_indent * column_height;
		if (screen_height > mouse_top + mainmenu_top_indent) 
			yPos = event.clientY + menuLocBod.scrollTop;
		else
			yPos = (event.clientY + menuLocBod.scrollTop) - mainmenu_top_indent;

		if (mouse_top - mainmenu_top_indent < 0) 
			yPos = event.clientY + menuLocBod.scrollTop;

		eval(ar_id + ".style.pixelTop =" + (yPos - 50));
		eval(ar_id + ".style.pixelLeft =" + xPos);		
		eval(ar_id + ".style.display = \"\"");
	}
	
	function viewSubMenu(e, ar_obj, ar_id) {
		if (ar_id == "none") return;
		event_id = ar_id;
		parent_top = menu_parent.style.pixelTop;
		parent_left = menu_parent.style.pixelLeft;
		child_top = ar_obj.style.pixelTop;
		child_left = ar_obj.style.pixelLeft;
		screen_height = window.document.body.offsetHeight;
		screen_width = window.document.body.offsetWidth;
		mouse_top = e.y;
		mouse_left = e.x;
		menuLocBod = window.document.body;
		xPos = menuLocBod.scrollLeft + parent_left + submenu_left_indent;
		eval("submenu_top_indent = " + ar_id + ".children[0].children[0].children.length");
		submenu_top_indent = submenu_top_indent * column_height;
		if (screen_height > mouse_top + submenu_top_indent) 
			yPos = event.clientY + menuLocBod.scrollTop;
		else
			yPos = (event.clientY + menuLocBod.scrollTop) - submenu_top_indent;
		
		if (mouse_top - submenu_top_indent < 0) 
			yPos = event.clientY + menuLocBod.scrollTop;
			

		eval(ar_id + ".style.pixelTop =" + yPos);
		eval(ar_id + ".style.pixelLeft =" + xPos);		
		eval(ar_id + ".style.display = \"\"");
	}
		
	function menuOut(ar_obj) {
		status_over = false;
		changeColor(ar_obj);
	}
	
	function changeColor(ar_obj) {
        

		if (ar_obj.style.background == menuover_bgcolor) {
			//ar_obj.style.color = default_menuover_fgcolor;
			ar_obj.style.background = default_menuover_bgcolor;
		} else {
			ar_obj.style.background = menuover_bgcolor;
			//ar_obj.children[0].style.color = menuover_fgcolor;
		}
		
	}


document.write("<div id=\"menu_parent\" style=\"position:absolute;display:none;top:0;left:0;z-index:1\">");
document.write("<table width=\"100\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#B6B6B6\">");
document.write("<tr><td> ");
document.write("<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">");
document.write("<tr> ");
document.write("<td style=\"padding: 3 0 0 10\" height=\"23\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT1');\" style=\"cursor:hand\"><span class=\"n_id\">¹Ì´ÏÈ¨ÇÇ</span></td>");
document.write("</tr><tr> ");
document.write("<td style=\"padding: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT2');\" style=\"cursor:hand\"><span class=\"n_id\">ÂÊÁöº¸³»±â</span></td>");
document.write("</tr><tr> ");
document.write("<td style=\"padding: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT3');\" style=\"cursor:hand\"><span class=\"n_id\">Ä£±¸Ãß°¡</span></td>");
document.write("</tr><tr> ");
document.write("<td style=\"padding: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT4');\" style=\"cursor:hand\"><span class=\"n_id\">ºñÅ¸¹Î¼±¹°</span></td>");
document.write("</tr><tr> ");
document.write("<td style=\"padding: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT5');\" style=\"cursor:hand\"><span class=\"n_id\">¹è°æÀ½¾Ç¼±¹°</span></td>");
document.write("</tr><tr> ");
document.write("<td style=\"padding: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT6');\" style=\"cursor:hand\"><span class=\"n_id\">²Ù¹Ò±Û²Ã¼±¹°</span></td>");
document.write("</tr><tr> ");
document.write("<td style=\"padding: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT7');\" style=\"cursor:hand\"><span class=\"n_id\">È¨ÇÇ½ºÅ²¼±¹°</span></td>");
document.write("</tr></table></td></tr></table>");
document.write("</div>");
// ¸Þ´º ·¹ÀÌ¾î ³¡


//win_pop(URL, width, height)
// ÀÍ½ºÇÃ·Î·¯ SWF ÆÐÄ¡ 
function swf(src,w,h){
	html = '';
	html += '<object type="application/x-shockwave-flash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" id="param" width="'+w+'" height="'+h+'">';
	html += '<param name="movie" value="'+src+'">';
	html += '<param name="quality" value="high">';
	html += '<param name="bgcolor" value="#ffffff">';
	html += '<param name="wmode" value="transparent">';
	html += '<param name="menu" value="false">';
	html += '<param name="swliveconnect" value="true">';
	html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" menu="false" width="'+w+'" height="'+h+'" swliveconnect="true" id="param" name="param" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"><\/embed>';
	html += '<\/object>';
	document.write(html);
}

/**
 * IE ÆÐÄ¡¿¡ µû¸¥ ÇÃ·¡½¬ activeXÃ³¸®
 */
var embedSrc = "";

function makeEmbed(src) {
	embedSrc += src;
}

function viewEmbed() {
	document.write(embedSrc);
	embedSrc = "";
}

