/* ---------------------------------------------------------
    ʱȭ   ̺Ʈ 

    LAST UPDATE : 2009.02.11
    CREATER     : [HG]ErrorDa
    MAIL TO     : hespnk@hanmail.net

    IE7.0 ׽Ʈ  ڵԴϴ.
    ҽڵ忡 Ͽ ߱Դϴ.
     Ͻô   Ϸ ּ.
--------------------------------------------------------- */

var ext;
var clb = false;
var wpCalc = new clsWpCalc;

//---------------------------------------------------------
// :  ̺ ʱȭ 
// :  ɷġ  ǥ   
// : item = ϵ 
//       ext1 = Ưɷ  (2 ŸƲ)
//       ext2 = Ưɷ  (1 ŸƲ)
//       arg  = Ưɷ Ī
// ȯ: -
//---------------------------------------------------------
function fun_DrawTable( item, ext1, ext2, arg)
{
    var nLoop;
    var nWidth

    // ------------------------------------------------------------------------------------------------------------//
    // [ ⺻   ]
    // ------------------------------------------------------------------------------------------------------------//
    ext = ext1 + ext2;
    delete UPNAME;
    delete UPNAME_UNIT;
    INHTML = "";

    switch( idxClass[1] )
    {
        case CON_CLASS_WEAPON :
        case CON_CLASS_WAND   :
        case CON_CLASS_NEWWAND:
        {
            CON_BASEITEM_CNT = 6;
            UPNAME = new Array("ε","Ƶ","뷱","ũ","");
            UPNAME_UNIT = new Array("", "", "%", "%", "");
        }
        break;

        case CON_CLASS_SHIELD :
        case CON_CLASS_CLOTH  :
        case CON_CLASS_LARMOR :
        case CON_CLASS_HARMOR :
        {
            CON_BASEITEM_CNT = 4;
            UPNAME = new Array("", "ȣ", "");
            UPNAME_UNIT = new Array("", "%", "");
        }
        break;
    }

    nWidth = (CON_BASE_WIDTH-200) / (CON_BASEITEM_CNT - 1 + ext);
    // [ ⺻   ]
    // ------------------------------------------------------------------------------------------------------------//


    // ------------------------------------------------------------------------------------------------------------//
    // [  ɷġ   ]
    // ------------------------------------------------------------------------------------------------------------//
    INHTML += ("<div style='z-index:1;' align=right>");
    INHTML += ("<table border=0 width=" + CON_BASE_WIDTH + " style='filter:alpha(opacity=80);'>");
    //INHTML += ("<tr><td class=SPR_LINE colspan=" + (CON_BASEITEM_CNT+ext) + "></td></tr>");
    INHTML += ("<tr align=center " + (ext1 ? ">" : "height=22>"));

    //    ŸƲ  
    INHTML += ("<td class=HEAD_TITLE id='td_title' style='width:200' ");
    INHTML += ("onmouseover='fun_ShowWpDescription(this, 1)' ");
    INHTML += ("onmouseout ='fun_ShowWpDescription(this, 0)' ");
    INHTML += (ext1 ? "rowspan=3>" : ">");
    switch( idxClass[1] )
    {
        // ⺻ɷ Ī 
        case CON_CLASS_WEAPON :
        case CON_CLASS_SHIELD :
        case CON_CLASS_CLOTH  :
        case CON_CLASS_LARMOR :
        case CON_CLASS_HARMOR :
        case CON_CLASS_WAND   :
        case CON_CLASS_NEWWAND:
        {
            //  Ī 
            INHTML += (item.item(0) + "</td>");
        }
        break;
    }
    for(nLoop=0; nLoop<CON_BASEITEM_CNT-1; nLoop++)
    {
        INHTML += ("<td width=" + nWidth + " class=BASE_TITLE " + (ext1 ? "rowspan=3>" : ">") + UPNAME[nLoop]);
        switch( idxClass[1] )
        {
            case CON_CLASS_CLOTH  :
            case CON_CLASS_LARMOR :
            case CON_CLASS_HARMOR :
            {
                // (õ/氩/߰)   
                if( UPNAME[nLoop] == "" )
                {
                   INHTML += ("<a class=EXP_ITEM onclick='fun_DurSetting()' ");
                   INHTML += ("onmouseover='this.style.cursor=\"hand\"'></a>");
                }
            }
            break;
        }
        INHTML += ("</td>");
    }

    // Ưɷ Ī 
    if( ext1 )
    {
        INHTML += ("<td colspan=" + ext1 + " class=BASE_TITLE>" + arg[0] + "</td>");
    }
    if( ext2 )
    {
        for(nLoop = ext1+1; nLoop <= ext; nLoop++)
        {
            INHTML += ("<td width=" + nWidth + " class=BASE_TITLE " + (ext1 ? "rowspan=3>" : ">") + arg[nLoop] + "</td>");
        }
    }
    // Ưɷ 2 ŸƲ 
    if( ext1 )
    {
        INHTML += ("</tr>");
        INHTML += ("<tr><td class=EXT_SPR_LINE colspan=" + ext1 + "></td></tr>");
        INHTML += ("<tr align=center>");
        for(nLoop = 1; nLoop <= ext1; nLoop++)
        {
            INHTML += ("<td width=" + nWidth + " class=BASE_TITLE>" + arg[nLoop] + "</td>");
        }
    }

    INHTML += ("</tr>");
    INHTML += ("<tr><td class=SPR_LINE colspan=" + (CON_BASEITEM_CNT+ext) + "></td></tr>");
    INHTML += ("<tr align=center>");

    //  Ī  ɷġ 
    switch( idxClass[1] )
    {
        case CON_CLASS_WEAPON :
        case CON_CLASS_WAND   :
        case CON_CLASS_NEWWAND:
        {
            INHTML += ("<td height=40 class=BASE_TITLE>" + item.item(10).split(',')[0] + "<br>" + item.item(10).split(',')[1] + "</td>");
        }
        break;

        case CON_CLASS_SHIELD :
        case CON_CLASS_CLOTH  :
        case CON_CLASS_LARMOR :
        case CON_CLASS_HARMOR :
        {
            INHTML += ("<td height=40>" + item.item(8) + "</td>");
        }
        break;
    }
    for(nLoop = 1; nLoop < CON_BASEITEM_CNT; nLoop++)
    {
        INHTML += ("<td id='tbl_itemData_" + nLoop + "' class=NO_SPACE style='padding-top:3'>" + item.item(nLoop) + UPNAME_UNIT[nLoop-1] + "</td>");
    }

    // Ưɷ 
    if( ext1 || ext2 )
    {
        for(nLoop=CON_BASEITEM_CNT; nLoop<CON_BASEITEM_CNT+ext; nLoop++)
        {
            INHTML += ("<td id='tbl_itemData_" + nLoop + "' class=NO_SPACE style='padding-top:3'>" + item.item(nLoop) + "</td>");
        }
    }
    INHTML += ("</tr>");
    INHTML += ("<tr><td class=EXT_SPR_LINE style='margin-bottom:0' colspan=" + (CON_BASEITEM_CNT+ext) + "></td></tr>");

    //    
    INHTML += ("<tr align=center><td class=EXT_ITEM>   </td>");
    INHTML += ("<td colspan=" + (CON_BASEITEM_CNT+ext-1) + " align=left class=EXT_ITEM>");
    var useBrood = "";
    useBrood += (item.useBrood.indexOf("H") > -1 ? "<font color=#0F7bae>ΰ</font>, " : "");
    useBrood += (item.useBrood.indexOf("E") > -1 ? "<font color=#4dae00></font>, " : "");
    useBrood += (item.useBrood.indexOf("G") > -1 ? "<font color=#898940>̾Ʈ</font>, " : "");
    useBrood = useBrood.substr(0, useBrood.length-2);
    INHTML += (useBrood);
    INHTML += ("</td></tr>");
    INHTML += ("<tr><td class=EXT_SPR_LINE style='margin-bottom:0' colspan=" + (CON_BASEITEM_CNT+ext) + "></td></tr>");
    INHTML += ("<tr><td class=SPC_LINE style='margin-bottom:0' colspan=" + (CON_BASEITEM_CNT+ext) + "></td></tr>");
    // [  ɷġ   ]
    // ------------------------------------------------------------------------------------------------------------//


    // ------------------------------------------------------------------------------------------------------------//
    // [  ޺ ɷġ   ]
    // ------------------------------------------------------------------------------------------------------------//
    if( item.useBlss || item.mopDrop || item.normal )
    {
        INHTML += ("<tr align=center style='height:22'>");
        INHTML += ("<td class=HEAD_TITLE> </td>");

        //  Ÿ ö  (Ϲ//)
        INHTML += ("<td style='padding-top:1' colspan=" + (CON_BASEITEM_CNT+ext-1) + " align=left>");
        INHTML += ("<select id='opt_ItemType' onchange='fun_clickItemType(this.value);'>");
        if( item.normal )
        {
            INHTML += ("<option value=1>ϡ</option>");
        }
        if( item.useBlss )
        {
            INHTML += ("<option value=2>ǰ</option>");
        }
        if( item.mopDrop )
        {
            INHTML += ("<option value=3></option>");
        }
        INHTML += ("<option value=4>ա</option>");
        INHTML += ("</select>");
        INHTML += ("</td></tr>");
        INHTML += ("<tr><td class=SPR_LINE colspan=" + (CON_BASEITEM_CNT+ext) + "></td></tr>");

        INHTML += ("<tr height=22 align=center class=EXT_TITLE>");
        INHTML += ("<td >ɷġ </td>");

        // ɷġ Է¶  (⺻ = Ⱥ)
        for(nLoop=1; nLoop<CON_BASEITEM_CNT+ext; nLoop++)
        {
            INHTML += ("<td style='padding-top:1'>");
            INHTML += ("<div id='div_row1_" + nLoop + "' style='visibility:hidden'>");
            INHTML += ("<table border=0 cellpadding=1 cellspacing=0 bgcolor=#a0a0a0><tr><td class=NO_SPACE>");
            INHTML += ("<table border=0 cellpadding=1 cellspacing=1><tr class=NO_SPACE height=18>");
            INHTML += ("<td bgcolor=#c0c0c0 width=10 align=center style='padding-top:1px' ");
            INHTML += ("onmouseover='this.style.background=\"#dddd00\";this.style.cursor=\"hand\";' ");
            INHTML += ("onmouseout ='this.style.background=\"#c0c0c0\"' ");
            INHTML += ("onclick='fun_Calibrate(" + nLoop + ", 1)'>+</td>");
            INHTML += ("<td class=LIGHT_GRAY style='padding-top:1px'>" + UPNAME[nLoop-1] + "</td>");
            INHTML += ("<td bgcolor=#c0c0c0 width=10 align=center style='padding-top:1px' ");
            INHTML += ("onmouseover='this.style.background=\"#dddd00\";this.style.cursor=\"hand\";' ");
            INHTML += ("onmouseout ='this.style.background=\"#c0c0c0\"' ");
            INHTML += ("onclick='fun_Calibrate(" + nLoop + ",-1)'>-</td>");
            INHTML += ("</tr></table>");
            INHTML += ("</td></tr></table>");
            INHTML += ("</div>");
            INHTML += ("</td>");
        }
        INHTML += ("</tr>");
        INHTML += ("<tr><td class=EXT_SPR_LINE colspan=" + (CON_BASEITEM_CNT+ext) + "></td></tr>");
        INHTML += ("<tr align=center height=22><td class=EXT_TITLE align=left style='padding-top:1px' width=200>");

        // Ϲ   ö  (⺻ = )
        if( item.normal )
        {
            INHTML += ("<div id='div_Normal' style='display:;'>");
            INHTML += ("<table border=0 cellpadding=0 cellspacing=0><tr>");
            INHTML += ("<td class=NO_SPACE valign=top>");
            INHTML += ("<select id='opt_Normal' style='width:200;' disabled='true'>");
            INHTML += ("<option value=1>/æƮ </option>");
            INHTML += ("</select>");
            INHTML += ("</td>");
            INHTML += ("</tr></table>");
            INHTML += ("</div>");
        }

        //    ö  (⺻ = Ⱥ)
        // ǥ  ȭ    ̵
        if( item.mopDrop )
        {
            INHTML += ("<div id='div_MonDrop' style='display:none;'>");
            INHTML += ("<table border=0 cellspaing=0><tr>");
            INHTML += ("<td style='padding:0'>");
            INHTML += ("<select id='opt_DropItem' style='width:200;' onchange='fun_SelectItem();'>");
            //  ũ ʽ 
            for(nLoop=0; nLoop< monDropItem.getMbCount(); nLoop++)
            {
              INHTML += ("<option value='" + nLoop + "'>" + monDropItem.getMbNode(nLoop)[0] + "</option>");
            }
            INHTML += ("</select>");
            INHTML += ("</td>");
            INHTML += ("</tr></table>");
            INHTML += ("</div>");
        }

        //    ö  (⺻ = Ⱥ)
        if( item.useBlss )
        {
            INHTML += ("<div id='div_BlssRank' style='display:none;'>");
            INHTML += ("<table border=0 cellpadding=0 cellspacing=0><tr>");
            INHTML += ("<td class=NO_SPACE valign=top>");
            INHTML += ("<select id='opt_BlssRank' style='width:100;' onchange='fun_SelectItem();'>");
            //  ũ ʽ 
            for(nLoop = 0; nLoop < blacksmith.getRkCount(); nLoop++)
            {
                INHTML += ("<option value='" + nLoop + "'>" + blacksmith.getRkNode(nLoop)[0] + "</option>");
            }
            INHTML += ("</td>");
            INHTML += ("<td class=NO_SPACE valign=top>");
            INHTML += ("<select id='opt_BlssItem' style='width:100;' onchange='fun_SelectItem();'>");
            //  ũ ʽ 
            for(nLoop=0; nLoop<blacksmith.getMbCount(); nLoop++)
            {
                INHTML += ("<option value='" + nLoop + "'>" + blacksmith.getMbNode(nLoop)[0] + "&nbsp;</option>");
            }
            INHTML += ("</select></td></tr></table>");
            INHTML += ("</div>");
        }
		
		// ռ (⺻ = Ⱥ)
        INHTML += ("<div id='div_Alchemy' style='display:none;'>");
        INHTML += ("<table border=0 cellpadding=0 cellspacing=0><tr>");
        INHTML += ("<td class=NO_SPACE valign=top>");
        INHTML += ("<select id='opt_Normal' style='width:200;' disabled='true'>");
        INHTML += ("<option value=1>ռ  ɷġ </option>");
        INHTML += ("</select>");
        INHTML += ("</td>");
        INHTML += ("</tr></table>");
        INHTML += ("</div>");


        INHTML += ("</td>");

        //  ɷġ Է¶  (⺻ = )
        for(nLoop=1; nLoop<CON_BASEITEM_CNT+ext; nLoop++)
        {
            INHTML += ("<td style='padding-top:1'>");
            INHTML += ("<div id='div_row2_" + nLoop + "' style='visibility:visible;'>");
            INHTML += ("</div>");
            INHTML += ("</td>");
        }
        INHTML += ("</tr>");
        INHTML += ("<tr><td class=EXT_SPR_LINE colspan=" + (CON_BASEITEM_CNT+ext) + " style='padding-top:0px'></td></tr>");
    }

    // ǥ ö  (⺻ = Ⱥ)
    INHTML += ("<tr><td class=BASE_TITLE style='padding-top:0'>");
    if( item.dropDragon )
    {
        INHTML += ("<div id='div_DrgDrop' style='display:none;'>");
        INHTML += ("<input type=checkbox id='chk_Dragon' onclick='blur();fun_SelectItem();' style='width:14;height:14'><font color=#ff4400> </font>");
        INHTML += ("</div>");
    }
    INHTML += ("</td>");
    INHTML += ("<td class=SPC_LINE colspan=" + (CON_BASEITEM_CNT+ext-1) + "></td>");
    INHTML += ("</tr>");
    // [  ޺ ɷġ   ]
    // ------------------------------------------------------------------------------------------------------------//


    // ------------------------------------------------------------------------------------------------------------//
    // [  ǥ   ]
    // ------------------------------------------------------------------------------------------------------------//
    //INHTML += ("<tr><td class=SPC_LINE colspan=" + (CON_BASEITEM_CNT+ext) + "></td></tr>");

    // ǥ ŸƲ 
    INHTML += ("<tr align=center height=22>");
    INHTML += ("<td class=HEAD_TITLE>ǥ</td>");
    INHTML += ("<td colspan=" + (CON_BASEITEM_CNT+ext-1) + " align=right style='padding-top:0'>");
    INHTML += ("<table border=0 cellpadding=0 cellspacing=0 bordercolor=#000000 bordercolorlight=#ffffff bordercolordark=#ffffff>");
    INHTML += ("<tr align=center>");
    INHTML += ("<td width=60>ʿ</td>");
    INHTML += ("<td width=80 align=left class=EXP_ITEM id='tbl_itemData_" + (CON_BASEITEM_CNT+ext+0) + "'>0</td>");
    INHTML += ("<td width=60></td>");
    INHTML += ("<td width=80 align=left class=GLD_ITEM id='tbl_itemData_" + (CON_BASEITEM_CNT+ext+1) + "'>0G&nbsp;</td>");
    INHTML += ("<td width=" + (CON_BASE_WIDTH-200-480) + "></td>");
    INHTML += ("<td width=100 class=NO_SPACE>");
    INHTML += ("<select id='opt_AutoMethod' onchange='fun_selMethod(this.value)' style='width:100%'>");
    INHTML += ("<option value=-1> </option>");
    for(nLoop=0; nLoop < revampItem.getMethodCount(); nLoop++)
    {
        INHTML += ("<option value=" + nLoop + ">" + revampItem.getMethod(nLoop).name.replace(" ", "&nbsp;") + "</option>");
    }
    INHTML += ("</td>");
    INHTML += ("<td width=1 color=#a0a0a0></td>");
    INHTML += ("<td width=48 class=BTN_COLOR ");
    INHTML += ("onmouseover='this.style.background=\"#dddd00\";this.style.cursor=\"hand\";' ");
    INHTML += ("onmouseout ='this.style.background=\"#c0c0c0\"' ");
    INHTML += ("onclick='fun_Init()'>ʱȭ</td>");
    INHTML += ("<td width=1 color=#a0a0a0></td>");
    INHTML += ("<td width=48 class=BTN_COLOR ");
    INHTML += ("onmouseover='this.style.background=\"#dddd00\";this.style.cursor=\"hand\";' ");
    INHTML += ("onmouseout ='this.style.background=\"#c0c0c0\"' ");
    INHTML += ("onclick='fun_Copy()'></td>");
    INHTML += ("</tr>");
    INHTML += ("</table>");
    INHTML += ("</td>");
    INHTML += ("</tr>");
    INHTML += ("<tr><td class=SPR_LINE colspan=" + (CON_BASEITEM_CNT+ext) + " style='padding-top:0px;'></td></tr>");
    INHTML += ("<tr><td colspan=" + (CON_BASEITEM_CNT+ext) + " style='padding-top:0px;'>");
    INHTML += ("<table border=0 width=" + CON_BASE_WIDTH + " cellspacing=0 cellpadding=0>");
    INHTML += ("<tr align=center class=EXT_ITEM>");
    INHTML += ("<td rowspan=3 width=200>  </td><td rowspan=3 class=COL_LINE></td>");
    INHTML += ("<td rowspan=3 width=" + (CON_BASE_WIDTH-404)+ ">   </td><td rowspan=3 class=COL_LINE></td>");
    INHTML += ("<td rowspan=3 width=50> </td><td rowspan=3 class=COL_LINE></td>");
    INHTML += ("<td rowspan=3 width=50> </td><td rowspan=3 class=COL_LINE></td>");
    INHTML += ("<td colspan=5>  ȸ </td>");
    INHTML += ("</tr><tr><td colspan=5 class=EXT_SPR_LINE></td></tr><tr>");

    //  ȸ 
    for(nLoop = 0; nLoop < 5; nLoop++)
    {
        INHTML += ("<td width=20 style='padding-top:0px' class=EXT_ITEM>");
        INHTML += ("<input type=radio name='rdoSel_" + nLoop + "' ");
        //  ȸ  / 
        INHTML += (parseInt(item.upgradeCnt) > nLoop ? " checked onclick='fun_CalcItem();blur();'>" : " disabled=true>");
        INHTML += ("</td>");
    }
    INHTML += ("</tr>");
    INHTML += ("<tr><td class=SPR_LINE colspan=13></td></tr>");

    // ϵ ǥ 
    fun_DrawDiagram();
    INHTML += ("</table>");
    INHTML += ("</td></tr>");
    // [  ǥ   ]
    // ------------------------------------------------------------------------------------------------------------//

    // ------------------------------------------------------------------------------------------------------------//
    // [  ׷̵   ]
    // ------------------------------------------------------------------------------------------------------------//
    if( item.isGem()  )
    {
        INHTML += ("<tr><td class=SPC_LINE colspan=" + (CON_BASEITEM_CNT+ext) + "></td></tr>");
        // ŸƲ ǥ
        INHTML += ("<tr align=center height=22>");
        INHTML += ("<td class=HEAD_TITLE> ׷̵</td>");
        INHTML += ("<td colspan=" + (CON_BASEITEM_CNT+ext-1) + " align=right style='padding-top:0;' id='tbl_gem'>");
        INHTML += ("</td></tr>");
        // ׸ ǥ
        INHTML += ("<tr><td class=SPR_LINE colspan=" + (CON_BASEITEM_CNT+ext) + " style='padding-top:0px;'></td></tr>");
        INHTML += ("<tr><td colspan=" + (CON_BASEITEM_CNT+ext) + " style='padding-top:0px;'>");
        INHTML += ("<table border=0 width=" + CON_BASE_WIDTH + " cellspacing=0 cellpadding=0>");
        INHTML += ("<tr align=center class=EXT_ITEM>");
        INHTML += ("<td rowspan=3 width=200>  </td><td rowspan=3 class=COL_LINE></td>");
        INHTML += ("<td rowspan=3 width=" + (CON_BASE_WIDTH-404)+ ">   </td><td rowspan=3 class=COL_LINE></td>");
        INHTML += ("<td rowspan=3 width=50> </td><td rowspan=3 class=COL_LINE></td>");
        INHTML += ("<td rowspan=3 width=50> </td><td rowspan=3 class=COL_LINE></td>");
        INHTML += ("<td colspan=5>  ȸ </td>");
        INHTML += ("</tr><tr><td colspan=5 class=EXT_SPR_LINE></td></tr><tr>");

        //  ȸ 
        for(nLoop = 0; nLoop < 5; nLoop++)
        {
            INHTML += ("<td width=20 style='padding-top:0px' class=EXT_ITEM>");
            INHTML += ("<input type=radio name='rdoGem_" + nLoop + "' ");
            //  ȸ  / 
            INHTML += (parseInt(item.getMaxGemUpgrade()) >= nLoop ? " checked onclick='fun_CalcItem();blur();'>" : " disabled=true>");
            INHTML += ("</td>");
        }

        INHTML += ("</tr>");
        INHTML += ("<tr><td class=SPR_LINE colspan=13></td></tr>");

        // ׸ 
        var nGem;
        for(nLoop = 0; nLoop < item.getGemCount(); nLoop++)
        {
            nGem = item.gemUpgrade[nLoop];
            if( nGem > 0 )
            {
            	var nOffset = 0;
            	if(item.classType >= 500 && item.classType < 900)
            	{
            		nOffset = 9;
            	} else {
            		nOffset = 11;
            	}

                INHTML += ("<tr class=BASE_TITLE>");
                //  NPC ̺Ʈ
                INHTML += ("<td onmouseover='fun_StartCapture(this);' ");
                INHTML += ("onmouseout='fun_EndCapture(this);' ");
                INHTML += ("onmousemove='fun_ShowNpcList(\"" + gem[nGem][nOffset+3] + "\");' ");
                INHTML += ("class=BASE_TITLE>");
                INHTML += ("" + gem[nGem][0] + "</td><td class=COL_LINE>");
                INHTML += ("<td onmouseover='fun_ShowGemList(\"" + gem[nGem][nOffset+2] + "\");' ");
                INHTML += ("onmouseout='fun_HideGemList();' ");
                INHTML += ("onmousemove=';'>");
                //  ׷̵  
                for(var nCnt = 1; nCnt < CON_BASEITEM_CNT; nCnt++)
                {
                    if( gem[nGem][nCnt+2] )
                    {
                        INHTML += UPNAME[nCnt-1] + (gem[nGem][nCnt+2] > 0 ? "<font class=POSITIVE>+" : "<font class=NEGATIVE>") + gem[nGem][nCnt+2] + UPNAME_UNIT[nCnt-1] + "</font> ";
                    }
                }
                if( ext )
                {
                	var nOffset2 = nOffset - 3;
                    for(nCnt = 0; nCnt < ext; nCnt++)
                    {
                        if( parseInt(gem[nGem][nCnt+nOffset2]) != 0 )
                        {
                            INHTML += EXT_UPNAME[nCnt];

                            switch( idxClass[1] )
                            {
                            	case CON_CLASS_SHIELD :
                            	{
                            		INHTML += (gem[nGem][nCnt+nOffset2] > 0 ? "<font class=POSITIVE>+" : "<font class=NEGATIVE>") + gem[nGem][nCnt+nOffset2] + EXT_UPNAME_UNIT[nCnt] + "</font>";
                            	} break;

                                case CON_CLASS_WAND   :
                                case CON_CLASS_NEWWAND:
                                {
                                    INHTML += (gem[nGem][nCnt+nOffset2] < 0 ? "<font class=POSITIVE>" : "<font class=NEGATIVE>+") + gem[nGem][nCnt+nOffset2] + EXT_UPNAME_UNIT[nCnt] + "</font>";
                                } break;
                            }
                            INHTML += " ";
                        }
                    }
                }
                INHTML += ("</td><td class=COL_LINE>");
                INHTML += ("<td align=right>" + gem[nGem][nOffset+0] + " &nbsp;</td><td class=COL_LINE>");
                INHTML += ("<td align=right>" + gem[nGem][nOffset+1] + "<font color=#808080>G</font>&nbsp;</td><td class=COL_LINE>");
                for(var nOpt = 0; nOpt < 5; nOpt++)
                {
                    INHTML += ("<td width=20 style='padding-top:0px' class=EXT_ITEM>");
                    INHTML += ("<input type=radio name='rdoGem_" + nOpt + "' ");
                    //  ȸ  / 
                    INHTML += (((parseInt(gem[nGem][1]) >= nOpt) && (parseInt(gem[nGem][2]) <= nOpt)) ? " onclick='fun_CalcItem();blur();'>" : " disabled=true>");
                    INHTML += ("</td>");
                }
                INHTML += ("</tr>");
                INHTML += ("<tr><td class=EXT_SPR_LINE colspan=13></td></tr>");
            }
        }

        INHTML += ("</table>");
        INHTML += ("</td></tr>");
    }
    // [  ׷̵   ]
    // ------------------------------------------------------------------------------------------------------------//

    INHTML += ("</table>");
    INHTML += ("</div>");
}



