var payurl = document.location.hostname;

//#############################################################################
//# ÆË¾÷Ã¢ ¶ç¿ì±â
//#############################################################################
function Open_Win(files,name,Width,Height,Scroll) 
{ 
  var win_width = (screen.width)/2 - Math.ceil(Width/2); 
  var win_height = (screen.height)/2 - Math.ceil(Height/2); 
  window.open(files,name,'menubar=0, status=0 locationbar=0,scrollbars='+Scroll+',resizable=0,left='+win_width+',top='+win_height+',width='+Width+',height='+Height); 
}

//#############################################################################
//# ÆË¾÷Ã¢ ¶ç¿ì±â
//#############################################################################
function Open_Popup(files, name, Width, Height, Left ,Top, Scroll) 
{ 
  window.open(files,name,'menubar=0, status=0 locationbar=1,scrollbars='+Scroll+',resizable=0,left='+Left+',top='+Top+',width='+Width+',height='+Height); 
}
//#############################################################################
//# ¸ð´ÞÃ¢ ¶ç¿ì±â
//#############################################################################
function Open_Modal(url, Width, Height)
{
	var win_width = (screen.width)/2 - Math.ceil(Width/2); 
	var win_height = (screen.height)/2 - Math.ceil(Height/2); 
	window.showModalDialog(url, self, "dialogLeft:"+win_width+"px; dialogTop:"+win_height+"px; dialogWidth:"+Width+"px; dialogHeight:"+Height+"px");
}
//#############################################################################
//# ÀÔ·Â ÇÊµå¿¡ ¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÏ°Ô....
//#############################################################################
function od(code) 
{
	if(code != 13)
	{
		if(code == 164) event.returnValue = false; 
		if ((code < 47) || (code > 57))
		{
			event.returnValue = false; 
		}
	}
}
//#############################################################################
//# °ø¹é Ã¼Å©
//#############################################################################
String.prototype.trim = function() 
{
	return this.replace(/^\s*(\b.*\b|)\s*$/, "$1"); 
}

//#############################################################################
//# °æ°í ¸Þ¼¼Áö
//#############################################################################
function alertmsg(obj,msg)
{
	var str = obj.value.trim();
	if(str.length == 0)
	{
		alert(msg);
		obj.value = "";
		obj.focus();
		return false;
	}
}

//#############################################################################
//# ¿ÞÂÊ ¸Þ´º ·Ñ¿À¹ö
//#############################################################################
function changeImg( imgObj, id )
{
	var curImage = imgObj.src;
	var changeTag = new String();
	var matchTag = new String();

	if( id == 1 )
	{
		matchTag = /.gif/gi;
		changeTag = "_o.gif";
	}
	else
	{
		matchTag = /_o.gif/gi;
		changeTag = ".gif";
	}
	imgObj.src = curImage.replace( matchTag, changeTag );
}

//#############################################################################
//# ¼ýÀÚ¸¸ 3ÀÚ¸®¸¶´Ù ÄÞ¸¶Âï±â
//#############################################################################
function number_format(num) {
	var num_str = num.toString();
	var result = '';

	for(var i=0; i<num_str.length; i++) 
	{
		var tmp = num_str.length-(i+1);
		if(i%3==0 && i!=0) result = ',' + result;
		result = num_str.charAt(tmp) + result;
	}
	return result;
}
//#############################################################################
//# ´ë¹®ÀÚ -> ¼Ò¹®ÀÚ
//#############################################################################
	function LowerUpperChange(temp,flag)
	{
		var str = "";
		for(i=0;i<temp.length;i++)
		{
			if(flag == "L"){
				str+=temp.charAt(i).toLowerCase(); //´ë¹®ÀÚ -> ¼Ò¹®ÀÚ
			} else {
				str+=temp.charAt(i).toUpperCase(); //¼Ò¹®ÀÚ -> ´ë¹®ÀÚ
			}
		}
		return str;
	}

