

	/* HTML 태그들을 없애준다 */
	function strip_tags(string) {
	  var objStrip = new RegExp();
	  objStrip = /[<][^>]*[>]/gi;
	  return string.replace(objStrip, "");
	}
	/*
	function strip_tags(string) {
	  var objStrip = new RegExp();
	  objStrip = /[<][^>]*[>]/gi;
	  return string.replace(objStrip, "");
	}
	*/
	function replaceTag(string) {
		var objString;
	  	objString = string.replace(/</g, "&lt;");
	  	return objString.replace(/>/g, "&gt;");
	}
	
	/* FONT 태그만 빼고 다 없애버린다.< > 류는 죄다 삭제  */	
	function removeTags(string){
	  var objStrip = new RegExp();
	  objStrip = /<IMG(.)+>|<P>|<\/P>/gi;
	  return string.replace(objStrip, "");
	}
	
	
	/* 앵커 태그를 삭제한다. */
	function removeHrefTags(string){
	  var objStrip = new RegExp();
	  objStrip = /<A[^>]*[>]|<\/A>/gi;
	  return string.replace(objStrip, "");
	}
	

	/*
	var arrColor = new Array();
	arrColor[0] = new Array("color=#000000","color=rgb(0,0,0)");
	arrColor[1] = new Array("color=#[Ff][Ff][Ff][Ff][Ff][Ff]","color=rgb(255,255,255)");
	arrColor[2] = new Array("color=#[Dd]4019[Dd]","color=rgb(212,1,157)");
	arrColor[3] = new Array("color=#7[Ee][Ee]600","color=rgb(126,230,0)");
	arrColor[4] = new Array("color=#5400[Dd]2","color=rgb(84,0,210)");
	arrColor[5] = new Array("color=#[Ff]8[Dd]93[Dd]","color=rgb(248,217,61)");
	arrColor[6] = new Array("color=#[Ff]000[Aa]5","color=rgb(240,0,165)");
	arrColor[7] = new Array("color=#3[Dd][Ee]8[Cc][Dd]","color=rgb(61,232,205)");
	arrColor[8] = new Array("color=#15222[Dd]","color=rgb(21,34,45)");
	arrColor[9] = new Array("color=#[Dd]0[Dd]3[Dd]4","color=rgb(208,211,212)");
	arrColor[10] = new Array("color=#4[Aa]1[Dd]22","color=rgb(74,29,34)");
	arrColor[11] = new Array("color=#0000[Ee][Bb]","color=rgb(0,0,235)");
	*/

	function replaceFontColorStyle(txtStr) {

		var arrColor = new Array();
		arrColor[0] = new Array("color=#000000","color=\"000000\"");
		arrColor[1] = new Array("color=#[Ff][Ff][Ff][Ff][Ff][Ff]","color=\"#ffffff\"");
		arrColor[2] = new Array("color=#[Dd]4019[Dd]","color=\"#d4019d\"");
		arrColor[3] = new Array("color=#7[Ee][Ee]600","color=\"#7ee600\"");
		arrColor[4] = new Array("color=#5400[Dd]2","color=\"#5400d2\"");
		arrColor[5] = new Array("color=#[Ff]8[Dd]93[Dd]","color=\"#f8d93d\"");
		arrColor[6] = new Array("color=#[Ff]000[Aa]5","color=\"#f000a5\"");
		arrColor[7] = new Array("color=#3[Dd][Ee]8[Cc][Dd]","color=\"#3de8cd\"");
		arrColor[8] = new Array("color=#15222[Dd]","color=\"#15222d\"");
		arrColor[9] = new Array("color=#[Dd]0[Dd]3[Dd]4","color=\"#d0d3d4\"");
		arrColor[10] = new Array("color=#4[Aa]1[Dd]22","color=\"#4a1d22\"");
		arrColor[11] = new Array("color=#0000[Ee][Bb]","color=\"#0000eb\"");

	    var rtnStr = txtStr;
	    for(var i = 0 ; i < arrColor.length ; i++) {
	        var regexp = eval('/' + arrColor[i][0] + '/g');
	        rtnStr = (rtnStr).replace(regexp, arrColor[i][1]);
	    }
	    return rtnStr;
	}
	
	/* 해당 함수를 부르기 전에 FONT 태그를 제외한 모든 태그는 text 에서 제거되어야 한다 */
	function replaceInnerFontTagToPlain(text){
	
		var flatText = "";
		var fontStr = "<FONT color=";
		var fontEndStr = "</FONT>";
		var stack = new Array();
		
		/* <font color=#ffffff> 와 같은 스타일을 <font color="#ffffff"> 와 같이 바꾼다 */
		text = replaceFontColorStyle(text);

		/*
		for ( var i = 0; i < text.length; i++ ){
		
			if (text.charAt(i) == '<'){
				if (text.substring(i).length >= 22 && text.substring(i, i+12) == "<FONT color=") { // 최소 <font color="#FF00FF"> 와 같이 22자 이상인경우
					if (stack != null && stack.length > 0){
						flatText += "</1FONT>";
					}
					//alert("before length:" + stack.length);
					stack.push(text.substring(i+12, i+21)); // color 값의 #FF00FF 부분을 스택에 push
					//alert("push:" + text.substring(i+12, i+21));
					//alert("after length:" + stack.length); 
				}
				else if (text.substring(i).length >= 7 && text.substring(i, i+7) == "</FONT>") {
					flatText += "</2FONT>";
					//alert(stack != null && stack.length > 0);
					//alert(text.charAt(i+7) != '<' && stack != null && stack.length > 0);
					if (text.charAt(i+7) != '<' && stack != null && stack.length > 0){
						var color = stack.pop();
						flatText += "<1FONT color=#" + color + ">";
					}
					i+=7;
				}
			}
			else {
			
			}
			flatText += text.charAt(i);
		}

		return flatText;
		*/
		return text;
	}

	function replaceFontTag(string){
	  var objStrip = new RegExp();
	  objStrip1 = /[<][FONT ][^>]*[>]/gi;
	  objStrip2 = /[<][\/FONT>]/gi;
	  return string.replace(objStrip1, "<color>").replace(objStrip2, "</color>");
	}

	
    function nl2br_js(myString) {
        var regX = /\r\n|\n/gi ;

        s = new String(myString);
        s = s.replace(regX, "<br/>\n");
        return s;
    }
    
    function br2nl(myString) {
        var regX = /[<]BR[>]/gi ;

        s = new String(myString);
        s = s.replace(regX, "\n");
        return s;
    }    

    function blank2nbsp(myString) {
        var regX = / /gi ;

        s = new String(myString);
        s = s.replace(regX, "&nbsp;");
        return s;
    }
    
    function nbsp2blank(myString) {
        var regX = /&nbsp;/gi ;

        s = new String(myString);
        s = s.replace(regX, " ");
        return s;
    }    

    function blank2star(myString) {
        var regX = / /gi ;

        s = new String(myString);
        s = s.replace(regX, "*");
        return s;
    }

	<!-- 일일이 document.getElementById() 를 쓰기 싫다면.. -->
	function $(id) {
	   return document.getElementById(id);
	}

	function goURL(url){
		document.location.href = url;
		return false;
	}

	function popup(url){
		window.open(url, '', 'scrollbars=no,toolbar=no,location=no,resizable=yes,status=no,menubar=no,width=650,height=500'); 
		return false;
	}

	function popup(url, width, height){
		window.open(url, '', 'scrollbars=no,toolbar=no,location=no,directories=no,resizable=yes,status=no,menubar=no,width='+width+',height='+height); 
		return false;
	}


	function getCookieVal (offset) {
	   var endstr = document.cookie.indexOf (";", offset);
	   if (endstr == -1) endstr = document.cookie.length;
	   return unescape(document.cookie.substring(offset, endstr));
	}

	function GetCookie (name) {
	   var arg = name + "=";
	   var alen = arg.length;
	   var clen = document.cookie.length;
	   var i = 0;
	   while (i < clen) {	//while open
		  var j = i + alen;
		  if (document.cookie.substring(i, j) == arg)
			 return getCookieVal (j);
		  i = document.cookie.indexOf(" ", i) + 1;
		  if (i == 0) break; 
	   }	//while close
	   return null;
	}

	function SetCookie (name, value) {
	   var argv = SetCookie.arguments;
	   var argc = SetCookie.arguments.length;
	   var expires = (2 < argc) ? argv[2] : null;
	   var path = (3 < argc) ? argv[3] : null;
	   var domain = (4 < argc) ? argv[4] : null;
	   var secure = (5 < argc) ? argv[5] : false;
	   document.cookie = name + "=" + escape (value) +
		  ((expires == null) ? "" : 
			 ("; expires=" + expires.toGMTString())) +
		  ((path == null) ? "" : ("; path=" + path)) +
		  ((domain == null) ? "" : ("; domain=" + domain)) +
		  ((secure == true) ? "; secure" : "");
	} 

	/* itemsName 에는 전체선택시 선택되어야 하는 것들의 이름(공통으로 표시한 이름), flagName 은 폼내에서 현재 전체선택여부를 세팅하기
		위해 사용할 임의의 input 컴포넌트(일반적으로 hidden 컴포넌트) */
    function selectAll(itemsName, flagName){
        var allSelected = document.getElementById(flagName).value;
        var obj = document.getElementsByName(itemsName);

        if (allSelected == "0"){
            for ( var i = 0; i < obj.length; i++ )
                obj[i].checked = true;

            document.getElementById(flagName).value = "1";

        }
        else {
            for ( var i = 0; i < obj.length; i++ )
                obj[i].checked = false;

            document.getElementById(flagName).value = "0";
        }
    }


	// Textarea 에서 메세지 글자수 세기 및 초과사이즈 입력내용 잘라내기
	function chkMsgLength(intMax,objMsg,st) {

		if (objMsg == null)
			return;

		var length = lengthMsg(objMsg);
		if ($('callback_url') != null && $('callback_url').value != ""){
			length = length + $('callback_url').value.length;
		}

		st.innerHTML = length;//현재 byte수를 넣는다

		if (length == 0)
			return false;

		if (length > intMax) {

			if (EditMode == "SMS"){
				if (confirm("SMS로 전송 가능한 80byte 를 초과했습니다. LMS로 전송하시겠습니까?\nLMS전송시 추가비용이 발생할 수 있습니다.")){
					EditMode = "LMS";
					setMaxMsgLength("LMS");

					remainCount = parseInt(usableCash) / 70;

					// 소숫점을 날려버리기 위해서
					remainCount = parseInt(remainCount);

					if ($('remain'))
						$('remain').innerHTML = "" + remainCount;

					return;
				}
			}

			alert("최대 " + intMax + "byte이므로 초과된 글자수는 자동으로 삭제됩니다.\n");
			//objMsg.innerText = objMsg.replace(/\r\n$/, "");
			//objMsg.innerText= assertMsg(intMax,objMsg, st );
			//alert("before assertMsg\n" + objMsg);
			objMsg = objMsg.replace(/\r/g, "");
			//objMsg = objMsg.replace(/\r\n$/, "");
			if ($('callback_url') != null && $('callback_url').value != ""){
				objMsg = assertMsg(intMax - $('callback_url').value.length, objMsg, st );
			}
			else {
				objMsg = assertMsg(intMax,objMsg, st );
			}
			//alert("after assertMsg\n" + objMsg);
			objMsg = blank2nbsp(nl2br_js(objMsg));
			//alert(objMsg);

			var s_html = "<style>BODY {font-size:11pt;background-color:#cce6f1} P {margin-top:3px;margin-bottom:3px;margin-left:3;margin-right:3;word-break:break-all;}</style><P>" + objMsg + "</P>";
			content.document.body.innerHTML = s_html; 
		}
	}

	function chkEmoticonMsgLength(intMax,objMsg,st) {

		if (objMsg == null)
			return;

		var value = objMsg.value;

		var length = lengthMsg(objMsg.value);
		//var length = lengthMsg(objMsg.value);

		st.innerHTML = length;//현재 byte수를 넣는다

		if (length == 0)
			return false;


		if (length > intMax) {
			alert("최대 " + intMax + "byte이므로 초과된 글자수는 자동으로 삭제됩니다.\n");
			objMsg.innerText = objMsg.value.replace(/\r\n$/, "");
			objMsg.innerText = assertMsg(intMax, objMsg.innerText, st );
		}
	}
 

	function lengthMsg(objMsg) {

		if (objMsg == null){
			return 0;
		}

		var nbytes = 0;

		for (i=0; i<objMsg.length; i++) {

			var ch = objMsg.charAt(i);
			if(escape(ch).length > 4) {
				nbytes += 2;
			} else if (ch == '\n') {
				if (objMsg.charAt(i-1) != '\r') {
					nbytes += 1;
				}
			/*
			} else if (ch == '<' || ch == '>') {
				nbytes += 4;
			*/
			} else {
				nbytes += 1;
			}
		}
		return nbytes;
	}
 

	function assertMsg(intMax,objMsg,st ) {

		var inc = 0;
		var nbytes = 0;
		var msg = "";
		var msglen = objMsg.length;

		for (i = 0; i < msglen; i++) {
			var ch = objMsg.charAt(i);
			if (escape(ch).length > 4) {
				inc = 2;
			} else if (ch == '\n') {
				if (objMsg.charAt(i-1) != '\r') {
					inc = 1;
				}
			/*
			} else if (ch == '<' || ch == '>') {
				inc = 4;
			*/
			} else {
				inc = 1;
			}

			if ((nbytes + inc) > intMax) {
				break;
			}
			nbytes += inc;
			msg += ch;
		}
		//alert("Before_msg:" + objMsg);
		//alert("After_msg:" + msg);
		
		if ($('callback_url') != null && $('callback_url').value != ""){
			st.innerHTML = nbytes + parseInt($('callback_url').value.length);
		}
		else
			st.innerHTML = nbytes; //현재 byte수를 넣는다

		return msg;
	}



