var onEditMode = true;
var Selection = null;


function initEditor() 
{
    var source = "<html><head><style>.Background {background-color:#FFFFFF} P {margin-top:2px;margin-bottom:2px;} table {border:1 solid C6C3C6}</style><script>function resizeImage(num){}</script></head><body class=\"Background\"></body></html>";

    EDITOR.document.designMode="On";
    EDITOR.document.open("text/html");
    EDITOR.document.write(source);
    EDITOR.document.close();


    EDITOR.document.body.style.fontSize = "9pt";
    EDITOR.document.body.style.fontFamily = "µ¸¿ò";
}

function setFont(oSelect)
{
    if (oSelect.options[oSelect.selectedIndex].value != '')
        EDITOR.document.execCommand("FontName", null, oSelect.options[oSelect.selectedIndex].value);
                   
    oSelect.selectedIndex = 0;   
}

function postContent()
{
    HTMLSOURCE = EDITOR.document.body.innerHTML;

	EDITOR.document.body.createTextRange().execCommand("copy"); 
	
    return HTMLSOURCE;
}

function setFontSize(oSelect)
{
    if (oSelect.options[oSelect.selectedIndex].value != '')
        EDITOR.document.execCommand("FontSize", null, oSelect.options[oSelect.selectedIndex].value);
        
    oSelect.selectedIndex = 0;
}

function editContent(act)
{
    if (!onEditMode)
    {
        alert("HTML ¸ðµå¿¡¼­´Â ¿¡µðÅÍ¸¦ »ç¿ëÇÒ¼ö ¾ø½À´Ï´Ù.");
        return;
    }                        

    Selection = EDITOR.document.selection.createRange();
    if (Selection != null) Selection.select();
    if (Selection.text == '') return;
	
    switch (act)
    {
        case "Bold" :
        case "Italic" :
        case "Underline" :
        case "StrikeThrough" :        
        case "JustifyLeft" :
        case "JustifyCenter" :
        case "JustifyRight" :
            EDITOR.document.execCommand(act);
            break;
        case "fontcolor" :
        case "bgcolor" :        
            showFontColorBox(act);
            break;
        case "link" :
            showLinkBox();
    }
}

function showFontColorBox(act)
{
    if (act == "fontcolor")
    {
        document.all["TableFontColor"].style.display = "";
        document.all["TableBGColor"].style.display = "none";
    }
    if (act == "bgcolor")
    {
        document.all["TableFontColor"].style.display = "none";
        document.all["TableBGColor"].style.display = "";
    }
}

function showLinkBox()
{
    EDITOR.focus();
    EDITOR.document.execCommand("CreateLink",true);
}

function setFontColor(color)
{
    if (Selection != null) 
        Selection.select();
    EDITOR.document.execCommand("ForeColor", false, color);

    document.all["TableFontColor"].style.display = "none";
    EDITOR.document.selection.empty();
}

function setBGColor(color, ftcolor)
{
    if (Selection != null) 
        Selection.select();
    EDITOR.document.execCommand("BackColor", null, color );
    if (ftcolor != "")
          EDITOR.document.execCommand("ForeColor", null, ftcolor);

    document.all["TableBGColor"].style.display = "none";
    EDITOR.document.selection.empty();
}

function setBackColor(color)
{
    EDITOR.document.body.style.backgroundColor = color;
}

var sepFile = "||";
var setField = "|";
function popImage()
{
    open_wnd("attach_img.php", "addimage", 330, 280);
}

function popLink()
{
    open_wnd("attach_link.php", "addlink", 330, 240);
}

function addLink(attachURL, comment, alignPos, chk, new_id)
{
    try
    {
        var attachTag = getAttachTag(attachURL, comment, alignPos, chk, new_id);

        if (alignPos=='top')
        {
            EDITOR.document.body.innerHTML =  attachTag+ "<br>" + EDITOR.document.body.innerHTML;
        }
        else if (alignPos=='bottom')
        {
            EDITOR.document.body.innerHTML =  EDITOR.document.body.innerHTML + "<br>" + attachTag ;
        }
        else
        {
            var sText = EDITOR.document.selection.createRange();
            
            if (sText.parentElement().all.EDITOR == null)
            {
                if (sText.parentElement().outerHTML.indexOf('<BODY') > 0)
                {
                    sText.parentElement().innerHTML = "<P>" + attachTag + sText.parentElement().innerHTML  +  "</P>"
                }
                else
                {
                    sText.parentElement().innerHTML = attachTag + sText.parentElement().innerHTML  
                }
            }
               else
               {
                EDITOR.document.body.innerHTML = "<P>" + attachTag + EDITOR.document.body.innerHTML + "</P>";
            }
        }
    }
    catch(e)
    {
        EDITOR.document.body.innerHTML = "<P>" + attachTag + EDITOR.document.body.innerHTML + "</P>";
    }
    
    EDITOR.focus();
}