//###################################################################
//# ÆÄÀÏ´Ù¿î·Îµå
//###################################################################
function goDownload(sdir, file)
{
	document.down_form.saveDir.value = sdir;
	document.down_form.file.value = file;
	document.down_form.action = "/common_/download.php";
	document.down_form.submit();
}
//#############################################################################
//# ÀÚ¹Ù½ºÅ©¸³Æ® ÄíÅ° °¡Á®¿À±â ÇÔ¼ö
//#############################################################################
function getCookie(name) {
     var Found = false
     var start, end
     var i = 0
     // cookie ¹®ÀÚ¿­ ÀüÃ¼¸¦ °Ë»ö
     while(i <= document.cookie.length) {
        start = i
        end = start + name.length
        // name°ú µ¿ÀÏÇÑ ¹®ÀÚ°¡ ÀÖ´Ù¸é
        if(document.cookie.substring(start, end) == name) {
            Found = true
            break
          }
        i++
     }
     // name ¹®ÀÚ¿­À» cookie¿¡¼­ Ã£¾Ò´Ù¸é
     if(Found == true) {
         start = end + 1
         end = document.cookie.indexOf(";", start)
     // ¸¶Áö¸· ºÎºÐÀÌ¶ó´Â °ÍÀ» ÀÇ¹Ì(¸¶Áö¸·¿¡´Â ";"°¡ ¾ø´Ù)
         if(end < start)
              end = document.cookie.length
              // name¿¡ ÇØ´çÇÏ´Â value°ªÀ» ÃßÃâÇÏ¿© ¸®ÅÏÇÑ´Ù.
         return document.cookie.substring(start, end)
      }
     // Ã£Áö ¸øÇß´Ù¸é
      return ""
}

