		var limitMsgno = 3;
		var curMsgno = 1;
		var totalMsgno = 1;
		var totalPhoneno = 1;
		var initByte = 0;
		var isSubmit = false;

		function doClear(tg) {
			if (tg.value == tg.defaultValue) {
				tg.value = '';
			}

			calByte(tg);
		}

		function calByte(tg) {
			var curText;
			var strLen;
			var byteIs;
			var lastByte;
			var thisChar;
			var escChar;

			curText = new String(tg.value);
			strLen = curText.length;
			byteIs = 0;

			for(i=0; i<strLen; i++) {
				thisChar = curText.charAt(i);
				escChar = escape(thisChar);

				if (escChar.length > 4) {
					byteIs += 2;
				}
				else if (thisChar != '\r') {
					byteIs += 1;
				}
				else {
					{}
				}

				if (byteIs > 80) {
					var goNext;

					if (totalMsgno >= limitMsgno) {
						goNext = false;
						alert('¸Þ¼¼Áö´Â ÇÑ¹ø¿¡ ÃÖ´ë '+limitMsgno+'È­¸é ±îÁö Àü¼ÛÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.\nÃÊ°úµÈ ¸Þ¼¼Áö´Â ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù.');
					}
/*
					else if (document.send_msg.goNext.checked == true) {
						goNext = true;
					}
*/
					else {
						var msg = 'ÇÑ¹ø¿¡ º¸³¾ ¼ö ÀÖ´Â ¸Þ¼¼Áö ±æÀÌ 80Byte(ÇÑ±Û 40ÀÚ, ¿µ¹® 80ÀÚ)¸¦ ÃÊ°úÇÏ¼Ì½À´Ï´Ù.\n\n¿©·¯ ¸Þ¼¼Áö¿¡ ³ª´©¾î º¸³»½Ã°Ú½À´Ï±î?\n(ÇÑ ¸Þ¼¼Áö´ç 30¿ø¾¿ °ú±ÝµË´Ï´Ù.)';
//						goNext = confirm(msg);
						goNext = showModalDialog('/sms/msg_confirm.htm', 'input_title', 'dialogWidth: 285px; dialogHeight: 185px; status: no; resizable: no; scroll: no;');
					}

					if (goNext == true) {
						thisText = curText.substring(0, i);
						newText = curText.substring(i, strLen);
						tg.value = thisText;

						if (curMsgno < totalMsgno) {
							tgpage = curMsgno + 1;
							chgPage(tgpage);
							document.send_msg['msgbox'+curMsgno].value = newText + document.send_msg['msgbox'+curMsgno].value;
							calByte(document.send_msg['msgbox'+curMsgno]);
							return;
						}
						else {
							addMsgbox();
							document.send_msg['msgbox'+curMsgno].value = newText;
							setFocus();
							calByte(document.send_msg['msgbox'+curMsgno]);
							return;
						}
					}
					else {
						thisText = curText.substring(0, i);
						tg.value = thisText;
						byteIs = lastByte;
						break;
					}
				}

				lastByte = byteIs;
			}

			if (byteIs < (initByte * 0.5) && initByte != 0) {
				document.send_msg.pid.value = '0';
				document.send_msg.category.value = '000';
			}
			msgByte.innerHTML = byteIs;

			return byteIs;
		}

		function calByte2(tg) {
			var curText;
			var strLen;
			var byteIs;
			var lastByte;
			var thisChar;
			var escChar;

			curText = new String(tg.value);
			strLen = curText.length;
			byteIs = 0;

			for(i=0; i<strLen; i++) {
				thisChar = curText.charAt(i);
				escChar = escape(thisChar);

				if (escChar.length > 4) {
					byteIs += 2;
				}
				else if (thisChar != '\r') {
					byteIs += 1;
				}

				if (byteIs > 80) {
					alert('ÇÑ¹ø¿¡ º¸³¾ ¼ö ÀÖ´Â ¸Þ¼¼Áö ±æÀÌ\n80Byte(ÇÑ±Û 40ÀÚ, ¿µ¹® 80ÀÚ)¸¦\nÃÊ°úÇÏ¼Ì½À´Ï´Ù.\nÃÊ°úµÈ ºÎºÐÀº ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù.');
					thisText = curText.substring(0, i);
					tg.value = thisText;
					byteIs = lastByte;
					break;
				}

				lastByte = byteIs;
			}

			msgByte2.innerHTML = byteIs;
		}

		function initPhonebox() {
			totalPhoneno = 0;
			toPhone_box.innerHTML = '';
		}

		function addPhonebox() {
			if (totalPhoneno >= 10) {
				alert('ÇÑ¹ø¿¡ 10¸í±îÁö¸¸ µ¿½Ã Àü¼ÛÀÌ °¡´ÉÇÕ´Ï´Ù.');
				return false;
			}

			totalPhoneno++;

			var addHtml = "<select name='to_prephone"+totalPhoneno+"' onChange='chgPhoneFocus("+totalPhoneno+")' style='position: relative; top: 2px'><option value='011'>011</option><option value='016'>016</option><option value='017'>017</option><option value='018'>018</option><option value='019'>019</option></select><input class='sms' type='text' name='to_phone"+totalPhoneno+"' value='' size=8 maxlength=8><br>";

			toPhone_box.insertAdjacentHTML("BeforeEnd", addHtml);
			document.send_msg.totalPhone.value = totalPhoneno;
			document.send_msg['to_prephone'+totalPhoneno].focus();
		}

		function addSavedPhoneno(phoneno) {
			phoneno = phoneno.replace(/ /g, '');
			document.send_msg.to_phone.value = phoneno;
			var eachPhone = phoneno.split(';', 5);
			var tot_phone = eachPhone.length;

			initPhonebox();

			for (var i=0; i<tot_phone; i++) {
				addPhonebox();

				pno = i + 1;

				var prePhone = eachPhone[i].substr(0, 3);
				var phoneno = eachPhone[i].substr(3);

				if (prePhone == '' || phoneno == '') {
					continue;
				}

				document.send_msg['to_prephone'+pno].value = prePhone;
				document.send_msg['to_phone'+pno].value = phoneno;
				document.send_msg.from_phone.focus();
			}
		}

		function chgPhoneFocus(tg) {
			document.send_msg['to_phone'+tg].focus();
		}

		function addMsgbox() {
			totalMsgno++;
			document.send_msg['msgbox'+curMsgno].style.display = 'none';
			curMsgno++;

			var addHtml = "<textarea name='msgbox"+totalMsgno+"' cols='16' rows='5' class='lcd2' onclick='doClear(this)' onselect='doClear(this)' onkeyup='calByte(this)'>¿©±â¿¡ ¸Þ¼¼Áö¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.</textarea>";
			var addHtml2 = "<a class='pgnavi' href='javascript: chgPage("+totalMsgno+")'>"+totalMsgno+"</a>&nbsp;";

			msgField.insertAdjacentHTML("BeforeEnd", addHtml);
			pageField.insertAdjacentHTML("BeforeEnd", addHtml2);

			curPage.innerHTML = curMsgno;
			totalPage.innerHTML = totalMsgno;
		}

		function chgPage(tgpage) {
			if (totalMsgno <= 1) {
				document.send_msg['msgbox'+curMsgno].focus();
				document.send_msg['msgbox'+curMsgno].value += '';
				return;
			}
			else {
				document.send_msg['msgbox'+curMsgno].style.display = 'none';
				document.send_msg['msgbox'+tgpage].style.display = 'inline';
				curPage.innerHTML = tgpage;
				curMsgno = tgpage;
				calByte(document.send_msg['msgbox'+curMsgno]);
				
				setFocus();
			}
		}

		function setFocus() {
			document.send_msg['msgbox'+curMsgno].focus();
			document.send_msg['msgbox'+curMsgno].value += '';
		}

		function chkValidStr(tgstr, addition) {
			var allowable = '0123456789 ' + addition;
			var p_len = tgstr.length;
			var t_chr;

			for (var i=0; i<p_len; i++) {
				t_chr = tgstr.charAt(i);
				if (allowable.indexOf(t_chr) == -1) {
					return false;
				}
			}

			return true;
		}

		function chkForm(tg) {
			if (isSubmit == true) {
				alert('Àü¼Û ÁßÀÔ´Ï´Ù.\nÀá½Ã¸¸ ±â´Ù·ÁÁÖ¼¼¿ä.');
				return false;
			}

			for (var i=1; i<=totalMsgno; i++) {
				if (tg['msgbox'+i].value == tg['msgbox'+i].defaultValue || tg['msgbox'+i].value == '') {
					alert('¸Þ¼¼Áö ³»¿ëÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.');
					tg['msgbox'+i].value = '';
					chgPage(i);
					return false;
				}
			}

			var istoPhone = false;
			for (var i=1; i<=totalPhoneno; i++) {
				if (tg['to_phone'+i].value != '' && tg['to_phone'+i].value != 0 && tg['to_prephone'+i].value != '') {
					if (!chkValidStr(tg['to_phone'+i].value, '')) {
						alert('¹Þ´Â »ç¶÷ ÀüÈ­¹øÈ£´Â ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù.');
						tg.to_phone1.select();
						return false;
					}
					else {
						istoPhone = true;
					}
				}
			}

			if (!istoPhone) {
				alert('¹Þ´Â »ç¶÷ ÀüÈ­¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
				tg.to_phone1.select();
				return false;
			}

			if (tg.from_phone.value == '' || tg.from_phone.value == 0) {
				alert('º¸³»´Â »ç¶÷ ÀüÈ­¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
				tg.from_phone.select();
				return false;
			}

			var addStr = '';
			if (!chkValidStr(tg.from_phone.value, addStr)) {
				alert('º¸³»´Â »ç¶÷ ÀüÈ­¹øÈ£´Â ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù.');
				tg.from_phone.select();
				return false;
			}

			tg.action = '/sms/send_sms_exec.htm';
			tg.totalMsg.value = totalMsgno;
			tg.totalPhone.value = totalPhoneno;
//			isSubmit = true;


			// /*
			// ÀÌº¥Æ® ±â°£ÀÏ °æ¿ì ¿¹¾à Àü¼ÛÀ» À¯·á¶ó´Â ¸Þ¼¼Áö Ãâ·Â
			// ÀÌº¥Æ® Á¾·áÈÄ ÁÖ¼®Ã³¸®
/*
			if (tg.send_method[1].checked == true	) {
				contiSend = confirm('¹®ÀÚ¸Þ¼¼Áö ¿¹¾à Àü¼ÛÀº À¯·á·Î °ú±ÝµË´Ï´Ù.\n¿¹¾àÇÏ½Ã°Ú½À´Ï±î?');
				if (!contiSend) {
					return false;
				}
			}
			// */	

			if (openSendWin()) {
				tg.submit();
			}
		}

		function ClearPhone() {
			toPhone_box.innerHTML = "<select name='to_prephone1' onChange='chgPhoneFocus(1)' style='position: relative; top: 2px'><option value='011'>011</option><option value='016'>016</option><option value='017'>017</option><option value='018'>018</option><option value='019'>019</option></select><input class='sms' type='text' name='to_phone1' value='' size=8 maxlength=8><br>";

			totalPhoneno = 1;
			document.send_msg.totalPhone.value = totalPhoneno;
		}

		function ClearMsg() {
			msgField.innerHTML = "<textarea name='msgbox1' cols='16' rows='5' class='lcd2' onclick='doClear(this)' onselect='doClear(this)' onkeyup='calByte(this)'>¿©±â¿¡ ¸Þ¼¼Áö¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.</textarea>";
			pageField.innerHTML = "<a class='pgnavi' href='javascript: chgPage(1)'>1</a> ";
			curMsgno = 1;
			totalMsgno = 1;
			curPage.innerHTML = 1;
			totalPage.innerHTML = 1;
			calByte(document.send_msg.msgbox1);
			document.send_msg.totalMsg.value = '1';
		}

		function initSMS() {
			ClearMsg();
			ClearPhone();
			chg_sendMethod('instant');

			document.send_msg.to_phone1.value = '';
			document.send_msg.to_name.value = '';
			document.send_msg.from_phone.value = document.send_msg.from_phone.defaultValue;
			document.send_msg.pid.value = '0';
			document.send_msg.category.value = '000';
			document.send_msg.title.value = '';
			
			send_complete();
		}

		function send_complete() {
			isSubmit = false;
		}

		function openPhonebook() {
			var winHandle = window.open('/addr/addr.htm?type=sms&key=1', 'phonebook', 'width=500, height=510, scrollbars=no');
			winHandle.focus();
		}

		function openSendWin() {
			var winHandle = window.open('', 'sendSMS', 'width=301, height=338, scrollbars=no');
			winHandle.focus();

			return true;
		}

		function smsZzim(tg) {
			for (var i=1; i<=totalMsgno; i++) {
				if (tg['msgbox'+i].value == tg['msgbox'+i].defaultValue || tg['msgbox'+i].value == '') {
					alert('¸Þ¼¼Áö ³»¿ëÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.');
					tg['msgbox'+i].value = '';
					chgPage(i);
					return false;
				}
			}

			var def_title = document.send_msg.title.value;
			if (def_title == '') {
				def_title = '³» ¹®ÀÚ';
			}

			var user_title = showModalDialog('/sms/msg_inptitle.htm?def_title='+def_title, 'input_title', 'dialogWidth: 285px; dialogHeight: 155px; status: no; resizable: no; scroll: no;');

/*
			var title = prompt('Á¦¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä.', def_title);
*/

			if (user_title == null) {
//				user_title = def_title;
				return false;
			}

			tg.title.value = user_title;
			tg.totalMsg.value = totalMsgno;
			tg.action = '/sms/favorite/insert.htm';
	
			if (openSendWin()) {
				tg.submit();
			}
		}

		function sendThis(seq, pid, category, title) {
			initByte = 0;
			window.phone_body.ClearMsg();

			var msg = document.all['msgbox'+seq].innerHTML;
			msg = msg.replace(/&gt;/g, '>');
			msg = msg.replace(/&lt;/g, '<');
			msg = msg.replace(/&amp;/g, '&');
			var title = document.all['title'+seq].innerHTML;
			//var tg = document.send_msg;
			var tg = window.phone_body.document.send_msg;

			tg.pid.value = pid;
			tg.category.value = category;
			tg.title.value = title;
			tg.msgbox1.value = msg;

			initByte = window.phone_body.calByte(tg.msgbox1);

			tg.msgbox1.focus();

//			alert(pid+' / '+category+' / '+msg);
		}

		function sendThis2(pid, msg, category, title) {
			window.phone_body.ClearMsg();

			msg = msg.replace(/cR_/g, '\n');
			msg = msg.replace(/bS_/g, '\\');
			msg = msg.replace(/dQ_/g, '\"');
			msg = msg.replace(/sQ_/g, '\'');

//			msg = msg.replace(/&gt;/g, '>');
//			msg = msg.replace(/&lt;/g, '<');
//			msg = msg.replace(/&amp;/g, '&');

			//var tg = document.send_msg;
			var tg = window.phone_body.document.send_msg;

			tg.pid.value = pid;
			tg.category.value = category;
			tg.title.value = title;
			tg.msgbox1.value = msg;

			initByte = window.phone_body.calByte(tg.msgbox1);

			tg.msgbox1.focus();

//			alert(pid+' / '+category+' / '+msg);
		}

		function previewThis(msg) {
			msg = msg.replace(/cR_/g, '<br>');
			msg = msg.replace(/bS_/g, '\\');
			msg = msg.replace(/dQ_/g, '\"');
			msg = msg.replace(/sQ_/g, '\'');
			msg = msg.replace(/ /g, '&nbsp;');

			preview_msg.innerHTML = '<table border=0 cellspacing=0 cellpadding=0 width=109 style="table-layout: fixed; filter: alpha(opacity=90)"><tr><td style="color: black; background-color: #E4FE7C; font-size:9pt; font-family: µ¸¿òÃ¼; padding: 5 5 5 5">' + msg + '</td></tr></table>';
			preview_msg.style.top = event.y + document.body.scrollTop + 10;
			preview_msg.style.left = event.x + document.body.scrollLeft + 10;
			preview_msg.style.display = 'inline';
		}

		function movePreview() {
			preview_msg.style.top = event.y + document.body.scrollTop + 10;
			preview_msg.style.left = event.x + document.body.scrollLeft + 10;
		}

		function hidePreview() {
			preview_msg.innerHTML = '';
			preview_msg.style.top = 0;
			preview_msg.style.left = 0;
			preview_msg.style.display = 'none';
		}

		function chg_sendMethod(value) {
			if (value == 'reserve') {
				reserve_date.style.display = 'inline';
				document.send_msg.send_method[1].checked = true;
				document.images.btn_send.src = '/sms/images/frm/phone_bottom_b05a.gif';
			}
			else if (value == 'instant') {
				reserve_date.style.display = 'none'
				document.send_msg.send_method[0].checked = true;
				document.images.btn_send.src = '/sms/images/frm/phone_bottom_b05.gif';
			}
			else {
				return false;
			}
		}


		function ins_spchr(chr) {
			var tg = document.send_msg['msgbox'+curMsgno];
			
			if (tg.value == tg.defaultValue) {
				tg.value = '';
			}
			tg.value += chr;
			calByte(tg);
			setFocus();
		}

		function insertSpecial(special) {
			var tg = window.phone_body.send_msg['msgbox'+curMsgno];
			if (tg.value == tg.defaultValue) {
				tg.value = '';
			}
			tg.value = tg.value + special;
			window.phone_body.calByte(tg);

			tg.focus();

		}

		function toggle_spchr() {
			var tgStyle = spchr.style;
			if (tgStyle.display == 'inline') {
				tgStyle.display = 'none';
			}
			else {
				tgStyle.top = event.y + document.body.scrollTop + 5;
				tgStyle.left = event.x + document.body.scrollLeft;
				tgStyle.display = 'inline';
			}

			setFocus();
		}

		var sp_chr = Array('¢½','¢¸','¢¹','¢º','¡ä','¢·','¡è','¡é','¡ß','¡Ú','¡Ù','¡Ô','¡Ø','¡Ý','¢Í','¢Î','¢Ï','¢Ð','¢Ñ','¢Ý','¢Ü');
		var sp_len = sp_chr.length;

		document.write("<div id='spchr' style='display: none; position: absolute; z-index: 99'>");
		document.write("<table border=0 cellspacing=2 cellpadding=0 bgcolor=#C4D9DA>");

		for (var i=1; i<=21 ; i++) {
			idx = i - 1;

			if (i % 7 == 1) {
				document.write("<tr>");
			}

			document.write("<td><a href='#' onClick='ins_spchr(this.innerHTML)'>"+sp_chr[idx]+"</a></td>");

			if (i % 7 == 0) {
				document.write("</tr>");
			}
		}

		document.write("</table>");
		document.write("</div>");

		document.write("<div id='preview_msg' style='border: 1 solid; width: 109px; display: none; position: absolute; z-index: 25'>");
		document.write("</div>");