// --------------------------------------------------------
// ۱  
//
//  ۰  ȵŰ  !! ũ~
// --------------------------------------------------------
function fun_DesignedBy()
{
    var strHTML = "";
    strHTML += ("<table border=0 cellpadding=0 cellspacing=0 style='filter:alpha(opacity=80);' width=100%>");
    strHTML += ("<tr><td class=SPC_LINE colspan=2></td></tr>");
    strHTML += ("<tr><td class=SPR_LINE colspan=2></td></tr>");

    strHTML += ("<tr><td class=BASE_TITLE colspan=2>");
    strHTML += ("̰ Ǵ    ۱ Nexon, devCAT studio ֽϴ.");
    strHTML += ("</td></tr>");
    strHTML += ("<tr><td class=SPR_LINE colspan=2></td></tr>");

    strHTML += ("<tr>");
    strHTML += ("<td class=CPY_LINE>Internet Explorer 7.0</td>");
    strHTML += ("<td class=CPY_LINE align=right>");
    strHTML += ("<font color=#ffaa00>[Mandolin]</font> <font style='font-variant:small-caps;color:#ff4400'>ErrorDa</font> in <font style='font-variant:small-caps;'>HappyGuild</font> &nbsp;");
    strHTML += ("</td></tr>");
    strHTML += ("<tr><td class=SPR_LINE colspan=2></td></tr>");
    strHTML += ("</table>");

    return strHTML;
}