//#############################################################################
//# ÀÚ¹Ù½ºÅ©¸³Æ® ÄíÅ° ¸¸µé±â ÇÔ¼ö
//#############################################################################
function setCookie( name, value, expiredays )
{
  var endDate = new Date();
  endDate.setDate( endDate.getDate()+ expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + endDate.toGMTString() + ";"
}
//#############################################################################
//# ÀÌ¸ÞÀÏ ¹× ÀÌ¸ÞÀÏÇüÅÂ ID°Ë»ç
//#############################################################################
function CheckEmail(strEmail)
{

    /** ±ÝÁö»çÇ×
     - @°¡ 2°³ÀÌ»ó
     - .ÀÌ ºÙ¾î¼­ ³ª¿À´Â °æ¿ì
     -  @.³ª  .@ÀÌ Á¸ÀçÇÏ´Â °æ¿ì
     - ¸ÇÃ³À½ÀÌ.ÀÎ °æ¿ì **/
    var regDoNot = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
    /** ÇÊ¼ö»çÇ×
     - @ÀÌÀü¿¡ ÇÏ³ªÀÌ»óÀÇ ¹®ÀÚ°¡ ÀÖ¾î¾ß ÇÔ
     - @°¡ ÇÏ³ªÀÖ¾î¾ß ÇÔ
     - Domain¸í¿¡ .ÀÌ ÇÏ³ª ÀÌ»ó ÀÖ¾î¾ß ÇÔ
     - Domain¸íÀÇ ¸¶Áö¸· ¹®ÀÚ´Â ¿µ¹®ÀÚ 2~3°³ÀÌ¾î¾ß ÇÔ **/
    var regMust = /^[a-zA-Z0-9\-\.\_]+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4})$/;
    
    if ( !regDoNot.test(strEmail) && regMust.test(strEmail) )
	{
		var strAlNumcomp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
		var strspcomp="'~!@#$%^&*()_-+=\<>?/:;|,.";
		var strmailcomp=strAlNumcomp + "@.-_";

		if(strEmail.length!=0) 
		{
			var emaillen=strEmail.length-1
		
			if(strEmail.indexOf("@")<1 || strEmail.indexOf(".")<1) 
			{
				alert("¸ÞÀÏÁÖ¼ÒÀÇ Çü½ÄÀÌ Àß¸øµÇ¾ú½À´Ï´Ù!");
			} 
			else if(StrCheck(strEmail.charAt(0),strspcomp) == true) 
			{
				alert("¸ÞÀÏÁÖ¼Ò Ã¹¹®ÀÚ´Â Æ¯¼ö¹®ÀÚ°¡ ¿Ã ¼ö ¾ø½À´Ï´Ù!");
			}
			else if(StrCheck(strEmail.charAt(emaillen),strspcomp) == true) 
			{
				alert("¸ÞÀÏÁÖ¼Ò ³¡¹®ÀÚ´Â Æ¯¼ö¹®ÀÚ°¡ ¿Ã ¼ö ¾ø½À´Ï´Ù!");
			}
			else if((StrCheck(strEmail,strmailcomp)) == false)
			{
				alert("E-MailÁÖ¼Ò¿¡ ÁöÁ¤µÇÁö ¾ÊÀº ¹®ÀÚ¿­ÀÌ µé¾î°¬½À´Ï´Ù! \n '-','_'ÀÌ¿ÜÀÇ Æ¯¼ö¹®ÀÚ¿Í ÇÑ±ÛÀº »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù!");
			}    
		}	
        return true;
	}
    else
	{
        return false;
	}
}
//#############################################################################
//# ÁÖ¹Îµî·Ï¹øÈ£ À¯È¿¼º Ã¼Å©
//#############################################################################
function juminChk(obj1,obj2)    
{
    // CheckSum Ã¼Å©
    if (chksumID(obj1,obj2) == false)
        return false;

    strReg1 = obj1.value;
    strReg2 = obj2.value;

    sGender = strReg2.substring(0,1);
    sYear = strReg1.substring(0,2);

    // µÎ¹øÂ° ´Ü¶ô Ã¹¹øÂ° ¼ýÀÚ´Â 4º¸´Ù Å¬ ¼ö ¾ø´Ù.
    if (sGender > 4) {
        return false;
    }
    
    // 2000³âµµ ÀÌÀüÀº ³²ÀÚ´Â 1, ¿©ÀÚ´Â 2
    // 2000³âµµ ÀÌÈÄ´Â ³²ÀÚ´Â 3, ¿©ÀÚ´Â 4
    if (sYear != '00') {
        if ((sGender != '1') && (sGender != '2')) {
            return false;
        }
    } else {
        if ((sGender != '3') && (sGender != '4')) {
            return false;
        }
    }
        
    // »ý¼º±â·Î ¸¸µç°Ô ¾Æ´Ñ°¡ »ý³â¿ùÀÏ Ã¼Å©
    if (ValidRegNo(obj1) == false)
        return false; 
}
//-------------------------------------------------------
// ÁÖ¹Î¹øÈ£ ¾ÕÀÚ¸® check check.
//-------------------------------------------------------
function ValidRegNo(obj1)    
{
    strReg1 = obj1.value;

    // YYMMDD°¡ ¸Â´ÂÁö È®ÀÎÇÑ´Ù.
    a = new String(strReg1);

    if(a == '') return false;
    if(a.length != 6 ) return false;

    intYear = parseInt(a.substring(0,2) , 10);
    intMonth = parseInt(a.substring(2,4) , 10);
    intDay = parseInt(a.substring(4,6) , 10);
    
    if(intMonth < 0 || intMonth > 12){ 
        return false;
    }
        
    switch(intMonth){
        case 2 :
            if(intDay < 0 || intDay > 29){
                return false;
                breake;
            }
        case 4 :
            if(intDay < 0 || intDay > 30){
                return false;
                breake;
            }
        case 6 :
            if(intDay < 0 || intDay > 30){
                return false;
                breake;
            }
        case 9 :
            if(intDay < 0 || intDay > 30){
                return false;
                breake;
            }
        case 11 :
            if(intDay < 0 || intDay > 30){
                return false;
                breake;
            }
        default :
            if(intDay < 0 || intDay > 31){
                return false;
                breake;
            }
    }
    
    return true;
}
function chksumID(obj1,obj2)    
{
    //¼ýÀÚ·Î¸¸±¸¼ºµÇ¾î ÀÖ´ÂÁö TestÇÒ Á¤±ÔÇ¥Çö.
	var regExpr = /^[0-9]+$/;

    var str1 = obj1.value;
    var str2 = obj2.value;
    var li_lastid,li_mod,li_minus,li_last;
    var value0,value1,value2,value3,value4,value5,value6;
    var value7,value8,value9,value10,value11,value12;
    
    if (regExpr.test(str1) &&  regExpr.test(str2)) {
        li_lastid    = parseFloat(str2.substring(6,7));
        value0  = parseFloat(str1.substring(0,1))  * 2;
        value1  = parseFloat(str1.substring(1,2))  * 3;
        value2  = parseFloat(str1.substring(2,3))  * 4;
        value3  = parseFloat(str1.substring(3,4))  * 5;
        value4  = parseFloat(str1.substring(4,5))  * 6;
        value5  = parseFloat(str1.substring(5,6))  * 7;
        value6  = parseFloat(str2.substring(0,1))  * 8;
        value7  = parseFloat(str2.substring(1,2))  * 9;
        value8  = parseFloat(str2.substring(2,3))  * 2;
        value9  = parseFloat(str2.substring(3,4))  * 3;
        value10 = parseFloat(str2.substring(4,5))  * 4;
        value11 = parseFloat(str2.substring(5,6))  * 5;
        value12 = 0;
        
        value12 = value0+value1+value2+value3+value4+value5+value6+value7+value8+value9+value10+value11+value12 ;
        
        li_mod = value12 %11;
        li_minus = 11 - li_mod;
        li_last = li_minus % 10;
        if (li_last != li_lastid){
            return false;
        } else
            return true;
    } else
    return false;
}
//#############################################################################
//# ¹®ÀÚ¿­ Ã¼Å©(ÀÌ¸ÞÀÏ Ã¼Å©)
//#############################################################################
function StrCheck(checkStr, checkOK)
{
	for (i=0; i<checkStr.length; i++)
	{
		ch=checkStr.charAt(i);
		for(j=0; j<checkOK.length; j++)
		{
			if (ch==checkOK.charAt(j))
			break;
		}

		if (j==checkOK.length)
		{
			return (false);
			break;
		}
	}
	return (true);
}