function getAttachTag(attachURL, comment, alignPos, chk , new_id)
{
    var attachTag = "";
        
    if (chk == "1")
    {
//         attachURL = "http://cafefiles.naver.net" + attachURL;
         attachURL = "http://www.2gun.net" + attachURL;
    }
        
    attachURL = attachURL.replace(/'/g, "\'");
            
    if  (attachURL.match(/.jpg|.jpeg|.gif|.png$/i))
    {
//        var imgid = parseInt((Math.random()*10000000));    
        var imgid = new_id;    
		
        if (alignPos == 'top' || alignPos == 'bottom')
            attachTag = "<center><img src='" + attachURL + "' align='" + alignPos + "' id='userImg" + imgid + "' onload='setTimeout(\"resizeImage(" + imgid + ")\",200)' style='cursor:hand' onclick='popview(\"" + attachURL + "\")'>" + comment + "</center>" ;
        else
            attachTag = "<img src='" + attachURL + "' align='" + alignPos + "' id='userImg" + imgid + "' onload='setTimeout(\"resizeImage(" + imgid + ")\",200)' style='cursor:hand' onclick='popview(\"" + attachURL + "\")'>" + comment ;
    }
    else 
    {
        attachTag = "<embed autostart='true' src='" + attachURL + "' >" + comment;
    }
    
    return attachTag;
}

function addList(dirname, filename, filesize)
{
    // Æú Ã·ºÎ
    if (filename == 'poll@nhn')
    {
        document.all.attachfilelist.add(new Option('ÆúÀÌ Ã·ºÎµÇ¾ú½À´Ï´Ù' , filename));
        //document.all.attachfilelist.options[document.all.attachfilelist.length-1].selected = true;        
    }
    // ÀÏ¹Ý ÆÄÀÏ Ã·ºÎ
    else
    {
        if (filesize)
        {    
            calcFileSize(filesize, 1);
            document.all.attachfilelist.add(new Option(filename + "   " + parseInt(parseInt(filesize)/1024) + "KB", dirname +"/" + filename));
            //document.all.attachfilelist.options[document.all.attachfilelist.length-1].selected = true;
        }
        else
            document.all.attachfilelist.add(new Option(filename, dirname +"/" + filename));
            //document.all.attachfilelist.options[document.all.attachfilelist.length-1].selected = true;            
    }
}

function calcFileSize(filesize, oper)
{
    if (oper == 1)
    {
        document.all.attachsizerealsum.value = parseInt(document.all.attachsizerealsum.value) + parseInt(filesize);
    }
    else
    {
        document.all.attachsizerealsum.value = parseInt(document.all.attachsizerealsum.value) - parseInt(filesize);
    }
    
    document.all.attachsizesum.value = parseInt(document.all.attachsizerealsum.value/1024);    
}

function addFile(dirname, filename, filesize, filetype)
{
    if (filetype == "F") document.all.attachfileyn.value = "Y";
    if (filetype == "I") document.all.attachimageyn.value = "Y";
    document.all.attachfiles.value = document.all.attachfiles.value + dirname +"/" + filename + "|" + filetype + "||";
    document.all.attachsizes.value = document.all.attachsizes.value + filesize + "||";
	
}

function removeFile(index)
{
    arrAttachfile = document.all.attachfiles.value.split("||");
    arrAttachsize = document.all.attachsizes.value.split("||");

    calcFileSize(arrAttachsize[index], -1);    
    
    arrAttachfile.remove(index);
    arrAttachsize.remove(index);
    document.all.attachfiles.value = arrAttachfile.join("||");
    document.all.attachsizes.value = arrAttachsize.join("||");
    
    
    document.all.attachfileyn.value = "";
    document.all.attachimageyn.value = "";
    for (var i = 0; i<arrAttachfile.length; i++)
    {
        if (arrAttachfile[i].match(/F$/))
        {
            document.all.attachfileyn.value = "Y";
        }
        if (arrAttachfile[i].match(/I$/))
        {
            document.all.attachimageyn.value = "Y";
        }
    }
}

function removeAttach()
{
    var attachlist = document.all.attachfilelist;
    
    if (attachlist.selectedIndex <= 0)
        return;

    if (attachlist.options[attachlist.selectedIndex].value == "poll@nhn")
        removePoll();
    else
        removeFile(attachlist.selectedIndex-1);
    
    attachlist.remove(attachlist.selectedIndex);    
}

function decodeContent(str)
{
    return str.replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&amp;/gi,"&");
}

function setContent()
{
//    EDITOR.document.body.innerHTML = decodeContent(document.all.DIVcontent.innerHTML);
    EDITOR.document.body.innerHTML = document.all.content.value;
}