//---------------------------------------------------------
// : ǥ 
// :  ǥ Ѵ.
// : -
// ȯ: -
//---------------------------------------------------------
function fun_DrawDiagram( )
{
    var drm;
    var bView;

    // ϵ  Ѵ.
    for(var nLoop=0; nLoop < revampItem.revamps.length; nLoop++)
    {
        drm = revampItem.getRevamp(nLoop);
        INHTML += ("<tr class=BASE_TITLE>");
        //  NPC   ̺Ʈ 
        INHTML += ("<td onmouseover='fun_StartCapture(this);' ");
        INHTML += ("onmouseout='fun_EndCapture(this);' ");
        INHTML += ("onmousemove='fun_ShowNpcList(\"" + drm.who + "\");' ");
        INHTML += ("class=BASE_TITLE>");
        //  
        INHTML += ("" + drm.name + "</td><td class=COL_LINE></td>");
        //  
        INHTML += ("<td>" + fun_GetContents(drm) + "</td><td class=COL_LINE></td>");
        // ʿġ 
        INHTML += ("<td align=right>" + drm.Exp()  + " &nbsp;</td><td class=COL_LINE></td>");
        //  
        INHTML += ("<td align=right>" + drm.Gold() + "<font color=#808080>G&nbsp;</font></td><td class=COL_LINE></td>");
        // ȸ  / 
        for(var nOpt=0; nOpt < 5; nOpt++)
        {
            bView = ((drm.start <= nOpt) && (drm.last >= nOpt) ? true : false);
            INHTML += ("<td style='padding-top:0px;' class=EXT_ITEM>");
            INHTML += ("<input type=radio name='rdoSel_" + nOpt + (bView ? "' onclick='fun_CalcItem();blur();'" : "' disabled=true") + ">");
            INHTML += ("</td>");
        }
        INHTML += ("</tr>");
        INHTML += ("<tr><td class=EXT_SPR_LINE colspan=13></td></tr>");
    }

    var nLine = revampItem.revamps.length;
    if( ext ) nLine++;
    if( nLine < 12 && !revampItem.isGem() )
    {
        for(nLoop=0; nLoop<12-nLine; nLoop++)
        {
            INHTML += ("<tr><td height=22 colspan=13></td></tr>");
        }
    }
    return;
}