//#############################################################################
//# ¿ÞÂÊ¸Þ´º ¸¶¿ì½º¿À¹ö Ã¼Å©
//#############################################################################
function LeftMenuOverChk(tot, num)
{
	var obj = document.getElementById("lmtd"+num);
	for(var i = 1; i <= tot; i++)
	{
		obj.className = "lmenubg lmenu black bold";
	}
	document.getElementById("lmtd"+num).className="lmenubg_o lmenu white bold";
}
//#############################################################################
//# ¿ÞÂÊ¸Þ´º ¸¶¿ì½º ¾Æ¿ôÃ¼Å©
//#############################################################################
function LeftMenuOutChk(tot,num)
{
	var obj = document.getElementById("lmtd"+num);
	for(var i = 1; i <= tot; i++)
	{
		obj.className = "lmenubg lmenu black bold";
	}
}

//#############################################################################
//# ¿ÞÂÊ¸Þ´º Fade È¿°ú
//#############################################################################
function fadeIn(obj) {
    obj.style.filter="blendTrans(duration=1)";
    // ÇÊÅÍ°¡ ÀÛµ¿ÇÏ°í ÀÖÁö ¾ÊÀ½À» È®ÀÎ
    if ((obj.visibility != "visible") && (obj.filters.blendTrans.status != 2)) {
        obj.filters.blendTrans.Apply();
        obj.style.visibility="visible";
        obj.filters.blendTrans.Play();
    }
}

