// ¹®ÀÚ ¾ÕµÚ °ø¹é Àß¶ó³»´Â ÇÔ¼ö
String.prototype.trim = function(str) 
{
	str = this != window ? this : str;
	return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

//¹®ÀÚ¿­Áß°£¿¡°ø¹éÀÌ ÀÖ´ÂÁö Ã¼Å©
function isSpace(objInput)
{
     if(objInput.search(/\s/) != -1){
     	return 1;
     }
     else {
         return "";
     }
}

function ObjectWrite(Html) {
	document.write(Html);
}

//¾ÆÀÌÇÁ·¹ÀÓ ¸®»çÀÌÁîÇÔ¼ö
//¾ÆÀÌÇÁ·¹ÀÓ ¾È¿¡¼­ onLoad½Ã È£ÃâÇÏ¸é µË´Ï´ç..
//By Espeniel
function fnIfrmResize()
{
 	self.resizeTo(document.body.scrollWidth, document.body.scrollHeight);
}


//textarea ±ÛÀÚ¼ö °è»ê ÇÏ´Â ÇÔ¼ö
//»ç¿ë ¿¹..onkeyup="chkMsgLength(400,contents,currentMsgLen);"
//±ÛÀÚ¼ö Ä«¿îÅÍ¸¦ º¸°í ½ÍÀ¸¸é..<span id="currentMsgLen" style="padding-right:0;" >0</span>ÀÌ·¸°Ô ÇÏ¸éµË´Ï´Ù.
function chkMsgLength(intMax,objMsg,st)
{

	var length = lengthMsg(objMsg.value);
	st.innerHTML = length;//ÇöÀç byte¼ö¸¦ ³Ö´Â´Ù

	if (length > intMax) {

		alert("ÃÖ´ë " + intMax + "byteÀÌ¹Ç·Î ÃÊ°úµÈ ±ÛÀÚ¼ö´Â ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù.\n");
		objMsg.value = objMsg.value.replace(/\r\n$/, "");
		objMsg.value = assertMsg(intMax,objMsg.value,st );

	}
}

function lengthMsg(objMsg)
{

	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;
	}

	st.innerHTML = nbytes; //ÇöÀç byte¼ö¸¦ ³Ö´Â´Ù
	return msg;
}

function iframe_autoResize(i) // iframe Auto Height
{
	
    var iframeHeight=
    (i).contentWindow.document.body.scrollHeight;
    
    
    if(iframeHeight > (i).height || (i).height =='100%')
    (i).height=iframeHeight+20;
}