//---------------------------------------------------------
// : ǥ  
// : ǥ    .
// : item =  ü
// ȯ: str =  
//---------------------------------------------------------
function fun_GetContents( item )
{
    var str = "";

    switch( idxClass[1] )
    {
        // ,
        case CON_CLASS_WEAPON :
        case CON_CLASS_SHIELD :
        case CON_CLASS_CLOTH  :
        case CON_CLASS_LARMOR :
        case CON_CLASS_HARMOR :
        case CON_CLASS_WAND   :
        case CON_CLASS_NEWWAND:
        {
            for(var nLoop = 1; nLoop < CON_BASEITEM_CNT; nLoop++)
            {
                if( item.Stat(nLoop) )
                {
                    str += UPNAME[nLoop-1] + (item.Stat(nLoop) > 0 ?  "<font class=POSITIVE>+" : "<font class=NEGATIVE>") + item.Stat(nLoop) + UPNAME_UNIT[nLoop-1] +"</font> ";
                }
            }

            switch( parseInt(idxClass[0] / 100) )
            {
                // Ѽ, õ
                case 1 :
                case 6 : break;

                // 
                case 2 :
                {
                    for(nLoop=0; nLoop<ext; nLoop++)
                    {
                        if( item.Stat(nLoop+CON_BASEITEM_CNT) )
                        {
                            str += EXT_UPNAME[nLoop];
                        }
                    }
                }
                break;

                // Ÿ, 
                case 4 :
                case 5 :
                {
                    for(nLoop=0; nLoop<ext; nLoop++)
                    {
                        if( item.Stat(nLoop+CON_BASEITEM_CNT) )
                        {
                            str += EXT_UPNAME[nLoop] + (item.Stat(nLoop+CON_BASEITEM_CNT) > 0 ? "<font class=POSITIVE>+" : "<font class=NEGATIVE>") + item.Stat(nLoop+CON_BASEITEM_CNT) + EXT_UPNAME_UNIT[nLoop] + "</font> ";
                        }
                    }
                }
                break;

                // 
                case 9 :
                {
                    for(nLoop=0; nLoop<ext; nLoop++)
                    {
                        if( item.Stat(nLoop+CON_BASEITEM_CNT) )
                        {
                            if( idxClass[1] == CON_CLASS_WAND )
                            {
                                if( nLoop < 2 )
                                {
                                    str += EXT_UPNAME[nLoop] + (item.Stat(nLoop+CON_BASEITEM_CNT) > 0 ? "<font class=NEGATIVE>+" : "<font class=POSITIVE>") + item.Stat(nLoop+CON_BASEITEM_CNT) + EXT_UPNAME_UNIT[nLoop] + "</font> ";
                                }
                                else
                                {
                                    str += EXT_UPNAME[nLoop] + (item.Stat(nLoop+CON_BASEITEM_CNT) > 0 ? "<font class=POSITIVE>+" : "<font class=NEGATIVE>") + item.Stat(nLoop+CON_BASEITEM_CNT) + EXT_UPNAME_UNIT[nLoop] + "</font> ";
                                }
                            }
                            else    // ſ
                            {
                                if( nLoop == 0 )
                                {
                                    str += EXT_UPNAME[nLoop] + (item.Stat(nLoop+CON_BASEITEM_CNT) > 0 ? "<font class=NEGATIVE>+" : "<font class=POSITIVE>") + item.Stat(nLoop+CON_BASEITEM_CNT) + EXT_UPNAME_UNIT[nLoop] + "</font> ";
                                }
                                else
                                {
                                    str += EXT_UPNAME[nLoop] + (item.Stat(nLoop+CON_BASEITEM_CNT) > 0 ? "<font class=POSITIVE>+" : "<font class=NEGATIVE>") + item.Stat(nLoop+CON_BASEITEM_CNT) + EXT_UPNAME_UNIT[nLoop] + "</font> ";
                                }
                            }
                        }
                    }
                }
                break;

                // ä
                case 3 :
                {
                    for(nLoop=0; nLoop<ext; nLoop++)
                    {
                        if( item.Stat(nLoop+CON_BASEITEM_CNT) > 0 )
                        {
                            if( idxClass[0] == 302 && nLoop == 1 )
                            {
                                if( item.Stat(nLoop+CON_BASEITEM_CNT) == 1 ) str += "<font class=POSITIVE>" + EXT_UPNAME_UNIT[nLoop] + "</font>" + EXT_UPNAME[nLoop] + " ";
                                if( item.Stat(nLoop+CON_BASEITEM_CNT) == 2 ) str += "<font class=POSITIVE>" + EXT_UPNAME_UNIT[nLoop] + "</font>" + EXT_UPNAME[nLoop] + " ";
                                if( item.Stat(nLoop+CON_BASEITEM_CNT) == 3 ) str += "<font class=POSITIVE>" + EXT_UPNAME_UNIT[nLoop] + "</font>" + EXT_UPNAME[nLoop] + " ";
                            }
                            else
                            {
                                str += EXT_UPNAME[nLoop] + " ";// + "<font class=POSITIVE>+" + item.Stat(nLoop+CON_BASEITEM_CNT) + EXT_UPNAME_UNIT[nLoop] + "</font> ";
                            }
                        }
                        else if( item.Stat(nLoop+CON_BASEITEM_CNT) < 0 )
                        {
                            str += EXT_UPNAME[nLoop] + "<font class=NEGATIVE>" + item.Stat(nLoop+CON_BASEITEM_CNT) + EXT_UPNAME_UNIT[nLoop] + "</font> ";
                        }
                    }
                }
                break;
            }
        }
        break;
    }

    return str;
}



//---------------------------------------------------------
// :  ɷġ ʱȭ
// :  ޿  ⺻  ɷ ʱȭ
// : type = Ϲ// 
// ȯ: -
//---------------------------------------------------------
function fun_clickItemType( type )
{
    // ̽ ʱȭ
    if( revampItem.useBlss ) {
        opt_BlssRank.value = 0;
        opt_BlssItem.value = 0;
    }
    if( revampItem.mopDrop ) {
        opt_DropItem.value = 0;
        if( revampItem.dropDragon ) {
            chk_Dragon.checked = false;
        }
    }

    clb = false;
    delete itemExtend;
    itemExtend = new Array();

    if( type == 0 ) {
        type = opt_ItemType.value;
    }

    // ŸԿ  ɷġ    Է¶ 
    switch( parseInt(type) ) {  
    	// Ϲ
        case 1: {
            div_Normal.style.display = "";
            if( revampItem.useBlss    ) div_BlssRank.style.display = "none";
            if( revampItem.dropDragon ) div_DrgDrop.style.display = "none";
            if( revampItem.mopDrop    ) div_MonDrop.style.display = "none";
            div_Alchemy.style.display = "none";
            CopyData( normalItem.getMbNode(0), itemExtend );
        } break;
        // 
        case 2: {
            div_BlssRank.style.display = "";
            if( revampItem.normal     ) div_Normal.style.display = "none";
            if( revampItem.dropDragon ) div_DrgDrop.style.display = "none";
            if( revampItem.mopDrop    ) div_MonDrop.style.display = "none";
            div_Alchemy.style.display = "none";
            CopyData( blacksmith.getMbNode(0), itemExtend );
        } break;
        // 
        case 3: {
            div_MonDrop.style.display = "";
            if( revampItem.dropDragon ) div_DrgDrop.style.display = "";
            if( revampItem.normal     ) div_Normal.style.display = "none";
            if( revampItem.useBlss    ) div_BlssRank.style.display = "none";
            div_Alchemy.style.display = "none";
            CopyData( monDropItem.getMbNode(0), itemExtend );
        } break;
        // ռ
        case 4: {
            div_Alchemy.style.display = "";
            if( revampItem.normal     ) div_Normal.style.display = "none";
            if( revampItem.useBlss    ) div_BlssRank.style.display = "none";
            if( revampItem.dropDragon ) div_DrgDrop.style.display = "none";
            if( revampItem.mopDrop    ) div_MonDrop.style.display = "none";
            CopyData( normalItem.getMbNode(0), itemExtend );
        } break;
    }

    // Ϲݰ   ġ Է п   
    for(var nLoop=1; nLoop <= CON_BASEITEM_CNT-1; nLoop++) {
        var cell = eval("div_row1_" + nLoop);
        if( type != 3 && type != 4 ) {
            cell.style.visibility = (( nLoop == CON_BASEITEM_CNT-1) ? "visible" : "hidden");
        }
        else {
            cell.style.visibility = "visible";
        }
    }

    //   ɷġ 
    fun_DrawItemExtend();

    //   ɷġ 
    fun_CalcItem();
}



//---------------------------------------------------------
// :  ɷ ġ 
// : ġ Է̳ Ϲ  /  
//         ÿ   ɷġ   Ѵ.
// : -
// ȯ: -
//---------------------------------------------------------
function fun_DrawItemExtend()
{
    var cell;
    var str;
    var itemType = opt_ItemType.value;

    for(var nLoop=1; nLoop <= CON_BASEITEM_CNT-1; nLoop++)
    {
        cell = eval("div_row2_" + nLoop);
        if( itemType == 1 )
        {
            str = (( nLoop == CON_BASEITEM_CNT-1) ? itemExtend[nLoop] : "");
        }
        else
        {
            str = itemExtend[nLoop];
        }

        if( str != "" && str != "0" )
        {
            if( parseInt(str) > 0 )
            {
                str = "<font class=POSITIVE>+" + str + "</font>";
            }
            else
            {
                str = "<font class=NEGATIVE>" + str + "</font>";
            }
        }
        cell.innerHTML = str;
    }
}



//---------------------------------------------------------
// : ġ /
// : ڿ  Էµ ġ 
// : index =  ɷ ε
//       val   = 
// ȯ: -
//---------------------------------------------------------
function fun_Calibrate( index, val )
{
    clb = true;

    if( revampItem.item(index) + itemExtend[index] + val < 0 )
    {
        alert(UPNAME[index-1] + " ġ 0" + UPNAME_UNIT[index-1] + " Ϸ   ϴ.");
        return;
    }
    itemExtend[index] += val;
    fun_DrawItemExtend();

    fun_CalcItem();
}



//---------------------------------------------------------
// : 콺 ̵  
// :  ǥ  Ŀ ġ   
//        NPC ϶ ̵ Ѵ.
// : obj = ǥ ̺  <TD>
// ȯ: -
//---------------------------------------------------------
function fun_StartCapture( obj )
{
    obj.style.cursor = "help";

    obj.setCapture();
    div_NpcList.style.visibility = "visible";
}



//---------------------------------------------------------
// : 콺 ̵  
// :  ǥ  Ŀ    
//        NPC ϶ ⵵ Ѵ.
// : obj = ǥ ̺  <TD>
// ȯ: -
//---------------------------------------------------------
function fun_EndCapture( obj )
{
    div_NpcList .style.visibility = "hidden";
    obj.releaseCapture();
}



//---------------------------------------------------------
// :   
// : õ/氩/߰ õ  Ѵ.
// : -
// ȯ: -
//---------------------------------------------------------
function fun_ResetDur( val )
{
    if( val < 0 )
    {
        return;
    }

    div_DrChoice.style.visibility = "hidden";
    revampItem.durability = val;

    fun_CalcItem();
}



//---------------------------------------------------------
// :   
// : õ/氩/߰  ø ش.
// : -
// ȯ: -
//---------------------------------------------------------
function fun_DurSetting()
{
    var MAX_COLS = 3; // 3 
    var str = "";
    var durList;

    //     
    if( idxClass[0] == 601 )        /* õ */
    {
        durList = Array( 5, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 25 );
    }
    else if( idxClass[0] == 701 )   /* 氩 */
    {
        durList = Array( 8, 12, 14, 15, 16, 19, 20, 27, 30, 32, 35 );
    }
    else if( idxClass[0] == 801 )   /* ߰ */
    {
        durList = Array( 14, 15, 17, 18, 20, 22, 28, 40, 45 );
    }

    // Ŭ  ü Ʒ ġϵ...
    var elmt = event.srcElement.offsetParent;
    var rect = elmt.getBoundingClientRect();

    div_DrChoice.style.pixelTop  = rect.top - 2 + elmt.clientHeight;
    div_DrChoice.style.pixelLeft = (event.x + 90 > 900) ? 900 : event.x;

    //   
    str += "<table border=1 bordercolor=#000000 cellspacing=0 cellpadding=0>";
    str += "<tr><td colspan=" + MAX_COLS + " align=right class=HEAD_TITLE>";
    str += "<a class=HEAD_TITLE onmouseover='this.style.cursor=\"hand\"' ";
    str += "onclick='div_DrChoice.style.visibility=\"hidden\"'></a>&nbsp;</td></tr>";
    for(var nLoop=0; nLoop<durList.length; nLoop++)
    {
        if( nLoop % MAX_COLS == 0 )
        {
            str += "<tr align=right>";
        }
        str += "<td width=30 bordercolor=#a0a0a0 " + (nLoop % 2 == 1 ? "bgcolor=#c0c0c0 " : "bgcolor=#d0d0d0 ") + "style='color:gray' ";
        str += "onmouseover='this.style.cursor=\"hand\";this.style.color=\"505050\";this.style.fontWeight=\"bold\"' ";
        str += "onmouseout='this.style.color=\"gray\";this.style.fontWeight=\"\"' onclick='fun_ResetDur(" + durList[nLoop] + ")'>";
        str += durList[nLoop] + "&nbsp;</td>";

        if( nLoop % MAX_COLS == (MAX_COLS-1) )
        {
            str += "</tr>";
        }
    }
    //  
    if( durList.length % MAX_COLS )
    {
        str += "<td colspan=" + (MAX_COLS - (durList.length % MAX_COLS)) + " bgcolor=#d0d0d0></td></tr>";
    }
    str += "</table>";

    div_DrChoice.innerHTML = str;
    div_DrChoice.style.visibility = "visible";
}