//#############################################################################
//# ÁÖ¹Îµî·Ï¹øÈ£ À¯È¿¼º Ã¼Å©
//#############################################################################
function juminChk(obj1,obj2)    
{
    // CheckSum Ã¼Å©
    if (chksumID(obj1,obj2) == false)
        return false;

    strReg1 = obj1.value;
    strReg2 = obj2.value;

    sGender = strReg2.substring(0,1);
    sYear = strReg1.substring(0,2);

    // µÎ¹øÂ° ´Ü¶ô Ã¹¹øÂ° ¼ýÀÚ´Â 4º¸´Ù Å¬ ¼ö ¾ø´Ù.
    if (sGender > 4) {
        return false;
    }
    
    // 2000³âµµ ÀÌÀüÀº ³²ÀÚ´Â 1, ¿©ÀÚ´Â 2
    // 2000³âµµ ÀÌÈÄ´Â ³²ÀÚ´Â 3, ¿©ÀÚ´Â 4
    if (sYear != '00') {
        if ((sGender != '1') && (sGender != '2')) {
            return false;
        }
    } else {
        if ((sGender != '3') && (sGender != '4')) {
            return false;
        }
    }
        
    // »ý¼º±â·Î ¸¸µç°Ô ¾Æ´Ñ°¡ »ý³â¿ùÀÏ Ã¼Å©
    if (ValidRegNo(obj1) == false)
        return false; 
}
//-------------------------------------------------------
// ÁÖ¹Î¹øÈ£ ¾ÕÀÚ¸® check check.
//-------------------------------------------------------
function ValidRegNo(obj1)    
{
    strReg1 = obj1.value;

    // YYMMDD°¡ ¸Â´ÂÁö È®ÀÎÇÑ´Ù.
    a = new String(strReg1);

    if(a == '') return false;
    if(a.length != 6 ) return false;

    intYear = parseInt(a.substring(0,2) , 10);
    intMonth = parseInt(a.substring(2,4) , 10);
    intDay = parseInt(a.substring(4,6) , 10);
    
    if(intMonth < 0 || intMonth > 12){ 
        return false;
    }
        
    switch(intMonth){
        case 2 :
            if(intDay < 0 || intDay > 29){
                return false;
                breake;
            }
        case 4 :
            if(intDay < 0 || intDay > 30){
                return false;
                breake;
            }
        case 6 :
            if(intDay < 0 || intDay > 30){
                return false;
                breake;
            }
        case 9 :
            if(intDay < 0 || intDay > 30){
                return false;
                breake;
            }
        case 11 :
            if(intDay < 0 || intDay > 30){
                return false;
                breake;
            }
        default :
            if(intDay < 0 || intDay > 31){
                return false;
                breake;
            }
    }
    
    return true;
}
function chksumID(obj1,obj2)    
{
    //¼ýÀÚ·Î¸¸±¸¼ºµÇ¾î ÀÖ´ÂÁö TestÇÒ Á¤±ÔÇ¥Çö.
	var regExpr = /^[0-9]+$/;

    var str1 = obj1.value;
    var str2 = obj2.value;
    var li_lastid,li_mod,li_minus,li_last;
    var value0,value1,value2,value3,value4,value5,value6;
    var value7,value8,value9,value10,value11,value12;
    
    if (regExpr.test(str1) &&  regExpr.test(str2)) {
        li_lastid    = parseFloat(str2.substring(6,7));
        value0  = parseFloat(str1.substring(0,1))  * 2;
        value1  = parseFloat(str1.substring(1,2))  * 3;
        value2  = parseFloat(str1.substring(2,3))  * 4;
        value3  = parseFloat(str1.substring(3,4))  * 5;
        value4  = parseFloat(str1.substring(4,5))  * 6;
        value5  = parseFloat(str1.substring(5,6))  * 7;
        value6  = parseFloat(str2.substring(0,1))  * 8;
        value7  = parseFloat(str2.substring(1,2))  * 9;
        value8  = parseFloat(str2.substring(2,3))  * 2;
        value9  = parseFloat(str2.substring(3,4))  * 3;
        value10 = parseFloat(str2.substring(4,5))  * 4;
        value11 = parseFloat(str2.substring(5,6))  * 5;
        value12 = 0;
        
        value12 = value0+value1+value2+value3+value4+value5+value6+value7+value8+value9+value10+value11+value12 ;
        
        li_mod = value12 %11;
        li_minus = 11 - li_mod;
        li_last = li_minus % 10;
        if (li_last != li_lastid){
            return false;
        } else
            return true;
    } else
    return false;
}