function checkpos()
{
    var sText = EDITOR.document.selection.createRange();
    
    if (sText.parentElement().all.EDITOR == null && sText.parentElement().all.papermain == null)
    {
        var lineval = sText.parentElement().outerHTML.toLowerCae();

        var idx = lineval.indexOf("<font");
        if (idx > -1)
        {
            try 
            {
                if (sText.parentElement().face != null)
                {
                    if (sText.parentElement().face != "")
                        document.all.fontface.value = sText.parentElement().face;
                    else
                        document.all.fontface.selectedIndex = 1;
                }
                else
                {
                    document.all.fontface.selectedIndex = 1;
                }

                if (sText.parentElement().size != null)
                {
                    if (sText.parentElement().size != "")
                        document.all.fontsize.value = sText.parentElement().size;
                    else
                        document.all.fontsize.selectedIndex = 0;
                }
                else
                {
                    document.all.fontsize.selectedIndex = 0;
                }
            }
            catch(e) {}
        }
        else
        {
            try 
            {
                document.all.fontface.selectedIndex = 1;
                document.all.fontsize.selectedIndex = 0;
            }
            catch(e) {}

        }
    }
}

function checkposkey()
{
    if (EDITOR.event.keyCode >= 37 && EDITOR.event.keyCode <= 40)
    {
        var sText = EDITOR.document.selection.createRange();
        
        if (sText.parentElement().all.EDITOR == null && sText.parentElement().all.papermain == null)
        {
            var lineval = sText.parentElement().outerHTML.toLowerCase();
            var idx = lineval.indexOf("<font");
            
            if (idx > -1)
            {
                try {
                    if (sText.parentElement().face != null)
                    {
                        if (sText.parentElement().face != "")
                            document.all.fontface.value = sText.parentElement().face;
                        else
                            document.all.fontface.selectedIndex = 1;
                    }
                    else
                    {
                        document.all.fontface.selectedIndex = 1;
                    }
                    
                    if (sText.parentElement().size != null)
                    {
                        if (sText.parentElement().size != "")
                            document.all.fontsize.value = sText.parentElement().size;
                        else
                            document.all.fontsize.selectedIndex = 0;
                    }
                    else
                    {
                        document.all.fontsize.selectedIndex = 0;
                    }
                }
                catch(e) {}
            }
            else
            {
                document.all.fontface.selectedIndex = 1;
                document.all.fontsize.selectedIndex = 0;
            }
        }
    }
}

document.write("" 
  + "<div id='TableFontColor' style='position:absolute;top:50;left:240;display:none;'>"
  + "<table width='200' border='0' cellspacing='1' cellpadding='0' bgcolor='#CCCCCC'>"
  + "<tr>" 
  + "<td align='center' bgcolor='#FFFFFF' width='85'>" 
  + "<table width='111' border='0' cellspacing='4' cellpadding='0' height='88' style='cursor:hand'>"
  + "<tr>" 
  + "<td bgcolor='#008000' onclick='setFontColor(\"#008000\");'>&nbsp;</td>"
  + "<td bgcolor='#009966' onclick='setFontColor(\"#009966\");'>&nbsp;</td>"
  + "<td bgcolor='#99CC66' onclick='setFontColor(\"#99CC66\");'>&nbsp;</td>"
  + "<td bgcolor='#999966' onclick='setFontColor(\"#999966\");'>&nbsp;</td>"
  + "<td bgcolor='#CC9900' onclick='setFontColor(\"#CC9900\");'>&nbsp;</td>"
  + "</tr>"
  + "<tr>" 
  + "<td bgcolor='#D41A01' onclick='setFontColor(\"#D41A01\");'>&nbsp;</td>"
  + "<td bgcolor='#FF0000' onclick='setFontColor(\"#FF0000\");'>&nbsp;</td>"
  + "<td bgcolor='#FF7635' onclick='setFontColor(\"#FF7635\");'>&nbsp;</td>"
  + "<td bgcolor='#FF9900' onclick='setFontColor(\"#FF9900\");'>&nbsp;</td>"
  + "<td bgcolor='#FF3399' onclick='setFontColor(\"#FF3399\");'>&nbsp;</td>"
  + "</tr>"
  + "<tr>" 
  + "<td bgcolor='#9B18C1' onclick='setFontColor(\"#9B18C1\");'>&nbsp;</td>"
  + "<td bgcolor='#993366' onclick='setFontColor(\"#993366\");'>&nbsp;</td>"
  + "<td bgcolor='#666699' onclick='setFontColor(\"#666699\");'>&nbsp;</td>"
  + "<td bgcolor='#0000FF' onclick='setFontColor(\"#0000FF\");'>&nbsp;</td>"
  + "<td bgcolor='#177FCD' onclick='setFontColor(\"#177FCD\");'>&nbsp;</td>"
  + "</tr>"
  + "<tr>" 
  + "<td bgcolor='#006699' onclick='setFontColor(\"#006699\");'>&nbsp;</td>"
  + "<td bgcolor='#003366' onclick='setFontColor(\"#003366\");'>&nbsp;</td>"
  + "<td bgcolor='#333333' onclick='setFontColor(\"#333333\");'>&nbsp;</td>"
  + "<td bgcolor='#8E8E8E' onclick='setFontColor(\"#8E8E8E\");'>&nbsp;</td>"
  + "<td bgcolor='#C1C1C1' onclick='setFontColor(\"#C1C1C1\");'>&nbsp;</td>"
  + "</tr>"
  + "</table>"
  + "</td>"
  + "<td align='center' bgcolor='#FFFFFF' width='162' valign='top'>"
  + "<br>"
  + "Á÷Á¢ÀÔ·Â"
  + "<font face='Verdana' size='1'>" 
  + "<input type='text' name='FontBox' style='width:60px' maxlength='6' class='box' value=''>"
  + "</font>"
  + "<br>"
  + "<table width='5' border='0' cellspacing='0' cellpadding='0' height='10'>"
  + "<tr>" 
  + "<td>&nbsp;</td>"
  + "</tr>"
  + "</table>"
  + "<a href='javascript:setFontColor(document.all.FontBox.value);'><img src='http://cafeimgs.naver.com/img/btn_ok01.gif' width='32' height='19' align='absmiddle'></a>"
  + "<br>"
  + "</td>"
  + "</tr>"
  + "</table>"
  + "</div>");