function fun_ShowGemList( gem )
{
	tbl_gem.innerHTML = gem;
}

function fun_HideGemList()
{
	tbl_gem.innerHTML = "";
}

//---------------------------------------------------------
// :  NPC  
// :  ǥ  Ŀ ġ 
//       Ŀ ġ   NPC  ش.
// : who = NPC  (,NPC,[],[NPC],)
// ȯ: -
//---------------------------------------------------------
function fun_ShowNpcList( who )
{
    // 콺 Ŀ ġ
    var x = event.x;
    var y = event.y + document.body.scrollTop;
    var str;

    //  µ ġ 
    div_NpcList.style.pixelTop  = y + 5;
    div_NpcList.style.pixelLeft = x + 5;

    if( who )
    {
        var npcList = who.split(",");
        // NPC   
        str  = "<table border=0 cellpadding=1 bgcolor=#000000><tr><td>";
        str += "<table border=0 bgcolor=#ffffff width=200>";
        str += "<tr><td bgcolor=#7799cc align=center style='padding:1;' class=HEAD_TITLE colspan=3> NPC</td></tr>";
        for(var nLoop = 0; nLoop < npcList.length; nLoop+=2)
        {
            str += "<tr class=BASE_TITLE><td class=LIGHT_GRAY width=70>&nbsp;" + npcList[nLoop] + "</td>";
            str += "<td width=1 class=NO_SPACE bgcolor=#c0c0c0></td>";
            str += "<td width=130>&nbsp;" + npcList[nLoop+1] + "</td></tr>";
            if( (nLoop/2) < (npcList.length/2-1) )
            {
                str+="<tr class=COL_LINE><td colspan=3></td></tr>";
            }
        }
        str += "</table></td></tr></table>";
        div_NpcList.innerHTML  = str;
    }
    else
    {
        div_NpcList.visibility = "hidden";
    }
}



//---------------------------------------------------------
// :  ǥ
// : ȣ ü   ǥѴ.
// : obj = ȣ ü
//       sel = ON/OFF ɼ
// ȯ: -
//---------------------------------------------------------
function fun_ShowWpDescription( obj, sel )
{
    // ȣ ü ġ 
    var rect = obj.getBoundingClientRect();

    if( sel )
    {
        obj.style.cursor = "help";
        var repairs = revampItem.repair.split(",");
        var str = "";

        //  ġ  (ȣⰴü ٷ )
        div_WpDesc.style.left = rect.left - 2;
        div_WpDesc.style.top  = rect.top  - 2 + obj.clientHeight;

        str += "<table border=0 bgcolor=#000000><tr><td style='padding-top:1'>";
        str += "<table border=0 bgcolor=#ffffff width=" + (obj.clientWidth-2) + " class=NO_SPACE>";
        //  ̹ 
        if( revampItem.linkImage != "" )
        {
            str += "<tr><td align=center bgcolor=white colspan=3 style='padding-top:10;padding-bottom:10;'>";
            str += "<img src='" + IMG_WEAPON_PATH + revampItem.linkImage + "'/></td></tr>";
        }

        //   ִ ȸ
        if( revampItem.repair.indexOf(",") >= 0 )
        {
            str += "<tr class=SPR_LINE><td colspan=3></td></tr>";

            //  
            str += "<tr><td align=center style='padding:3' class=EXT_ITEM colspan=3> </td></tr>";
            str += "<tr class=SPR_LINE><td colspan=3></td></tr>";
            for(var nLoop=0; nLoop<repairs.length; nLoop++)
            {
                str += "<tr class=BASE_TITLE><td class=LIGHT_GRAY align=center>" + repairs[nLoop].split(":")[0] + " 1 Point</td>";
                str += "<td width=1 class=NO_SPACE bgcolor=#c0c0c0></td>";
                str += "<td align=right>" + repairs[nLoop].split(":")[1] + "&nbsp;&nbsp;</td></tr>";
                //  
                if( nLoop < parseInt(repairs.length-1) )
                {
                    str += "<tr class=COL_LINE><td colspan=3></td></tr>";
                }
            }
        }
        str += "</table></td></tr></table>";

        div_WpDesc.innerHTML = str;
        div_WpDesc.style.visibility = "visible";

        // ̾ Z-Order ֻ ø
        fnSetFrameBack("div_WpDesc");
    }
    else
    {
        div_WpDesc.style.visibility = "hidden";
        // ֻ ̾ 
        fnResetFrameBack();
    }
}



//---------------------------------------------------------
// :   û 
// : ڷũ,۵,ӿ 
// : -
// ȯ: -
//---------------------------------------------------------
function fun_SelectItem()
{
    var itemClass = parseInt(opt_ItemType.value);

    clb = false;
    delete itemExtend;
    itemExtend = new Array();

    switch( itemClass )
    {
        // Ϲ
        case 1: break;

        // ǰ
        case 2:
        {
            //  ũ
            var rkIndex = parseInt(opt_BlssRank.value);
            // ǰ 
            var mbIndex = parseInt(opt_BlssItem.value);

            CopyData( blacksmith.getMbNode(mbIndex), itemExtend );
            for(var nLoop=1; nLoop <= CON_BASEITEM_CNT-1; nLoop++)
            {
                itemExtend[nLoop] += blacksmith.getRkNode(rkIndex)[nLoop];
            }
        }
        break;

        // 
        case 3:
        {
            var drIndex = parseInt(opt_DropItem.value);

            CopyData( monDropItem.getMbNode(drIndex), itemExtend );
            if( revampItem.dropDragon && chk_Dragon.checked )
            {
                itemExtend[CON_BASEITEM_CNT-1] += (revampItem.dTemDur - revampItem.durability);
            }
        }
        break;
    }

    //   ɷġ 
    fun_DrawItemExtend();

    //   ɷġ 
    fun_CalcItem();

}



//---------------------------------------------------------
// :   
// :  û ݿϿ ɷġ ջѴ.
// : -
// ȯ: -
//---------------------------------------------------------
function fun_CalcItem()
{
    var rvp;

    delete wpCalc;
    wpCalc = new clsWpCalc;

    for(var i=1; i<CON_BASEITEM_CNT+ext; i++)
    {
        wpCalc.data[i] = revampItem.item(i);
    }
    wpCalc.AddData(itemExtend);

    // Ϲ  
    if( revampItem.getRvCount() )
    {
        for(var nLoop=0; nLoop < revampItem.upgradeCnt; nLoop++)
        {
            if( eval("rdoSel_" + nLoop)[0].checked )
            {
                continue;
            }

            for(var nSel=1; nSel <= revampItem.getRvCount(); nSel++)
            {
                if( eval("rdoSel_" + nLoop)[nSel].checked )
                {
                    rvp = revampItem.getRevamp(nSel-1);
                    wpCalc.AddData( rvp.article );
                    break;
                }
            }
        }
    }

    //   
    if( revampItem.isGem() )
    {
        for(var nLoop=0; nLoop <= revampItem.getMaxGemUpgrade(); nLoop++)
        {
            for(var nSel=1; nSel <= revampItem.getGemCount(); nSel++)
            {
                if( eval("rdoGem_" + nLoop)[nSel].checked )
                {
                    for(var nPos=0; nPos<10; nPos++)
                    {
                        wpCalc.data[1+nPos] += gem[revampItem.gemUpgrade[nSel-1]][3+nPos];

                        if( wpCalc.data[1+nPos] < 0 && (parseInt(revampItem.classType / 100) != 9) )
                        {
                            wpCalc.data[1+nPos] = 0;
                        }
                    }
                }
            }
        }
    }

    fun_DrawFinal();
}



//---------------------------------------------------------
// :  ڵ
// : ϵ  ý ڵ 
// : val = õ  ε
// ȯ: -
//---------------------------------------------------------
function fun_selMethod( val )
{
    var bFind = false;
    var met;
    var rdoSel;
    var mpos;

    if( revampItem.getMethod(val) != null )
    {
        bFind  = true;
        met = revampItem.getMethod(val);
    }

    for(var nLoop=0; nLoop < revampItem.upgradeCnt; nLoop++)
    {
        if( bFind )
        {
            mpos = met.sequence[nLoop] + 1;
            rdoSel = eval("rdoSel_" + nLoop)[mpos];
        }
        else
        {
            rdoSel = eval("rdoSel_" + nLoop)[0]
        }
        rdoSel.checked = true;
    }

    fun_CalcItem();
}