/* added by denny */
function openwin(szUrl)
{
    var WinProperty;
    WinProperty = 'toolbar=no,location=no,directories=no,menubar=no,resizable=no,scrollbars=no,width=350,height=270';
    window.open(szUrl, 'sendmsg', WinProperty);
}

function openwin2(szUrl)
{
    var WinProperty;
    WinProperty = 'toolbar=no,location=no,directories=no,menubar=no,resizable=yes,scrollbars=no,width=600,height=600';
    window.open(szUrl, 'sendmsg', WinProperty);
}

function openwin_named(szUrl, name)
{
    var WinProperty;
    WinProperty = 'toolbar=no,location=no,directories=no,menubar=no,resizable=yes,scrollbars=no,width=400,height=300';
    window.open(szUrl, name, WinProperty);
}

function del_confirm(url)
{
	openwin(url);
}

function tmt_winCentre()
{
    if (document.layers)
    {
        var sinist = screen.width / 2 - outerWidth / 2;
        var toppo = screen.height / 2 - outerHeight / 2;
    }
    else
    {
        var sinist = screen.width / 2 - document.body.offsetWidth / 2;
        var toppo = -75 + screen.height / 2 - document.body.offsetHeight / 2;
    }

    self.moveTo(sinist, toppo);
}


/* resize 를 위해 급추가 */
function winResize()
{
    var Dwidth = parseInt(document.body.scrollWidth);
    var Dheight = parseInt(document.body.scrollHeight);
    var divEl = document.createElement("div");
    divEl.style.position = "absolute";
    divEl.style.left = "0px";
    divEl.style.top = "0px";
    divEl.style.width = "100%";
    divEl.style.height = "100%";

    document.body.appendChild(divEl);

    window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight);
    document.body.removeChild(divEl);
}


function getDaysofMonth(yymm) {
		var mon = 0;
		var year = 0;

		mon = yymm.substr(4,6);
		year = yymm.substr(0,4);

		//alert('mon = ' + mon);
		//alert('year = ' + year);

		if(mon==2) {
            if(year%4==0) {
                if(year%100==0) {
                    if(year%400==0)
                        return 29;
                    else
                        return 28;
                }
                else
                    return 29;
            }
            else
                return 28;
        }

        if(mon==4||mon==6||mon==9||mon==11)
            return 30;
        else
            return 31;
	}