document.write(""
  + "<div id='TableBGColor' style='position:absolute;top:0;left:260;display:none;'>"
  + "<table width='200' border='0' cellspacing='1' cellpadding='0' bgcolor='#CCCCCC'>"
  + "  <tr>" 
  + "    <td align='center' bgcolor='#FFFFFF' width='85'>" 
  + "      <table width='111' border='0' cellspacing='5' cellpadding='0' height='88' style='cursor:hand'>"
  + "        <tr valign='top'>" 
  + "          <td bgcolor='#FFDAED' width='53' onclick='setBGColor(\"#FFDAED\",\"\");'>¹ÙÅÁ»ö</td>"
  + "          <td bgcolor='#FF0000' width='53' onclick='setBGColor(\"#FF0000\",\"#FFFFFF\");'><font color='#FFFFFF'>¹ÙÅÁ»ö</font></td>"
  + "        </tr>"
  + "        <tr valign='top'>" 
  + "          <td bgcolor='#99DCFF' width='53' onclick='setBGColor(\"#99DCFF\",\"\");'>¹ÙÅÁ»ö</td>"
  + "          <td bgcolor='#0000FF' width='53' onclick='setBGColor(\"#0000FF\",\"#FFFFFF\");'><font color='#FFFFFF'>¹ÙÅÁ»ö</font></td>"
  + "        </tr>"
  + "        <tr valign='top'>" 
  + "          <td bgcolor='#A6FF4D' width='53' onclick='setBGColor(\"#A6FF4D\",\"\");'>¹ÙÅÁ»ö</td>"
  + "          <td bgcolor='#009966' width='53' onclick='setBGColor(\"#009966\",\"#FFFFFF\");'><font color='#FFFFFF'>¹ÙÅÁ»ö</font></td>"
  + "        </tr>"
  + "        <tr valign='top'>" 
  + "          <td bgcolor='#E4FF75' width='53' onclick='setBGColor(\"#E4FF75\",\"\");'>¹ÙÅÁ»ö</td>"
  + "          <td bgcolor='#E4E4E4' width='53' onclick='setBGColor(\"#E4E4E4\",\"\");'>¹ÙÅÁ»ö</td>"
  + "        </tr>"
  + "        <tr valign='top'>" 
  + "          <td bgcolor='#333333' width='53' onclick='setBGColor(\"#333333\",\"#FFFFFF\");'><font color='#FFFFFF'>¹ÙÅÁ»ö</font></td>"
  + "          <td bgcolor='#333333' width='53' onclick='setBGColor(\"#333333\",\"#FFFF00\");'><font color='#FFFF00'>¹ÙÅÁ»ö</font></td>"
  + "        </tr>"
  + "        <tr valign='top'>" 
  + "          <td bgcolor='#8E8E8E' width='53' onclick='setBGColor(\"#8E8E8E\",\"#FFFFFF\");'><font color='#FFFFFF'>¹ÙÅÁ»ö</font></td>"
  + "          <td bgcolor='#CDCDCD' width='53' onclick='setBGColor(\"#CDCDCD\",\"#FFFFFF\");'><font color='#FFFFFF'>¹ÙÅÁ»ö</font></td>"
  + "        </tr>"
  + "        <tr valign='top'>" 
  + "          <td width='53' onclick='setBGColor(\"\",\"\");'>¹ÙÅÁ»ö</td>"
  + "          <td width='53'>&nbsp;</td>"
  + "        </tr>"
  + "      </table>"
  + "    </td>"
  + "    <td align='center' bgcolor='#FFFFFF' width='162'>"
  + "      <br>"
  + "      Á÷Á¢ÀÔ·Â"
  + "      <br>"
  + "      <input type='text' name='FontBox2' style='width:60px' maxlength='6' class='box' value='' align='absmiddle'>"
  + "      <br>"
  + "      <table width='5' border='0' cellspacing='0' cellpadding='0' height='10'>"
  + "        <tr>" 
  + "          <td>&nbsp;</td>"
  + "        </tr>"
  + "      </table>"
  + "      <a href='javascript:setBGColor(document.all.FontBox2.value,\"\");'><img src='http://cafeimgs.naver.com/img/btn_ok01.gif' width='32' height='19' align='absmiddle'></a>"
  + "      <br>"
  + "      <br>"
  + "    </td>"
  + "  </tr>"
  + "</table>"
  + "</div>");
  