//---------------------------------------------------------
// :   
// :   Ѵ.
// : -
// ȯ: -
//---------------------------------------------------------
function fun_DrawFinal()
{
    var rst1;
    var rst2;
    var str;

    for(var nLoop=1; nLoop < CON_BASEITEM_CNT; nLoop++)
    {
        //  ǥ
        rst1 = wpCalc.data[nLoop];
        rst2 = rst1 - (itemExtend[nLoop] + revampItem.item(nLoop));
        str = rst1 + UPNAME_UNIT[nLoop-1] + "<br>";

        //  ǥ
        if( rst1 != revampItem.item[nLoop] && rst2 )
        {
            str += (rst2 > 0 ? "(<font class=POSITIVE>+" : "(<font class=NEGATIVE>") + rst2 + UPNAME_UNIT[nLoop-1] + "</font>)";
        }
        eval("tbl_itemData_" + nLoop).innerHTML = str;
    }

    // Ȯ ɷġ ǥ
    for(nLoop=CON_BASEITEM_CNT; nLoop<CON_BASEITEM_CNT+ext; nLoop++)
    {
        rst1 = wpCalc.data[nLoop];
        rst2 = rst1 - (itemExtend[nLoop] + revampItem.item(nLoop));

        if( rst1 != rst2 )
        {
            str = rst1 + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT];
            if( rst2 )
            {
                str += "<br>(<font class=" + ( rst2 > 0 ? "POSITIVE>+" : "NEGATIVE>") + rst2 + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + "</font>) ";
            }
        }
        else if( rst1 == rst2 && rst1 )
        {
            if( idxClass[0] == 302 && nLoop == CON_BASEITEM_CNT + 1 )
            {
                if( rst1 == 1 ) str = "<font class=POSITIVE>" + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + "</font> ";
                if( rst1 == 2 ) str = "<font class=POSITIVE>" + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + "</font> ";
                if( rst1 == 3 ) str = "<font class=POSITIVE>" + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + "</font> ";
            }
            else if( parseInt(idxClass[0]/100) == 2 || parseInt(idxClass[0]/100) == 3 )
            {
                str = "<font class=POSITIVE>" + rst1 + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + "</font> ";
            }
            else if( parseInt(idxClass[0]/100) == 9 &&
                    ( ((nLoop <= CON_BASEITEM_CNT+1) && idxClass[1] == CON_CLASS_WAND) ||
                      ((nLoop == CON_BASEITEM_CNT  ) && idxClass[1] == CON_CLASS_NEWWAND) ))
            {
                str = "<font class=" + ( rst1 > 0 ? "NEGATIVE>+" : "POSITIVE>") + rst1 + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + "</font> ";
            }
            else
            {
                str = "<font class=" + ( rst1 > 0 ? "POSITIVE>+" : "NEGATIVE>") + rst1 + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + "</font> ";
            }
        }
        else
        {
            if( parseInt(idxClass[0]/100)==4 )
            {
                str = rst1 + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT];
            }
            else
            {
                str = "-";
            }
        }

        eval("tbl_itemData_" + (nLoop)).innerHTML = str;
    }

    // ʿ, Ѱ
    eval("tbl_itemData_" + (CON_BASEITEM_CNT+ext+0)).innerHTML = (isNaN(wpCalc.data[CON_BASEITEM_CNT+3]) ? "0" : wpCalc.data[CON_BASEITEM_CNT+3]);
    eval("tbl_itemData_" + (CON_BASEITEM_CNT+ext+1)).innerHTML = (isNaN(wpCalc.data[CON_BASEITEM_CNT+4]) ? "0": wpCalc.data[CON_BASEITEM_CNT+4]) + "<span style='color:#505050;font-weight:normal'> Gold</span>";
}



//---------------------------------------------------------
// :  ʱȭ
// : ȸ  
// : -
// ȯ: -
//---------------------------------------------------------
function fun_Init()
{
    for(var nLoop=0; nLoop < revampItem.upgradeCnt; nLoop++)
    {
        eval("rdoSel_" + nLoop)[0].checked = true;
    }

    if( revampItem.isGem() )
    {
        eval("rdoGem_0")[0].checked = true;
    }
    fun_CalcItem();
}



//---------------------------------------------------------
// :  
// :   Ŭ忡 
// : -
// ȯ: -
//---------------------------------------------------------
function fun_Copy()
{
    var strClip = "";

    //  
    strClip += "[" + revampItem.item(0) + "] ";
    if( opt_ItemType.value == 1 )
    {
        strClip += "";
    }
    else if( opt_ItemType.value == 2 )
    {
        // ǰ  ũ  
        if( opt_BlssRank.value == 0 )
        {
            strClip += " ";
        }
        else
        {
            strClip += blacksmith.getRkNode(opt_BlssRank.value)[0] + " ";
        }

        strClip += blacksmith.getMbNode(opt_BlssItem.value)[0] + " ";
    }
    else
    {
        //    
        if( revampItem.dropDragon && chk_Dragon )
        {
            strClip += " ";
        }
        else
        {
            strClip += " ";
        }

        strClip += monDropItem.getMbNode(opt_DropItem.value)[0] + " ";
    }

    //  
    if( clb )
    {
        strClip += "() ";
    }

    // õ
    strClip += (isNaN(wpCalc.data[CON_BASEITEM_CNT+3]) ? "0" : wpCalc.data[CON_BASEITEM_CNT+3]) + " ";

    // 
    for(var nLoop=0; nLoop<revampItem.upgradeCnt; nLoop++)
    {
        if( ! eval("rdoSel_" + nLoop)[0].checked )
        {
            // strClip += revampItem.getRevamp(eval("rdoSel_" + nLoop).selectedIndex).name;
            for(var nOpt=1; nOpt<=revampItem.getRvCount(); nOpt++)
            {
                if( eval("rdoSel_" + nLoop)[nOpt].checked )
                {
                    strClip += revampItem.getRevamp(nOpt-1).name;
                    break;
                }
            }
        }
        if( nLoop < revampItem.upgradeCnt-1 ) strClip += ">";
    }
    if( revampItem.isGem() )
    {
        if( ! eval("rdoGem_0")[0].checked )
        {
            for(var nOpt=1; nOpt<=2; nOpt++)
            {
                if( eval("rdoGem_0")[nOpt].checked )
                {
                    strClip += ">" + gem[revampItem.gemUpgrade[nOpt-1]][0];
                }
            }
        }
    }

    strClip += " ";

    //  ɷġ
    for(nLoop=1; nLoop < CON_BASEITEM_CNT; nLoop++)
    {
        strClip += UPNAME[nLoop-1] + ":" + wpCalc.data[nLoop] + UPNAME_UNIT[nLoop-1] + " ";
    }
    for(nLoop=CON_BASEITEM_CNT; nLoop<CON_BASEITEM_CNT+ext; nLoop++)
    {
        //  ó
        if( idxClass[0] == 302 && nLoop == CON_BASEITEM_CNT+1)
        {
            if( wpCalc.data[nLoop] == 1 ) strClip += EXT_UPNAME[nLoop-CON_BASEITEM_CNT] + ":" + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + " ";
            if( wpCalc.data[nLoop] == 2 ) strClip += EXT_UPNAME[nLoop-CON_BASEITEM_CNT] + ":" + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + " ";
            if( wpCalc.data[nLoop] == 3 ) strClip += EXT_UPNAME[nLoop-CON_BASEITEM_CNT] + ":" + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + " ";
        }
        else
        {
            if( wpCalc.data[nLoop] )
            {
                strClip += EXT_UPNAME[nLoop-CON_BASEITEM_CNT] + ":";
                switch( idxClass[1] )
                {
                    case CON_CLASS_WEAPON :
                    {
                        if( parseInt(idxClass[0]/100) == 4 ||
                            parseInt(idxClass[0]/100) == 3 ||
                            parseInt(idxClass[0]/100) == 2 )
                        {
                            break;
                        }
                    }

                    default :
                    {
                        if( wpCalc.data[nLoop] > 0 )
                        {
                            strClip += "+";
                        }
                    }
                    break;
                }
                strClip += wpCalc.data[nLoop] + EXT_UPNAME_UNIT[nLoop-CON_BASEITEM_CNT] + " ";
            }
        }
    }
    // 
    strClip += ":" + (isNaN(wpCalc.data[CON_BASEITEM_CNT+4]) ? "0": wpCalc.data[CON_BASEITEM_CNT+4]) + "G";

    window.clipboardData.setData("Text", strClip);
    alert("Ŭ忡  Ǿϴ.\n\tCtrl+VŰ ٿֱ⸦ Ͻ  ֽϴ.");
}



//---------------------------------------------------------
// :   ε
// : ⰳ ʱȭ 
// : type =     (ex. 101 = εҵ  )
//       clss =     (0=/1=/2=)
//       obj  =  µ ü
// ȯ: -
//---------------------------------------------------------
function JS_LoadItem( type, clss, obj )
{
    idxClass[0] = type;
    idxClass[1] = clss;

    window.fontSmoothingEnabled = true;

    //   ε
    fun_LoadData();

    //    HTML ´.
    switch( parseInt(idxClass[0]/100) )
    {
        /* Ѽ */  case 1 :
        /* õ */  case 6 :
        /* 氩 */  case 7 :
        /* ߰ */  case 8 : fun_DrawTable(revampItem, 0, 0); break;
        /*  */  case 2 : fun_DrawTable(revampItem, 2, 0, Array("÷", "Ÿ", "")); break;
        /* ä */  case 3 :
                    {
                        /*  */
                        if( idxClass[0] == 302 )
                        {
                            fun_DrawTable(revampItem, 2, 1, Array("ä", "ӵ", "Ȯ", "")); break;
                        }
                        else
                        {
                            fun_DrawTable(revampItem, 2, 1, Array("ä", "ӵ", "2Ȯ", "")); break;
                        }
                    }
        /*Ÿ*/  case 4 : fun_DrawTable(revampItem, 2, 1, Array("λ", "Min", "Max", "Ÿ")); break;
        /*  */  case 5 : fun_DrawTable(revampItem, 3, 0, Array("ڵ Ȯ", "", "Ÿ", "")); break;
        /* ϵ */  case 9 :
                    {
                        if( idxClass[1] == CON_CLASS_WAND )
                        {
                            fun_DrawTable(revampItem, 2, 1, Array("", "Ҹ", "߷", "Ʈü")); break;
                        }
                        else
                        {
                            fun_DrawTable(revampItem, 0, 3, Array("", "Һ", "", "ӵ"));break;
                        }
                    }
    }

    obj.innerHTML = INHTML + fun_DesignedBy();
    fun_clickItemType(0);

    var bkImg = "rua.jpg";//fun_randBgImage(1);
    //obj.style.height = 636;
    with(obj.style)
    {
    	background = "url('image/illust/" + bkImg + "') no-repeat top left #ffffff";
    }
}



//---------------------------------------------------------
// : Խ  
// : Խ ¾  ܺ Խ ũ
// : obj =    ü
// ȯ: -
//---------------------------------------------------------
function JS_LoadBoard( obj )
{
    INHTML =  ("<div style='position:relative'>");
    INHTML += ("<table border=0 width=100% align=right>");
    INHTML += ("<tr><td width=100% height=590>");

    INHTML += ("<iframe width=" + CON_BASE_WIDTH + " height=580 marginwidth=0 marginheight=0 ");
    INHTML += ("hspace=0 vspace=0 frameborder=0 scrolling=atuo align=right ");
    //     Խ ּ
    INHTML += ("id='fraBoard' src='http://hwild.inour.net/bbs/zboard.php?id=wb_simul_free' ");
    INHTML += ("style='border:1px dotted #444444;filter:alpha(opacity=80);'>");
    INHTML += ("</iframe>");

    INHTML += ("</td></tr>");
    INHTML += ("<tr><td>");
    INHTML += fun_DesignedBy();
    INHTML += ("</td></tr>");
    INHTML += ("</table>");
    INHTML += ("</div>");

    obj.innerHTML = INHTML;

    //obj.style.height = 600;
    var bkImg = "nao_a.jpg";//fun_randBgImage(1);
    with(obj.style)
    {
        background = "url('image/illust/" + bkImg + "') no-repeat top left #ffffff";
    }
}