//###################################################################
//# ´Þ·Â Open/Close
//# fg : 1 :ÀÌ¹ø´ÞÀ» ´ÙÀ½´Þ¿µ¿ª¿¡ À§Ä¡ , 2 : ÀÌ¹ø´ÞÀ» ÀÌÀü´Þ¿µ¿ª¿¡ À§Ä¡
//# bChk : Y : ¿À´Ã³¯Â¥ ÀÌÀü³¯Â¥ ¼±ÅÃ°¡´É, N : ¿À´Ã³¯Â¥ ÀÌÀü ¼±ÅÃ ºÒ°¡´É
//# sId : div °´Ã¼¸í
//# sIn : input °´Ã¼¸í
//###################################################################
function OpenCalendar(fg, bChk, sId, sIn)
{
	if(document.getElementById(sId).style.display == "none" || !document.getElementById(sId).style.display)
	{
		document.getElementById(sId).style.display = "block";
		document.getElementById(sId).style.position="absolute";
		hiddenframe.location.replace("/common_/multi_calendar.php?fg="+fg+"&bChk="+bChk+"&sId="+sId+"&sIn="+sIn);
	}
	else
	{
		CloseCalendar(sId);
	}
}

//###################################################################
//# ´Þ·Â Close
//###################################################################
function CloseCalendar(sId)
{
	document.getElementById(sId).style.display = "none";
}

//###################################################################
//# ´Þ·Â ÀÌÀü´Þ / ´ÙÀ½´Þ ÀÌµ¿
//###################################################################
function MoveCalendar(sId, sIn, year, mm, bChk)
{
	hiddenframe.location.replace("/common_/multi_calendar.php?cur_y="+year+"&cur_m="+mm+"&sId="+sId+"&sIn="+sIn+"&bChk="+bChk);
}

function ReturnDate(date, sId, sIn)
{
	var obj = eval("document.all."+sIn);
	obj.value = date;
	CloseCalendar(sId);
}

function FlashObject(url, width, height)
{
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ");
	document.write("		codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ");
	document.write("		width='"+width+"' height='"+height+"' align='middle'>");
	document.write("	<param name='allowScriptAccess' value='always' /> ");
	document.write("	<param name='movie'				value='"+url+"' /> ");
	document.write("	<param name='quality'			value='high' /> ");
	document.write("	<param name='wmode'				value='transparent'> ");
	document.write("	<embed src='"+url+"' quality='high' width='"+width+"' height='"+height+"' align='middle' ");
	document.write("		allowScriptAccess='always' type='application/x-shockwave-flash' ");
	document.write("		pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.write("</object>");
}


//###################################################################
//# ´Þ·Â Open/Close
//# fg : 1 :ÀÌ¹ø´ÞÀ» ´ÙÀ½´Þ¿µ¿ª¿¡ À§Ä¡ , 2 : ÀÌ¹ø´ÞÀ» ÀÌÀü´Þ¿µ¿ª¿¡ À§Ä¡
//# bChk : Y : ¿À´Ã³¯Â¥ ÀÌÀü³¯Â¥ ¼±ÅÃ°¡´É, N : ¿À´Ã³¯Â¥ ÀÌÀü ¼±ÅÃ ºÒ°¡´É
//# sId : div °´Ã¼¸í
//# sIn : input °´Ã¼¸í
//###################################################################
function OpenCalendar(fg, bChk, sId, sIn)
{
	if(document.getElementById(sId).style.display == "none" || !document.getElementById(sId).style.display)
	{
		document.getElementById(sId).style.display = "block";
		document.getElementById(sId).style.position="absolute";
		hiddenframe.location.replace("/common_/multi_calendar.php?fg="+fg+"&bChk="+bChk+"&sId="+sId+"&sIn="+sIn);
	}
	else
	{
		CloseCalendar(sId);
	}
}
//###################################################################
//# ´Þ·Â Close
//###################################################################
function CloseCalendar(sId)
{
	document.getElementById(sId).style.display = "none";
}
//###################################################################
//# ´Þ·Â ÀÌÀü´Þ / ´ÙÀ½´Þ ÀÌµ¿
//###################################################################
function MoveCalendar(sId, sIn, year, mm, bChk)
{
	hiddenframe.location.replace("/common_/multi_calendar.php?cur_y="+year+"&cur_m="+mm+"&sId="+sId+"&sIn="+sIn+"&bChk="+bChk);
}

function padZero(num,leng) {
	var zero=leng-(""+num).length;
	if (typeof(num)=="number" && zero>0)
	{
		var tmp="";
		for (var i=0; i<zero; i++) tmp+="0";
		return tmp+num;
	}
	else
	{
		return num;
	}
}


function MM_swapImgRestore() {
	//v3.0
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() {
	//v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){
				d.MM_p[j]=new Image;
			d.MM_p[j++].src=a[i];
		}
	}
}