document.write(""
  + "<div id='TableLink' style='position:absolute;top:100;left:280;display:none;'>"
  + "<table width=260 border=0 cellspacing=1 cellpadding=3 bgcolor='#CCCCCC'>"
  + "<tr>"
  + "<td bgcolor='#FFFFFF'>"
  + "<input type='text' name='linkbox' style='width:215px' class='box' value='http://' align='absmiddle'>"
  + "<a href='javascript:setLink(document.all.linkbox.value);'><img src='http://blogimgs.naver.com/imgs/btn_ok01.gif' width='32' height='19' align='absmiddle'></a>"
  + "</td>"
  + "</tr>"
  + "</table>"
  + "</div>");


// ¼­ºñ½º Àû¿ëÈÄ »ç¿ë document.domain = "naver.com";


// iframe resize½Ã ÃÖ¼Ò width, height
var frmMinWidth;
var frmMinHeight;
var applyMinSize = false;
// iframe resize½Ã ÃÖ´ë width, height
var frmMaxWidth;
var frmMaxHeight;
var applyMaxSize = false;
function setMinSize(width, height)
{
	frmMinWidth = width;
	frmMinHeight = height
	applyMinSize = true;
}
function setMaxSize(width, height)
{
	frmMaxWidth = width;
	frmMaxHeight = height
	applyMaxSize = true;
}

function resizeIframe(name)
{
	if (name == null || name == "")
	{
		name = "main";
	}
	
	try
	{
		var oBody   = document.frames(name).document.body;
		var oIFrame = document.all(name);
		//var frmWidth  = oBody.scrollWidth + (oIFrame.offsetWidth - oIFrame.clientWidth);
		//var frmHeight = oBody.scrollHeight + (oIFrame.offsetHeight - oIFrame.clientHeight);
		var frmWidth  = oBody.scrollWidth;
		var frmHeight = oBody.scrollHeight;

		if (applyMinSize)
		{
			frmWidth  = Math.max(frmWidth, frmMinWidth);
			frmHeight = Math.max(frmHeight, frmMinHeight);
		}
		if (applyMaxSize)
		{
			frmWidth  = Math.min(frmWidth, frmMaxWidth);
			frmHeight = Math.min(frmHeight, frmMaxHeight);
		}
		
		oIFrame.style.height = frmHeight;
		oIFrame.style.width = frmWidth;
	}
	catch (e)
	{
		window.status = "IFrame Resize Error";
	}
}

function parentResizeIframe(name)
{
	if (parent && parent != this && parent.resizeIframe != null)
	{
		parent.resizeIframe(name);
	}
}

// F5¸¦ ´­·¶À»¶§ iframe ³»ºÎ¸¸ refresh µÇµµ·Ï Ã³¸®
document.onkeydown = trapRefresh;
function trapRefresh()
{
	if (event.keyCode == 116)
	{
		event.keyCode = 0; 
		event.cancelBubble = true; 
		event.returnValue = false;
		document.location.reload();
	}
}

function parentPlusIframe(name, height)
{
	if (parent && parent != this && parent.plusIframe != null)
	{
		parent.plusIframe(name, height);
	}
}

function plusIframe(name, height) 	{
	if (name == null || name == "")
	{
		name = "main";
	}
	
	try
	{
		var oBody   = document.frames(name).document.body;
		var oIFrame = document.all(name);
		var frmHeight  = oBody.scrollHeight;

		if (applyMinSize)
		{
			frmHeight = Math.max(frmHeight, frmMinHeight);
		}
		if (applyMaxSize)
		{
			frmHeight = Math.min(frmHeight, frmMaxHeight);
		}
		oIFrame.style.height = frmHeight + height;
	}
	catch (e)
	{
		window.status = "IFrame Size Plus Error";
	}
}

function resizepopup() 	{
	var winW = 356, winH = 200;
	winW = 356;
  winH = document.body.scrollHeight;

	if(winH > 550){
		winH = 550;
	}
  window.resizeTo(winW,winH+30);

}

function resizepopup2(wid) 	{
	var winW = wid, winH = 200;
	winW = wid;
  winH = document.body.scrollHeight;

	if(winH > 550){
		winH = 550;
	}
  window.resizeTo(winW,winH+40);

}



/* validate °ü·Ã ÇÔ¼ö */

// FORM FIELD CHECK 1. NULL CHECK
function checkNull(oField, strMsg, blnFocus)
{
	var isNotNull = false;
	var fieldType = null;
	var mainField;
	
	if (typeof(oField.type) == 'undefined' && typeof(oField.length) != 'undefined')

		mainField = oField[0];
	else
		mainField = oField;
	fieldType = mainField.type;


	switch (fieldType)
	{
		case "text" :
		case "password" :
		case "file" :
			isNotNull = hasValue(oField);
			break;
		case "textarea" :
			isNotNull = hasEditerValue(oField);
			break;
		case "checkbox" :
		case "radio" :		
			isNotNull = isChecked(oField);
			break;		
		case "select-one" :
		case "select-multiple" :
			isNotNull = isNotSelected(oField);
			break;
	}
	
	if (!isNotNull)
	{
		alert(strMsg);
		if (blnFocus == true)
		{
			mainField.focus();
		}
	}
	
	return isNotNull;
}