//---------------------------------------------------------
// : MML ȭ 
// : Ǳ⿬  
// : obj =    ü
// ȯ: -
//---------------------------------------------------------
function JS_LoadMMLPlay( obj )
{
	INHTML = "";
    INHTML += ("<div style='position:relative;' width=100% align=right>");
	INHTML += js_WriteScoreTable();
    INHTML += fun_DesignedBy();
    INHTML += ("</div>");

    obj.innerHTML = INHTML;

    var bkImg = "nao_b.jpg"; //fun_randBgImage(1);
    //obj.style.height = 636;
    with(obj.style)
    {
    	background = "url('image/illust/" + bkImg + "') no-repeat top left #ffffff";
    }
}

//---------------------------------------------------------
// :  ȭ 
// : ȭ   , Ÿ 
// : obj =    ü
// ȯ: -
//---------------------------------------------------------
function JS_LoadFirst( obj )
{
    fun_setNotice();
    fun_setUpdate();

    INHTML =  "<div align=right>";
    INHTML += "<table border=0 width=100%>";
    INHTML += "<tr><td height=480 align=right valign=top>";

    INHTML += "<table border=0>"
    // 
    INHTML += "<tr><td><table border=0 class=NO_SPACE><tr id=TT><td id=TT>&nbsp;Notice ";
    INHTML += "<a href='#prev' onclick='blur();fun_readNotice(+1)' id=CT></a>";
    INHTML += "</td><td id='NPG' style='font-size:8pt'></td><td>";
    INHTML += "<a href='#next' onclick='blur();fun_readNotice(-1)' id=CT></a>";
    INHTML += "</td></tr></table></td></tr><tr><td>";
    INHTML += "<fieldset style='width:600;height:185;overflow-x:hidden;overflow-y:auto;filter:alpha(opacity=80);' id='notice'>";
    INHTML += "</fieldset><p></td></tr>";
    // Ʈ
    INHTML += "<tr><td><table border=0 class=NO_SPACE><tr id=TT><td id=TT>&nbsp;Update ";
    INHTML += "<a href='#prev' onclick='blur();fun_readUpdate(+1)' id=CT></a>";
    INHTML += "</td><td id='UPG' style='font-size:8pt'></td><td>";
    INHTML += "<a href='#next' onclick='blur();fun_readUpdate(-1)' id=CT></a>";
    INHTML += "</td></tr></table></td></tr><tr><td>";
    INHTML += "<fieldset style='width:600;height:240;overflow-x:hidden;overflow-y:auto;filter:alpha(opacity=80);' id='uplist'>";
    INHTML += "</fieldset></td></tr>";
    // ۱ 
    INHTML += "</table></td></tr><tr><td>";
    INHTML += fun_DesignedBy();
    INHTML += "</td></tr></table></div>";

    obj.innerHTML = INHTML;
    var bkImg = "bard.jpg";
    with (obj.style)
    {
        background = "url('image/" + bkImg + "') no-repeat top left #ffffff";
    }

    // ֽ װ   
    fun_readNotice(0);
    fun_readUpdate(0);
}



//---------------------------------------------------------
// : A.P ùķ ù ȭ 
// :     ų    
// : -
// ȯ: -
//---------------------------------------------------------
function fun_DrawApTable()
{
    INHTML  = ("<table border=0 width=100%>");
    INHTML += ("<tr><td valign=top>");
    INHTML += ("</td><td align=center>");

    // ǥ
    INHTML += ("<table border=0 cellspacing=0 cellpadding=1><tr><td>");
    INHTML += ("<table border=1 bordercolor=#c0c0c0 bgcolor=#ffffff>");
    INHTML += ("<tr class=LIGHT_GRAY align=center>");
    INHTML += ("<td width=118 rowspan=2>A.P</td ><td width=50 rowspan=2>ü</td><td width=50 rowspan=2>ؾ</td><td width=50 rowspan=2></td>");
    INHTML += ("<td width=50 rowspan=2></td><td width=50 rowspan=2></td><td width=50 rowspan=2></td><td width=50 rowspan=2></td>");
    INHTML += ("<td colspan=3></td><td colspan=3>Ÿ</td>");
    INHTML += ("<td colspan=1></td><td width=50 rowspan=2>ũ</td></tr>");
    INHTML += ("<tr class=LIGHT_GRAY align=center><td width=50>ִ</td><td width=50>ּ</td><td width=50>뷱</td>");
    INHTML += ("<td width=50>ִ</td><td width=50>ּ</td><td width=50>뷱</td>");
    INHTML += ("<td width=50></td>");
    INHTML += ("</tr><tr align=center>");
    //   ¶
    for(var k=0; k<16; k++)
    {
        INHTML += ("<td height=38 id='apStat_" + k + "'></td>");
    }
    INHTML += ("</tr></table>");
    INHTML += ("</td></tr>");
    INHTML += ("<tr><td colspan=16 height=30 valign=bottom>");
    INHTML += ("<table border=0>");
    INHTML += ("<tr align=center>");
    INHTML += ("<td width=584 id='CP' align=left></td>");
    // ų ʱȭ ư
    INHTML += ("<td width=48 height=28 class=BTN_COLOR2 ");
    INHTML += ("onmouseover='this.style.background=\"#fff0f0\";this.style.cursor=\"hand\";' ");
    INHTML += ("onmouseout ='this.style.background=\"#efefef\"' ");
    INHTML += ("onclick='fun_InitAP()'>Init</td>");
    INHTML += ("<td width=1></td>");
    // ų ִ ư
    INHTML += ("<td width=48 height=28 class=BTN_COLOR2 ");
    INHTML += ("onmouseover='this.style.background=\"#fff0f0\";this.style.cursor=\"hand\";' ");
    INHTML += ("onmouseout ='this.style.background=\"#efefef\"' ");
    INHTML += ("onclick='fun_MaxAP()'>Max</td>");
    INHTML += ("<td width=1></td>");
    //  ų  ư
    INHTML += ("<td width=48 height=28 class=BTN_COLOR2 ");
    INHTML += ("onmouseover='this.style.background=\"#fff0f0\";this.style.cursor=\"hand\";' ");
    INHTML += ("onmouseout ='this.style.background=\"#efefef\"' ");
    INHTML += ("onclick='fun_APSaveCookie()'>Save</td>");
    INHTML += ("<td width=1></td>");
    //   ҷ ư
    INHTML += ("<td width=48 height=28 class=BTN_COLOR2 ");
    INHTML += ("onmouseover='this.style.background=\"#fff0f0\";this.style.cursor=\"hand\";' ");
    INHTML += ("onmouseout ='this.style.background=\"#efefef\"' ");
    INHTML += ("onclick='fun_APLoadCookie()'>Load</td>");
    INHTML += ("<td width=5></td>");
    // Export
    INHTML += ("<td width=48 height=28 class=BTN_COLOR2 ");
    INHTML += ("onmouseover='this.style.background=\"#fff0f0\";this.style.cursor=\"hand\";' ");
    INHTML += ("onmouseout ='this.style.background=\"#efefef\"' ");
    INHTML += ("onclick='fun_APExport()'>Export</td>");
    INHTML += ("<td width=1></td>");
    // Import
    INHTML += ("<td width=48 height=28 class=BTN_COLOR2 ");
    INHTML += ("onmouseover='this.style.background=\"#fff0f0\";this.style.cursor=\"hand\";' ");
    INHTML += ("onmouseout ='this.style.background=\"#efefef\"' ");
    INHTML += ("onclick='fun_APImport()'>Import</td>");

    INHTML += ("</tr></table>");
    INHTML += ("</td></tr>");
    INHTML += ("</table>");

    /* 2 ̾  ų  ȭ   */
    //  ̾
    INHTML += ("<div id='div_cp' style='display:none'></div>");
    // ų ̾
    INHTML += ("<div id='div_ap' style='display:'>");
    //  ų 
    if( skills.melee )
    {
        INHTML += ("<table border=0 cellspacing=0 style='filter:alpha(opacity=80)' width=918>");
        INHTML += ("<tr><td class=HEAD_TITLE width=20 align=center></td>");
        INHTML += ("<td class=NO_SPACE>");
        INHTML += ("<table border=0>");
        for(var i=0; i<skills.melee; i++)
        {
            var skill = skills.getSkill(CON_TYPE_MELEE, i+1);
            // 4 
            if( i % 4 == 0 )
            {
                INHTML += ("<tr>");
            }
            INHTML += ("<td style='padding-top:1'>");
            INHTML += ("<table border=1 bordercolor=#c0c0c0 cellspacing=0 cellpadding=3 bgcolor=#fffff0>");
            // ų ̹ 
            INHTML += ("<td><img src='image/skill/" + skill.sImage + "'></td>");
            // ų(/) 
            INHTML += ("<td align=center width=110><span class=MINI>" + skill.sEname + "</span><br>" + skill.sKname + "<br></td>");
            // ų ũ 
            INHTML += ("<td width=60><select id='selSkill_" + skill.Index + "' onchange='calcAp()'>");
            for(var j=0; j<skill.sRank.length; j++)
            {
                INHTML += ("<option value=" + j + ">" + skill.sRank[j].sRank + "</option>");
            }
            INHTML += ("</select></td></table></td>");
        }
        INHTML += ("</tr></table>");
        INHTML += ("</td></tr><tr><td height=2 colspan=2></td></tr><tr><td height=1 bgcolor=#a0a0a0 colspan=2></td></tr><tr><td height=2 colspan=2></td></tr></table>");
    }
    // Ÿ ų 
    if( skills.range )
    {
        INHTML += ("<table border=0 cellspacing=0 style='filter:alpha(opacity=80)' width=918>");
        INHTML += ("<tr><td class=HEAD_TITLE width=20 align=center></td>");
        INHTML += ("<td class=NO_SPACE>");
        INHTML += ("<table border=0>");
        for(var i=0; i<skills.range; i++)
        {
            var skill = skills.getSkill(CON_TYPE_RANGE, i+1);

            if( i % 4 == 0 )
            {
                INHTML += ("<tr>");
            }
            INHTML += ("<td style='padding-top:1'>");
            INHTML += ("<table border=1 bordercolor=#c0c0c0 cellspacing=0 cellpadding=3 bgcolor=#fffff0>");
            INHTML += ("<td><img src='image/skill/" + skill.sImage + "'></td>");
            INHTML += ("<td align=center width=110><span class=MINI>" + skill.sEname + "</span><br>" + skill.sKname + "<br></td>");
            INHTML += ("<td width=60><select id='selSkill_" + skill.Index + "' onchange='calcAp()'>");
            for(var j=0; j<skill.sRank.length; j++)
            {
                INHTML += ("<option value=" + j + ">" + skill.sRank[j].sRank + "</option>");
            }
            INHTML += ("</select></td></table></td>");
        }
        INHTML += ("</tr></table>");
        INHTML += ("</td></tr><tr><td height=2 colspan=2></td></tr><tr><td height=1 bgcolor=#a0a0a0 colspan=2></td></tr><tr><td height=2 colspan=2></td></tr></table>");
    }
    //  ų 
    if( skills.magic )
    {
        INHTML += ("<table border=0 cellspacing=0 style='filter:alpha(opacity=80)' width=918>");
        INHTML += ("<tr><td class=HEAD_TITLE width=20 align=center></td>");
        INHTML += ("<td class=NO_SPACE>");
        INHTML += ("<table border=0>");
        for(var i=0; i<skills.magic; i++)
        {
            var skill = skills.getSkill(CON_TYPE_MAGIC, i+1);

            if( i % 4 == 0 )
            {
                INHTML += ("<tr>");
            }
            INHTML += ("<td style='padding-top:1'>");
            INHTML += ("<table border=1 bordercolor=#c0c0c0 cellspacing=0 cellpadding=3 bgcolor=#fffff0>");
            INHTML += ("<td><img src='image/skill/" + skill.sImage + "'></td>");
            INHTML += ("<td align=center width=110><span class=MINI>" + skill.sEname + "</span><br>" + skill.sKname + "<br></td>");
            INHTML += ("<td width=60><select id='selSkill_" + skill.Index + "' onchange='calcAp()'>");
            for(var j=0; j<skill.sRank.length; j++)
            {
                INHTML += ("<option value=" + j + ">" + skill.sRank[j].sRank + "</option>");
            }
            INHTML += ("</select></td></table></td>");
        }
        INHTML += ("</tr></table>");
        INHTML += ("</td></tr><tr><td height=2 colspan=2></td></tr><tr><td height=1 bgcolor=#a0a0a0 colspan=2></td></tr><tr><td height=2 colspan=2></td></tr></table>");
    }
    // Ȱ,  ų 
    if( skills.life )
    {
        INHTML += ("<table border=0 cellspacing=0 style='filter:alpha(opacity=80)' width=918>");
        INHTML += ("<tr><td class=HEAD_TITLE width=20 align=center></td>");
        INHTML += ("<td class=NO_SPACE>");
        INHTML += ("<table border=0>");
        for(var i=0; i<skills.life; i++)
        {
            var skill = skills.getSkill(CON_TYPE_LIFE, i+1);

            if( i % 4 == 0 )
            {
                INHTML += ("<tr>");
            }
            INHTML += ("<td style='padding-top:1'>");
            INHTML += ("<table border=1 bordercolor=#c0c0c0 cellspacing=0 cellpadding=3 bgcolor=#fffff0>");
            INHTML += ("<td><img src='image/skill/" + skill.sImage + "'></td>");
            INHTML += ("<td align=center width=110><span class=MINI>" + skill.sEname + "</span><br>" + skill.sKname + "<br></td>");
            INHTML += ("<td width=60><select id='selSkill_" + skill.Index + "' onchange='calcAp()'>");
            for(var j=0; j<skill.sRank.length; j++)
            {
                INHTML += ("<option value=" + j + ">" + skill.sRank[j].sRank + "</option>");
            }
            INHTML += ("</select></td></table></td>");
        }
        INHTML += ("</tr></table>");
        INHTML += ("</td></tr><tr><td height=2 colspan=2></td></tr><tr><td height=1 bgcolor=#a0a0a0 colspan=2></td></tr><tr><td height=2 colspan=2></td></tr></table>");
    }
    // ݼ ų 
    if( skills.alchemy )
    {
        INHTML += ("<table border=0 cellspacing=0 style='filter:alpha(opacity=80)' width=918>");
        INHTML += ("<tr><td class=HEAD_TITLE width=20 align=center></td>");
        INHTML += ("<td class=NO_SPACE>");
        INHTML += ("<table border=0>");
        for(var i=0; i<skills.alchemy; i++)
        {
            var skill = skills.getSkill(CON_TYPE_ALCHEMY, i+1);

            if( i % 4 == 0 )
            {
                INHTML += ("<tr>");
            }
            INHTML += ("<td style='padding-top:1'>");
            INHTML += ("<table border=1 bordercolor=#c0c0c0 cellspacing=0 cellpadding=3 bgcolor=#fffff0>");
            INHTML += ("<td><img src='image/skill/" + skill.sImage + "'></td>");
            INHTML += ("<td align=center width=110><span class=MINI>" + skill.sEname + "</span><br>" + skill.sKname + "<br></td>");
            INHTML += ("<td width=60><select id='selSkill_" + skill.Index + "' onchange='calcAp()'>");
            for(var j=0; j<skill.sRank.length; j++)
            {
                INHTML += ("<option value=" + j + ">" + skill.sRank[j].sRank + "</option>");
            }
            INHTML += ("</select></td></table></td>");
        }
        INHTML += ("</tr></table>");
        INHTML += ("</td></tr></table>");
    }

    INHTML += ("</td></tr></table>");
    INHTML += ("</div>");
}