function MM_findObj(n, d) {
	//v4.01
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n);
		return x;
}

function MM_swapImage() {
	//v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){
			document.MM_sr[j++]=x;
		if(!x.oSrc) x.oSrc=x.src;
		x.src=a[i+2];
	}
}

function bluring(){
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG")
		document.body.focus();
}
document.onfocusin=bluring;


//#############################################################################
//# 80¹ÙÀÌÆ® ÀÌ»óÀÌ¸é ¹®ÀÚ ÀÚ¸£±â
//#############################################################################
function cut( str, limit )
{
	var l = 0;
	for ( var i=0;i<str.length;i++ )
	{
		if ( str.charAt(i) != 13 ) {
			l += (str.charCodeAt(i) > 128) ? 2 : 1;
		}
		if ( l > limit ) return str.substring(0,i);
	}
	return str;
}

//#############################################################################
//# ÇÑ±Û, ¼ýÀÚ, ¿µ¾îÀÇ ¹ÙÀÌÆ® ¼ö °è»ê
//#############################################################################
function strCharByte(chStr)
{
    if (chStr.substring(0, 2) == '%u')
    {
        if (chStr.substring(2,4) == '00')
            return 1;
        else
            return 2;
    }
    else if (chStr.substring(0,1) == '%') 
    {
        if (parseInt(chStr.substring(1,3), 16) > 127)
            return 2;
        else
            return 1;
    }
    else
        return 1;
}

//#############################################################################
//# ¹®ÀÚ¿­ ±æÀÌ ¸®ÅÏ
//#############################################################################
function strLengthByte(str) 
{
    var totLength = 0;
    for (var i=0;i<str.length;i++)
        totLength += strCharByte(escape(str.charAt(i)));
    return totLength;
}

//#############################################################################
//# SMS ³»¿ë Ã¼Å©
//#############################################################################
function inputText(editnum)
{
	if(editnum)
	{
		editlen = strLengthByte(document.getElementById("content_"+editnum).value);
		if ( editlen > 1000 )
		{
			alert("µ¡±ÛÀº 1000BYTE ±îÁö¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.");
			document.getElementById("content_"+editnum).value = cut( document.getElementById("content_"+editnum).value, 1000 );
			document.getElementById("content_"+editnum).focus();
		}
		document.getElementById("StrBite_"+editnum).innerHTML = strLengthByte( document.getElementById("content_"+editnum).value );	
	}
	else
	{
		var f = document.all;
		len = strLengthByte( f.content.value );
		if ( len > 1000 )
		{
			alert("µ¡±ÛÀº 1000BYTE ±îÁö¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.");
			f.content.value = cut( f.content.value, 1000 );
			f.content.focus();
		}
		StrBite.innerHTML = strLengthByte( f.content.value );
	}
}