function hasValue(oField)
{
	if (oField.value.replace(/(^\s*)|(\s*$)/g, "") == "")
		return false;
	else
		return true;
}

function hasEditerValue(oField)
{
	if (oField.value.replace(/&nbsp;/g, " ").replace(/(^\s*)|(\s*$)/g, "") == "")
		return false;
	else
		return true;
}

function isChecked(oField)
{	
	var checked = false;

	if (typeof(oField.length) != 'undefined')
	{
		for (var i=0; i<oField.length; i++)
			if (oField[i].checked)
				checked = true;
	}
	else
	{
		checked = oField.checked;
	}
	
	return checked;
}

function isNotSelected(oField)
{
	if (oField.selectedIndex == -1)
	{
		return false;
	}
	else
	{
		if (oField.value == -1)
			return false;
		else
			return true;
	}
}
// FORM FIELD CHECK 2. LENGTH CHECK
function checkLength(oField, min, max, strMsg, blnFocus)
{
	var isValid = false;
	var len_value = oField.value.length;
	
	if (min < 0)
	{
		if (len_value < max)
			isValid = true;
	}
	if (max < 0)
	{
		if (len_value > min)
			isValid = true;
	}
	if (min >= 0 && max >= 0)
	{
		if (len_value >= min && len_value <= max)
			isValid = true;
	}
		
	if (!isValid)
	{
		alert(strMsg);
		if (blnFocus == true)
			oField.focus();
	}
	
	return isValid;
}
// FORM FIELD CHECK 3. LENGTH CHECK (INCLUDE KOREAN)
function checkLengthKor(oField, min, max, strMsg, blnFocus)
{
	var isValid = false;
	var len_value = oField.value.bytes();
	
	if (min < 0)
	{
		if (len_value < max)
			isValid = true;
	}
	if (max < 0)
	{
		if (len_value > min)
			isValid = true;
	}
	if (min >= 0 && max >= 0)
	{
		if (len_value >= min && len_value <= max)
			isValid = true;
	}
		
	if (!isValid)
	{
		alert(strMsg);
		if (blnFocus == true)
			oField.focus();
	}
	
	return isValid;
}

function getCheckedIndex(oField) // for radio button
{
	var index = -1;

	for(i=0; i < oField.length; i++) {
		if(oField[i].checked) {
			index = i;
			break;
		}
	}

	return index;
}

function getCheckedValue(oField) // for radio button
{
	var value = null;

	for(i=0; i < oField.length; i++) {
		if(oField[i].checked) {
			value = oField[i].value;
			break;
		}
	}

	return value;
}

function radioCheck(oField, paramValue) // for radio button
{
	for (var i=0; i<oField.length; i++) {
		if (oField[i].value == paramValue) {
			oField[i].checked = true;
			break;
		}
	}
}

function getSelectedValue(oField) // for select button
{
	var value = null;

	selectedIndex = oField.selectedIndex;

	value = oField[selectedIndex].value;

	return value;
}

function strLenCk(str)
{
  var len = 0;
  for (var i=0;i<str.length; i++) {
    var n = str.charCodeAt(i);
    if ((n>= 0)&&(n<256)) {
      len ++;
    } else {
      len += 2;
	}
  }
  return len;
}
function strLenCnt(str,lengths)	//¹®ÀÚ¿­ÀÇ Æ¯Á¤ ±æÀÌ¸¦ ¹ÝÈ¯ÇÑ´Ù.
{
  var len = 0;
  var newStr = '';
  
  for (var i=0;i<str.length; i++) {
    var n = str.charCodeAt(i);
    var nv = str.charAt(i);
    if ((n>= 0)&&(n<256)) {
      len ++;
    } else {
      len += 2;
	}

	if (len>lengths)
		break;
	else
		newStr = newStr + nv;
  }

  return newStr;
}
function strCutPrint(str,byteLength) {	 //¸î±ÛÀÚ ÀÌ»ó µÇ¸é ..À» ºÙ¿©ÁØ´Ù.
	var strOld = str;
	str = strLenCnt(str,byteLength);
	if (str!=strOld) {
		str = str+'..';
	}
	return str;
}
function strCutPrintT(obj,byteLength) {	 //¸î±ÛÀÚ ÀÌ»ó µÇ¸é ..À» ºÙ¿©ÁØ´Ù. textarea·ÎºÎÅÍ ºÒ·¯¿À±â
	var str = '';
	str = obj.value;
	var strOld = str;
	str = strLenCnt(str,byteLength);
	if (str!=strOld) {
		str = str+'..';
	}
	return str;
}