//---------------------------------------------------------
// : A.P  ʱȭ
// : õǾ ִ ü ų ũ ʱȭ
// : -
// ȯ: -
//---------------------------------------------------------
function fun_InitAP()
{
    for(var i=0; i<skills.skills.length; i++)
    {
        eval("selSkill_"+i).value = 0;
    }
    calcAp();
}



//---------------------------------------------------------
// : A.P  ִ
// : ü ų ִ ũ 
// : -
// ȯ: -
//---------------------------------------------------------
function fun_MaxAP()
{
    for(var i=0; i<skills.skills.length; i++)
    {
        eval("selSkill_"+i).value = skills.skills[i].sRank.length-1;
    }
    calcAp();
}



//---------------------------------------------------------
// : A.P 
// : õ  ų  A.P  ߰   
//          ߰   뷱  
// : -
// ȯ: -
//---------------------------------------------------------
function calcAp()
{
    // õ ų ũ 
    for(var i=0; i<skills.skills.length; i++) {
        skills.skills[i].SetRank( eval("selSkill_"+i).value );
    }
    skills.calcAp();

    // ü  A.P 
    apStat_0.innerHTML = "<font color=#0044ff><b>"+ skills.calcResult[0] + "</b></font>";

    //  ɷġ 
    for(i = 0; i<7; i++) {
        eval("apStat_"+(1+i)).innerHTML = skills.calcResult[10+i];
    }

    // ߰   뷱, ũƼ 
    apStat_8.innerHTML  = skills.calcResult[2];
    apStat_9.innerHTML  = skills.calcResult[1];
    apStat_10.innerHTML = skills.calcResult[6] + "%";
    apStat_11.innerHTML = skills.calcResult[4];
    apStat_12.innerHTML = skills.calcResult[3];
    apStat_13.innerHTML = skills.calcResult[7] + "%";
    apStat_14.innerHTML = skills.calcResult[5];
    //apStat_15.innerHTML = skills.calcResult[8] + "%";
    apStat_15.innerHTML = skills.calcResult[9]+ "%";

    // ų  
    var kp = fun_RoundPos(skills.calcCp(),3);
    // ĳ  
    var tp = fun_RoundPos(skills.calcMp(),3);
    // ų  
    CP.innerHTML  = "<a href='#1' id='LK' onclick='fun_ShowCP()' title='ų  ϼ'>  </a> ų(" + kp + ")";
    //  ȭ    ݿ
    if( div_cp.style.display != 'none' ) {
        fun_ShowCP();
    }
}



//---------------------------------------------------------
// : ų  ε
// : A.P  ʱȭ 
// : br  =   (0=ΰ/1=/2=̾Ʈ)
//       obj =  µ ü
// ȯ: -
//---------------------------------------------------------
function JS_LoadAP( br, obj )
{
    // õ  ų ε
    fun_LoadSkill(br);
    fun_DrawApTable();

    // ۱ 
    obj.innerHTML = (INHTML + fun_DesignedBy());

    //  ̹ 
    var bkImg = "imp.jpg";
    with (obj.style)
    {
        background = "url('image/illust/" + bkImg + "') no-repeat top left #ffffff";
    }

    calcAp();
}


//---------------------------------------------------------
// :  ų 
// : õ ų Ű Ѵ.
// : -
// ȯ: -
//---------------------------------------------------------
function fun_APSaveCookie()
{
    var saveValue = "";
    try {
        // õ ų ũ
        for (var i=0; i<skills.skills.length; i++) {
            saveValue += eval("selSkill_" + i).value + ",";
        }
        // õ  (  ޸Ѵ.)
        switch( BROOD ) {
            case CON_SKILL_HUMAN: {
                fun_WriteCookie("HAP", saveValue);
            } break;

            case CON_SKILL_ELF: {
                fun_WriteCookie("EAP", saveValue);
            } break;

            case CON_SKILL_GIANT: {
                fun_WriteCookie("GAP", saveValue);
            } break;
        }
        alert("ų ͸ Ͽϴ");
    }
    catch(e) {
        alert("ų  忡 ߽ϴ");
    }
}

//---------------------------------------------------------
// :   ε
// :  Ű  ҷ ڵ Ѵ.
// : -
// ȯ: -
//---------------------------------------------------------
function fun_APLoadCookie()
{
    var saveValue = "";
    var setRanks;

    try {
        //  õǾ ִ  ͸ ε
        switch( BROOD ) {
            case CON_SKILL_HUMAN: {
                saveValue = fun_ReadCookie("HAP");
            } break;

            case CON_SKILL_ELF: {
                saveValue = fun_ReadCookie("EAP");
            } break;

            case CON_SKILL_GIANT: {
                saveValue = fun_ReadCookie("GAP");
            } break;
        }

        if( saveValue != "" ) {
            // ų   ũ 
            setRanks = saveValue.split(",");
            for(var i=0; i<skills.skills.length; i++) {
                eval("selSkill_" + i).value = parseInt(setRanks[i]);
            }
            // A.P   
            calcAp();
            return;
        }
        alert(" Ͱ ϴ");
    }
    catch(e) {
        alert("ų ͸ ҷ ߽ϴ");
    }
}

function fun_APExport()
{
    var saveValue = "";
    
    for (var i=0; i<skills.skills.length; i++) {
        saveValue += eval("selSkill_" + i).value + ",";
    }

    switch( BROOD ) {
        case CON_SKILL_HUMAN: {
            saveValue = "H" + saveValue;
        } break;

        case CON_SKILL_ELF: {
            saveValue = "E" + saveValue;
        } break;

        case CON_SKILL_GIANT: {
            saveValue = "G" + saveValue;
        } break;
    }
    prompt('Export Data', saveValue);
}

function fun_APImport()
{
	var bSet = false;
	var str = prompt('Import Data', '');	
		
	if( str == null || str == "") {
		return;
	}

	var strSep = str.substr(0, 1);
	var strValue = str.substr(1);
    switch( BROOD ) {
        case CON_SKILL_HUMAN: {
           	if(strSep == "H") {
           		bSet = true;
           	}
        } break;

        case CON_SKILL_ELF: {
            if(strSep == "E") {
            	bSet = true;
            }
        } break;

        case CON_SKILL_GIANT: {
            if(strSep == "G") {
            	bSet = true;
            }
        } break;
    }

    if(bSet==true) {
        var setRanks = strValue.split(",");
        for(var i=0; i<skills.skills.length; i++) {
            eval("selSkill_" + i).value = parseInt(setRanks[i]);
        }
        calcAp();
        return;
    }
    
    alert("ش  Ͱ ƴմϴ.");
}