function hasWrongWord(str, wrongStr)
{
	if(str.indexOf(wrongStr) >= 0) return true;
	else return false;
}
// FORM FIELD CHECK 4. WRONG CHAR CHECK (Æ¯Á¤¹®ÀÚ°¡ Æ÷ÇÔµÇ¾î ÀÖÀ¸¸é false)
function checkWrongWord(oField, wrongStr, strMsg) // for text and textbox
{
	var isWrong = false;
	var fieldType = null;
	var mainField;
	
	if (typeof(oField.type) == 'undefined' && typeof(oField.length) != 'undefined')
		mainField = oField[0];
	else
		mainField = oField;
	fieldType = mainField.type;

	switch (fieldType)
	{
		case "text" :
		case "textarea" :
			isWrong = hasWrongWord(oField.value, wrongStr);
			break;
	}
	
	if (isWrong)
	{
		alert(strMsg);
		array = mainField.value.split(wrongStr);
		result = '';
		for(i=0; i<array.length; i++) {
			result += array[i];
		}
		mainField.value = result;
		mainField.focus();
	}
	
	return !isWrong;
}
// FORM FIELD CHECK 5. ALPHA NUMERIC CHARACTER CHECK (¿µ¹® ¼Ò¹®ÀÚ¿Í ¼ýÀÚ·Î¸¸ µÇ¾î ÀÖÀ¸¸é true)
function checkAlphaNum(oField, strMsg, blnFocus) // for text and textbox
{
	var isAlphaNum = false;
	var fieldType = null;
	var mainField;
	
	if (typeof(oField.type) == 'undefined' && typeof(oField.length) != 'undefined')
		mainField = oField[0];
	else
		mainField = oField;
	fieldType = mainField.type;

	switch (fieldType)
	{
		case "text" :
		case "textarea" :
			isAlphaNum = isLowAlphaNumCheck(oField.value);
			break;
	}
	
	if (!isAlphaNum)
	{
		alert(strMsg);
		if (blnFocus == true)
			mainField.focus();
	}
	
	return isAlphaNum;
}

function isLowAlphaNumCheck(arg_v)
{
	if (arg_v.match(/^[a-z0-9]*$/g)) return true;
	else return false;
}

function isAlphaNumCheck(arg_v)
{
	var alpha_num_Str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

	for (i=0; i < arg_v.length; i++)
	{
		var substr = arg_v.substring(i, i+1);		
		if (alpha_num_Str.indexOf(substr) < 0) 
			return false;	
		
	}
	
	return true;
}

// ¼ýÀÚ Ã¼Å©
function isNumber(arg) {
	for (i =0 ; i < arg.length; i++) {
  	
	  	if (arg.charCodeAt(i) < 48 || arg.charCodeAt(i) > 57) {
	  		return false;
	  	}
	}
	return true;
}
// FORM FIELD CHECK 6. SPECIAL CHARACTER CHECK (Æ¯¼ö¹®ÀÚ ÇÏ³ªµµ ¾ø¾î¾ß true)
function checkNotSpecialChar(oField, strMsg, blnFocus) // for text and textbox
{
	var notSpecialChar = false;
	var fieldType = null;
	var mainField;
	
	if (typeof(oField.type) == 'undefined' && typeof(oField.length) != 'undefined')
		mainField = oField[0];
	else
		mainField = oField;
	fieldType = mainField.type;

	switch (fieldType)
	{
		case "text" :
		case "textarea" :
			notSpecialChar = hasNotSpecialChar(oField.value);
			break;
	}
	
	if (!notSpecialChar)
	{
		alert(strMsg);
		if (blnFocus == true)
			mainField.focus();
	}
	
	return notSpecialChar;
}

// Æ¯¼ö¹®ÀÚ Ã¼Å© (Æ¯¼ö¹®ÀÚ ÇÏ³ªµµ Æ÷ÇÔµÇ¾î ÀÖÁö ¾ÊÀ¸¸é true)
function hasNotSpecialChar(id_text)
{
		//var specialchar = '~`!@#$%^&*()-_=+\|<>?,./;:"';
		var specialchar = '`@#$%&\|<>;"';

		var i ; 
		for ( i=0; i < id_text.length; i++ )  {
			if( specialchar.indexOf(id_text.substring(i,i+1)) > 0) {
				break ; 
			}
		}
		if ( i != id_text.length ) {
			return false ; 
		}
		else{
			return true ;
		} 

		return false;
}

// ÇÑ±Û·Î¸¸ µÇ¾îÀÖ´ÂÁö Ã¼Å© (ÇÑ±Û¿ÜÀÇ ´Ù¸¥ ±ÛÀÚ°¡ ÀÖÀ¸¸é true, ÇÑ±Û·Î¸¸ µÇ¾î ÀÖ¾î¾ß false)
function isNotOnlyKorean(id_text){
	for ( var i=0; i < id_text.length; i++ ) {
		if ( id_text.charCodeAt(i) < 0xAC00 || id_text.charCodeAt(i) > 0xD7A3){
			if (( id_text.charCodeAt(i) < 12593 || id_text.charCodeAt(i) > 12643 ) && ( id_text.charCodeAt(i) != 32)) {
				return true;
			}
		}
	}	
	return false;
}

function keydownEngNum() {			//keydown½Ã¿¡ ¿µ¾î¿Í ¼ýÀÚ¸¸ ¸Ô´Â °Í.
	if (!(event.keyCode>=48&&event.keyCode<=57)&&!(event.keyCode>=65&&event.keyCode<=90)&&event.keyCode!=9&&event.keyCode!=8&&event.keyCode!=46&&event.keyCode!=37&&event.keyCode!=39&&event.keyCode!=45) {
		event.keyCode = 0;
		event.cancelBubble = true;
		event.returnValue = false;
	}
}

function notInMSIE5(functionnm) {		//ºê¶ó¿ìÀú°¡ 5.0ÀÌ¸é ÇÔ¼ö¸¦ È£ÃâÇÏÁö ¾Ê´Â´Ù.
	if (navigator.userAgent.indexOf("MSIE 5")==-1)
	{
		eval(functionnm);
	}
}


function bt(id,after) 
{ 
	eval(id+'.filters.blendTrans.stop();'); 
	eval(id+'.filters.blendTrans.Apply();'); 
	eval(id+'.src="'+after+'";'); 
	eval(id+'.filters.blendTrans.Play();'); 
} 



function resizeImage(num)
{
    var oImg = eval("document.all.userImg" + num);
    
    if (oImg.width > 600)
       oImg.width = 600;
}

function popview(url)
{

	Large_photo(url);

}


function Large_photo(what) { 
var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=0,location=no,menu=no,width=10,height=10'); 
imgwin.focus(); 
imgwin.document.open(); 
imgwin.document.write("<html>\n"); 
imgwin.document.write("<head>\n"); 
imgwin.document.write("<title>µÎ±ÙµÎ±Ù</title>\n"); 

imgwin.document.write("<sc"+"ript>\n"); 
imgwin.document.write("function resize() {\n"); 
imgwin.document.write("pic = document.il;\n"); 
//imgwin.document.write("alert(eval(pic).height);\n"); 
imgwin.document.write("if (eval(pic).height) { var name = navigator.appName\n"); 
imgwin.document.write("  if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 30; myWidth = eval(pic).width + 10;\n"); 
imgwin.document.write("  } else { myHeight = eval(pic).height + 9; myWidth = eval(pic).width; }\n"); 
imgwin.document.write("  clearTimeout();\n"); 
imgwin.document.write("  var height = screen.height;\n"); 
imgwin.document.write("  var width = screen.width;\n"); 
imgwin.document.write("  var leftpos = width / 2 - myWidth / 2;\n"); 
imgwin.document.write("  var toppos = height / 2 - myHeight / 2; \n"); 
imgwin.document.write("  self.moveTo(leftpos, toppos);\n"); 
imgwin.document.write("  self.resizeTo(myWidth, myHeight);\n"); 
imgwin.document.write("}else setTimeOut(resize(), 100);}\n"); 
imgwin.document.write("</sc"+"ript>\n"); 
imgwin.document.write('<META http-equiv="imagetoolbar" content="no"> \n'); 

imgwin.document.write("</head>\n"); 
imgwin.document.write('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF" oncontextmenu = "return false" ondragstart = "return false" onselectstart = "return false">\n'); 

imgwin.document.write("<a href=# onclick=self.close();><img border=0 src='"+what+"' xwidth=100 xheight=9 name=il onload='resize();'></a>\n"); 
imgwin.document.write("</body>\n"); 
imgwin.document.close(); 

} 



<!--

var mvf = false;
var ofx = 0;
var ofy = 0;

function fncInit()
{
    cookiedata = document.cookie;

    if ( cookiedata.indexOf('maindiv=done') < 0 )
        document.all['divpop'].style.visibility = 'visible';
    else
        document.all['divpop'].style.visibility = 'hidden';

    document.onmousemove = fncMove;
}

function setcookie( name, value, expirehours )
{
    var todayDate = new Date();
    todayDate.setHours( todayDate.getHours() + expirehours );
    document.cookie = name + '=' + escape( value ) + '; path=/; expires=' + todayDate.toGMTString() + ';'
}

function closeWin()
{
    if ( document.notice_form.chkbox.checked )
    {
        setcookie( 'maindiv', 'done', 24 );
    }

    document.all['divpop'].style.display = 'none';
}

function fncMVSet( bool )
{
    ofx = event.offsetX;
    ofy = event.offsetY;
    mvf = bool;

    var obj = document.getElementById('divpop');

    if( mvf )
        obj.style.filter = 'Alpha(Opacity=50)';
    else
        obj.style.filter = 'Alpha(Opacity=100)';
}

function fncMove()
{
    if( mvf )
    {
        var obj = document.getElementById('divpop');

        obj.style.top = event.clientY-ofy;;
        obj.style.left= event.clientX-ofx;
    }
}

//-->

