//////////////////////////////////////////////////
/////         Netmarble Laghaim              /////
/////                      provided by hayun /////
//////////////////////////////////////////////////

switch(theRace) {
    case "aBulkan":
        weaponEng=axeEng;   weaponKor=axeKor;  
        aSkillDamNote=iSkillDamNote[1];bSkillDamNote=iSkillDamNote[2];
        iWhatIsThis=iWhatIsThisABulkan;break;
    case "wBulkan":
        weaponEng=swordEng; weaponKor=swordKor;
        aSkillDamNote=iSkillDamNote[3];bSkillDamNote=iSkillDamNote[4];
        iWhatIsThis=iWhatIsThisWBulkan;break;
    case "hHybrid":
        weaponEng=hummaEng;   weaponKor=hummaKor;  
        aSkillDamNote=iSkillDamNote[5];bSkillDamNote=iSkillDamNote[6];
        iWhatIsThis=iWhatIsThisHHybrid;break;
    case "tHybrid":
        weaponEng=twinEng; weaponKor=twinKor;
        aSkillDamNote=iSkillDamNote[7];bSkillDamNote=iSkillDamNote[8];
        iWhatIsThis=iWhatIsThisTHybrid;break;
    case "Kairipton":
        weaponEng=staffEng; weaponKor=staffKor;
        aSkillDamNote=iSkillDamNote[9];bSkillDamNote=iSkillDamNote[10];
        iWhatIsThis=iWhatIsThisKairipton;break;
    case "Human":
        weaponEng=gunEng;   weaponKor=gunKor;
        aSkillDamNote=iSkillDamNote[11];bSkillDamNote=iSkillDamNote[12];
        iWhatIsThis=iWhatIsThisHuman;break;
    case "Aidia":
        weaponEng=ringEng;  weaponKor=ringKor;
        aSkillDamNote=iSkillDamNote[13];bSkillDamNote=iSkillDamNote[14];
        iWhatIsThis=iWhatIsThisAidia;break;
    default:break;
}

// generate present weapon object
function theWeapon(arr,zname,zupnum) {
    var t=this;
    t.engName = arr[0]; t.korName = zname;
    t.weapLevel = arr[1];
    t.levelGrade = Math.ceil(t.weapLevel/30);
    t.minDam = arr[2]; t.maxDam = arr[3];
    t.atkSpeed = arr[4];
    t.strLimit = arr[5]; t.wisLimit = arr[6]; t.spdLimit = arr[7];
    t.isTwohand = arr[8]; t.etc = arr[9];t.itemPrice=arr[10];
    t.noUpgrade=zupnum;t.staffDam=0;
    // basicDam : bareDam+magicDam (kai), bareDam+weapDam (others)
    // basicDamDes : bareDam+magicDam (kai), bareDam+weapDam (others)
    t.badWeather=-0.1;t.goodWeather=0.1;
    t.magicDam=0;t.staffDam=0;
    t.weapDam1=0;t.weapDam2=0;t.basicDamDes='';
    // weapDam1t:twohand, weapDam1o:onehand, useOnehand:ÇÑ¼Õ»ç¿E¸·Î?
    t.weapDam1o=0;t.weapDam2o=0;t.weapDam1t=0;t.weapDam2t=0;t.useOnehand=false;
    t.aSkillDam1=0;t.aSkillDam2=0;t.aSkillDamDes='';
    t.bSkillDam1=0;t.bSkillDam2=0;t.bSkillDamDes='';
    t.secDam1=0;t.secDam2=0;t.secDamDes='';
    t.gyulChiDam1=0;t.gyulChiDam2=0;t.gyulChiDamMax=0;t.gyulChiDamDes=''
    t.isNoWeap=false;t.isAxe=false;t.isSword=false;t.isStaff=false;t.isGun=false;t.isRing=false;
    t.masuk1=0; t.masuk2=0; t.masuk3=0; t.masuk4=0; t.masuk5=0; t.masuk6=0;
    t.masuk1dam=0;t.masuk2dam=0;t.masuk3dam=0;
    t.masuk4dam=0;t.masuk5dam=0;t.masuk6dam=0;
    // level,STR,WIS,DEX no limit : 0=not apply, 1=apply
    // level,STR,WIS,DEX limit decrease : 0=not apply, 3~25=apply
    t.spLvlNo=0;t.spLvlDown=0;t.spLvlDownMin=3;t.spLvlDownMax=25;
    t.spStrNo=0;t.spStrDown=0;t.spStrDownMin=3;t.spStrDownMax=25;
    t.spWisNo=0;t.spWisDown=0;t.spWisDownMin=3;t.spWisDownMax=25;
    t.spSpdNo=0;t.spSpdDown=0;t.spSpdDownMin=3;t.spSpdDownMax=25;
    // spSpeed (increase attack speed) : kailipton 0~0.1, others 0 or 1
    // spDamage (special damage)  : 0~30
    t.spSpeed=0;t.spSpeedMin=0;t.spSpeedMax=0.1;
    t.spDamage=0;t.spDamageMin=0;t.spDamageMax=30;

    switch(t.engName.charAt(0)){
    // w:sword, a:axe, s:staff, g:gun, r:ring
        case 'a': t.isAxe=true;
            iMASUK=mNoStaff;iMASUKNote=mNoStaffNote;
            break;
        case 'w': t.isSword=true;
            iMASUK=mNoStaff;iMASUKNote=mNoStaffNote;
            break;
        case 'h': t.isHum=true;
            iMASUK=mNoStaff;iMASUKNote=mNoStaffNote;
            break;
        case 't': t.isTwin=true;
            iMASUK=mNoStaff;iMASUKNote=mNoStaffNote;
            break;
        case 'g': t.isGun=true;
            iMASUK=mNoStaff;iMASUKNote=mNoStaffNote;
            break;
        case 'r': t.isRing=true;
            iMASUK=mNoStaff;iMASUKNote=mNoStaffNote;
            break;
        case 's': t.isStaff=true;
            iMASUK=mStaff;iMASUKNote=mStaffNote;
            break;
        case 'n': t.isNoWeap=true;
            iMASUK=mNoWeap;iMASUKNote=mNoWeapNote;
            break;
    }
    t.masuk1note=iMASUKNote[1];t.masuk2note=iMASUKNote[2];t.masuk3note=iMASUKNote[3];
    t.masuk4note=iMASUKNote[4];t.masuk5note=iMASUKNote[5];t.masuk6note=iMASUKNote[6];
}

// upgrade the weapon with masuk & jewel, only apply to weapDam1 & weapDam2
theWeapon.prototype.upgradeWeapon = function() {
    // damage = (bareDam+(weapDam*masuk6+masuk1/2/4)*jewel)*skill
    // ignore the effect of chimyungta & gyuljungta, temporarily
    // if staff, also ignore the weather effect for masuk 1/2/4
    if (myChar.engRace=='Kairipton') {
        this.magicDam=myChar.magicDam;this.staffDam=this.maxDam;
        this.badWeather=-0.1;this.goodWeather=0.1;
        }
    else {this.weapDam1=this.minDam;this.weapDam2=this.maxDam;}
    // true when (axe || sword) && one hand weapon && use shield => to calculate the one/two hand damage with shield, except Meta shield
    if ((myWeapon.isAxe || myWeapon.isSword) && myWeapon.isTwohand && myArmor.S.itemLevel>0 && myArmor.S.itemLevel<=180) this.useOnehand=true;
    else this.useOnehand=false;
    this.applyMasuk();this.applyJewel();this.applySkill();this.calSecDam();this.calGyulChiDam();
    return true;
}

// apply magic stone(=masuk) & special item
theWeapon.prototype.applyMasuk = function() {
    // levelGrade:1=min(bad weather), 2=max(good weather), 3=decisive 4=weapon(magci) damage, 5=critical, 6=weapon damage %
    // levelGrade == 6 should be applied first
    if (this.levelGrade>=6) {
        if (this.isStaff) {
            this.staffDam+=this.masuk6dam;
            //this.magicDam*=(1+this.masuk6dam);
        }
        else {
            this.weapDam1*=(1+this.masuk6dam);this.weapDam2*=(1+this.masuk6dam);
        }
    }
    if (this.levelGrade>=1) {
        if (this.isStaff) this.badWeather+=this.masuk1dam;
        else {
            this.weapDam1+=this.masuk1dam;
            // below is small bug in Laghaim
            // example:Tornado rifle(compare with magic stone full up value)
            //this.weapDam1>this.weapDam2 ? this.weapDam1=this.weapDam2 : true;
        }
    }
    if (this.levelGrade>=2) {
        if (this.isStaff) this.goodWeather+=this.masuk2dam;
        else {
            this.weapDam2+=this.masuk2dam;
        }
    }
    if (this.levelGrade>=4) {
        if (this.isStaff) {
            this.magicDam+=this.masuk4dam;
        }
        else {  // magic stone && special item
            this.weapDam1+=this.masuk4dam;this.weapDam2+=this.masuk4dam;
        }
    }
    // special item
    if (this.isStaff) this.magicDam+=this.spDamage;
    else {this.weapDam1+=this.spDamage;this.weapDam2+=this.spDamage;}
    // for GyulJungTa & ChiMyungTa, see the calGyulChiDam()
    return true;
}

// apply jewel after masuk
theWeapon.prototype.applyJewel = function() {
    if (this.isNoWeap) {
        if (myChar.engRace=='Kairipton') this.basicDamDes="‘fŽè "+Math.floor(myChar.bareDam) + "<br>–‚–@ "+Math.floor(this.magicDam);
        else this.basicDamDes="‘fŽè "+Math.floor(myChar.bareDam)+"<br>&nbsp;";
    }
    else {
        if(this.weapLevel>260){plusValue=plusValueC;}
        if(this.weapLevel<=260 && this.weapLevel>180){plusValue=plusValueB;}
        if(this.weapLevel<=180){plusValue=plusValueA;}
        //plusValue=this.weapLevel>180?plusValueB:plusValueA;    // 15 upgrade for diamond item
        if (this.isStaff) {;
            if(this.weapLevel>260){
                this.staffDam *= (1+plusValue[this.noUpgrade]/0.748);
                this.gyulChiDam2 *= (1+plusValue[this.noUpgrade]/0.748);
                this.gyulChiDamMax *= (1+plusValue[this.noUpgrade]/0.748);
            }
            else{
                this.staffDam *= (1+plusValue[this.noUpgrade]/0.57);
                this.gyulChiDam2 *= (1+plusValue[this.noUpgrade]/0.57);
                this.gyulChiDamMax *= (1+plusValue[this.noUpgrade]/0.57);
            }
            // kai : floor , others : round , don't know why?
            this.basicDamDes="‘fŽè "+Math.floor(myChar.bareDam)+"<br>–‚–@ "+Math.floor(this.magicDam);
        }
        else {
            /*  ¸¶¼® °ø°Ý·Â 10% »ó½Â ÈÄ=>ÇØ´E°ª ¼Ò¼ýÁ¡ÀÌÇÏ ¹ö¸² => º¸¼®¾÷ÇÒ°Í
                +3 ÁúÇ³°Ë ¸¶¼®Ç®¿É (2401) µÎ¼Õ°ø°Ý·Â : 347-386 (°ÔÀÓÇ¥½Ã°ª)
                          ¼öÁ¤ÀE: ±âº» 210-235, ???(210~235*1.1 +5+5)*1.44=347.04~386.64
                          ¼öÁ¤ÈÄ : ±âº» 210-235 *1.1=231-258.5=>(231-258 +5+5)*1.44=347.04~385.92
                +3 Åä³×ÀÌµµ¶óÀÌÇÃ (4477) °ø°Ý·Â : 256-268 (°ÔÀÓÇ¥½Ã°ª), ÃÖ¼Ò°ø°Ý·Â 2 »ó½Â, ÃÖ´Eø°Ý·Â 5 »ó½Â, °ø°Ý·Â 2 »ó½Â, °ø°Ý·Â 10% »ó½Â
                          ¼öÁ¤ÀE: ±âº» 159~163, (159~163*1.1 +2)=176.9~181.3 +(+2~+5)=178.9~186.3 *1.44=257.616~268.272
                          ¼öÁ¤ÈÄ : ±âº» 159~163, (159~163*1.1)=174.9~179.3=>(174~179) +(+2) +(+2~+5) *1.44=256.32~267.84
            */
            this.weapDam1=Math.floor(this.weapDam1);this.weapDam2=Math.floor(this.weapDam2);
            this.weapDam1 *= (1+plusValue[this.noUpgrade]);this.weapDam2 *= (1+plusValue[this.noUpgrade]);
            // divide into one/two hand damage
            this.weapDam1t=Math.floor(this.weapDam1);this.weapDam2t=this.weapDam2;
            this.weapDam1o=this.weapDam1*2/3;this.weapDam2o=this.weapDam2*2/3;
            if (myWeapon.useOnehand) {  // when applying the one hand damage
                this.weapDam1=this.weapDam1o;this.weapDam2=this.weapDam2o;
            }
            this.gyulChiDam1 *= (1+plusValue[this.noUpgrade]);
            this.gyulChiDam2 *= (1+plusValue[this.noUpgrade]);
            this.gyulChiDamMax *= (1+plusValue[this.noUpgrade]);
            // kai : floor , others : round , don't know why?
            this.basicDamDes="‘fŽè "+Math.floor(myChar.bareDam)+"<br>"+"•Ší "+(myWeapon.useOnehand?Math.floor(this.weapDam1)+' ` '+Math.round(this.weapDam2):Math.round(this.weapDam1)+' ` '+Math.floor(this.weapDam2));
        }
    }
    return true;
}

// apply skill
theWeapon.prototype.applySkill = function() {
    switch(myChar.engRace) {
        case 'Bulkan'   : 
            // aSkill:Sword(Axe) Master, bSkill:Cut throught(Cut down), 10% random
            var zRandom=myChar.nowSkill1Value==0?0:0.1; // 10% random, when skillvalue==0
            this.aSkillDam1=(myChar.bareDam+this.weapDam1)*(this.isNoWeap?1:(1+myChar.nowSkill0Value));
            this.aSkillDam2=(myChar.bareDam+this.weapDam2)*(this.isNoWeap?1:(1+myChar.nowSkill0Value));
            this.bSkillDam1=this.aSkillDam1*(1+myChar.nowSkill1Value)*(1-zRandom);
            this.bSkillDam2=this.aSkillDam2*(1+myChar.nowSkill1Value)*(1+zRandom);
            this.gyulChiDam1=(myChar.bareDam+this.gyulChiDam1)*(1+myChar.nowSkill0Value)*(1+myChar.nowSkill1Value)*(1-zRandom);
            this.gyulChiDam2=(myChar.bareDam+this.gyulChiDam2)*(1+myChar.nowSkill0Value)*(1+myChar.nowSkill1Value)*(1+zRandom);
            this.gyulChiDamMax=(myChar.bareDam+this.gyulChiDamMax)*(1+myChar.nowSkill0Value)*(1+myChar.nowSkill1Value)*(1+zRandom);
            if (this.isNoWeap) {
                this.aSkillDamDes=Math.floor((this.aSkillDam1+this.aSkillDam2)/2);
                if (zRandom==0) // if bSkill == 0
                    this.bSkillDamDes=Math.floor((this.bSkillDam1+this.bSkillDam2)/2);
                else {
                    this.bSkillDamDes = Math.floor(this.bSkillDam1)+' ` '+Math.floor(this.bSkillDam2)
                                     + ' ('+Math.floor((this.bSkillDam1+this.bSkillDam2)/2)+')';
                }
            }
            else {
                this.aSkillDamDes = Math.floor(this.aSkillDam1)+' ` '+Math.floor(this.aSkillDam2)
                                 + ' ('+Math.floor((this.aSkillDam1+this.aSkillDam2)/2)+')';
                // bSkill (µ¹·Áº£±E³»·ÁÂEE Àº 10% »óÇÏ º¯À§°¡ ÀÖÀ½.
                this.bSkillDamDes = Math.floor(this.bSkillDam1)+' ` '+Math.floor(this.bSkillDam2)
                                 + ' ('+Math.floor((this.bSkillDam1+this.bSkillDam2)/2)+')';
            }
            this.damNote = "&nbsp;"; this.etcNote = "etcnote"; 
            break;
        case 'Hybrid'   : 
            // aSkill:Twin(Humma) Master, bSkill:Cut throught(Cut down), 10% random
            var zRandom=myChar.nowSkill2Value==0?0:0.1; // 10% random, when skillvalue==0
            this.aSkillDam1=(myChar.bareDam+this.weapDam1)*(this.isNoWeap?1:(1+myChar.nowSkill0Value));
            this.aSkillDam2=(myChar.bareDam+this.weapDam2)*(this.isNoWeap?1:(1+myChar.nowSkill0Value));
            this.bSkillDam1=this.aSkillDam1*(1+myChar.nowSkill2Value)*(1-zRandom);
            this.bSkillDam2=this.aSkillDam2*(1+myChar.nowSkill2Value)*(1+zRandom);
            this.gyulChiDam1=(myChar.bareDam+this.gyulChiDam1)*(1+myChar.nowSkill0Value)*(1+myChar.nowSkill2Value)*(1-zRandom);
            this.gyulChiDam2=(myChar.bareDam+this.gyulChiDam2)*(1+myChar.nowSkill0Value)*(1+myChar.nowSkill2Value)*(1+zRandom);
            this.gyulChiDamMax=(myChar.bareDam+this.gyulChiDamMax)*(1+myChar.nowSkill0Value)*(1+myChar.nowSkill2Value)*(1+zRandom);
            if (this.isNoWeap) {
                this.aSkillDamDes=Math.floor((this.aSkillDam1+this.aSkillDam2)/2);
                if (zRandom==0) // if bSkill == 0
                    this.bSkillDamDes=Math.floor((this.bSkillDam1+this.bSkillDam2)/2);
                else {
                    this.bSkillDamDes = Math.floor(this.bSkillDam1)+' ` '+Math.floor(this.bSkillDam2)
                                     + ' ('+Math.floor((this.bSkillDam1+this.bSkillDam2)/2)+')';
                }
            }
            else {
                this.aSkillDamDes = Math.floor(this.aSkillDam1)+' ` '+Math.floor(this.aSkillDam2)
                                 + ' ('+Math.floor((this.aSkillDam1+this.aSkillDam2)/2)+')';
                // bSkill (µ¹·Áº£±E³»·ÁÂEE Àº 10% »óÇÏ º¯À§°¡ ÀÖÀ½.
                this.bSkillDamDes = Math.floor(this.bSkillDam1)+' ` '+Math.floor(this.bSkillDam2)
                                 + ' ('+Math.floor((this.bSkillDam1+this.bSkillDam2)/2)+')';
            }
            this.damNote = "&nbsp;"; this.etcNote = "etcnote"; 
            break;
        case 'Kairipton': 
            this.aSkillDam1=(myChar.bareDam+this.magicDam)*(1+this.staffDam)*(1+this.badWeather);
            this.aSkillDam2=(myChar.bareDam+this.magicDam)*(1+this.staffDam)*(1+this.goodWeather);
            this.aSkillDamDes = Math.floor(this.aSkillDam1*(1+myChar.nowSkill9Value))+' ` '+Math.floor(this.aSkillDam2*(1+myChar.nowSkill9Value))
                              +' ('+Math.floor((this.aSkillDam1+this.aSkillDam2)*(1+myChar.nowSkill9Value)/2)+')';
            this.bSkillDam1=this.aSkillDam1*(1+myChar.nowSkill3Value+myChar.nowSkill9Value);
            this.bSkillDam2=this.aSkillDam2*(1+myChar.nowSkill3Value+myChar.nowSkill9Value);
            this.bSkillDamDes = Math.floor(this.bSkillDam1)+' ` '+Math.floor(this.bSkillDam2)
                              +' ('+Math.floor((this.bSkillDam1+this.bSkillDam2)/2)+')';
            this.gyulChiDam1=0;
            this.gyulChiDam2=(myChar.bareDam+this.magicDam)*(this.gyulChiDam2+1)*(1+myChar.nowSkill3Value+myChar.nowSkill9Value);
            this.gyulChiDamMax=(myChar.bareDam+this.magicDam)*(this.gyulChiDamMax+1)*(1+myChar.nowSkill3Value+myChar.nowSkill9Value);
            this.damNote = "’nã/ƒVƒ‡ƒbƒNƒXƒsƒA"; this.etcNote = "elecuse";
            break;
        case 'Human'    : 
            // 2 repeative shooting : 50%, 3 repeative shooting : 50% = total : 2.5
            this.aSkillDam1=(myChar.bareDam+this.weapDam1)*(this.isNoWeap?1:(1+myChar.nowSkill0Value));
            this.aSkillDam2=(myChar.bareDam+this.weapDam2)*(this.isNoWeap?1:(1+myChar.nowSkill0Value));
            this.bSkillDam1=this.aSkillDam1*(this.isNoWeap?1:((1-myChar.nowSkill1Value)+2.5*myChar.nowSkill1Value)*(1+myChar.nowSkill6Value+myChar.elecUp));
            this.bSkillDam2=this.aSkillDam2*(this.isNoWeap?1:((1-myChar.nowSkill1Value)+2.5*myChar.nowSkill1Value)*(1+myChar.nowSkill6Value+myChar.elecUp));
            this.gyulChiDam1=(myChar.bareDam+this.gyulChiDam1)*(1+myChar.nowSkill0Value)*((1-myChar.nowSkill1Value)+2.5*myChar.nowSkill1Value+myChar.nowSkill6Value)*(1+myChar.elecUp);
            this.gyulChiDam2=(myChar.bareDam+this.gyulChiDam2)*(1+myChar.nowSkill0Value)*((1-myChar.nowSkill1Value)+2.5*myChar.nowSkill1Value+myChar.nowSkill6Value)*(1+myChar.elecUp);
            this.gyulChiDamMax=(myChar.bareDam+this.gyulChiDamMax)*(1+myChar.nowSkill0Value)*((1-myChar.nowSkill1Value)+2.5*myChar.nowSkill1Value+myChar.nowSkill6Value)*(1+myChar.elecUp);
            if (this.isNoWeap) {
                this.aSkillDamDes=Math.floor(this.aSkillDam1+this.aSkillDam2)/2;
                this.bSkillDamDes=Math.floor(this.bSkillDam1+this.bSkillDam2)/2;
            }
            else {
                this.aSkillDamDes = Math.floor(this.aSkillDam1)+' ` '+Math.floor(this.aSkillDam2)
                                 + ' ('+Math.floor((this.aSkillDam1+this.aSkillDam2)/2)+')';
                this.bSkillDamDes = Math.floor(this.bSkillDam1)+' ` '+Math.floor(this.bSkillDam2)
                                 + ' ('+Math.floor((this.bSkillDam1+this.bSkillDam2)/2)+')';
            }
            this.damNote = "2˜AŽË 50%+3˜AŽË 50%"; this.etcNote = "etcnote"; 
            break;
        case 'Aidia'    : 
            // first skill , insect summon+100%, animal summon+100%
            this.aSkillDam1=(myChar.bareDam+this.weapDam1)*(this.isNoWeap?1:(1+myChar.nowSkill0Value)*(1+myChar.nowSkill1Value));
            this.aSkillDam2=(myChar.bareDam+this.weapDam2)*(this.isNoWeap?1:(1+myChar.nowSkill0Value)*(1+myChar.nowSkill1Value));
            // second skill, phonomenon+100%
            this.bSkillDam1=this.aSkillDam1*(this.isNoWeap?1:(1+myChar.nowSkill2Value));
            this.bSkillDam2=this.aSkillDam2*(this.isNoWeap?1:(1+myChar.nowSkill2Value));
            this.gyulChiDam1=(myChar.bareDam+this.gyulChiDam1)*(1+myChar.nowSkill0Value)*(1+myChar.nowSkill1Value)*(1+myChar.nowSkill2Value);
            this.gyulChiDam2=(myChar.bareDam+this.gyulChiDam2)*(1+myChar.nowSkill0Value)*(1+myChar.nowSkill1Value)*(1+myChar.nowSkill2Value);
            this.gyulChiDamMax=(myChar.bareDam+this.gyulChiDamMax)*(1+myChar.nowSkill0Value)*(1+myChar.nowSkill1Value)*(1+myChar.nowSkill2Value);
            if (this.isNoWeap) {
                this.aSkillDamDes=Math.floor((this.aSkillDam1+this.aSkillDam2)/2);
                this.bSkillDamDes=Math.floor((this.bSkillDam1+this.bSkillDam2)/2);
            }
            else {
                this.aSkillDamDes = Math.floor(this.aSkillDam1)+' ` '+Math.floor(this.aSkillDam2)
                                 + ' ('+Math.floor((this.aSkillDam1+this.aSkillDam2)/2)+')';
                this.bSkillDamDes = Math.floor(this.bSkillDam1)+' ` '+Math.floor(this.bSkillDam2)
                                 + ' ('+Math.floor((this.bSkillDam1+this.bSkillDam2)/2)+')';
            }
            this.damNote = "&nbsp;"; this.etcNote = "etcnote";
            break;
        default         : break;
    }
    if (!this.isNoWeap || myChar.engRace=='Kairipton') {   // when having weapon or kailipton
        iWhatIsThis[7]='<font color="red">PK : '+Math.floor(this.aSkillDam1/PKDamRate)+' ` '+Math.floor(this.aSkillDam2/PKDamRate)
                      +' ('+Math.floor((this.aSkillDam1+this.aSkillDam2)/2/PKDamRate)+')'+'</font>';
        iWhatIsThis[8]='<font color="red">PK : '+Math.floor(this.bSkillDam1/PKDamRate)+' ` '+Math.floor(this.bSkillDam2/PKDamRate)
                      +' ('+Math.floor((this.bSkillDam1+this.bSkillDam2)/2/PKDamRate)+')'+'</font>';
    }
    else {                  // if no weapon
        iWhatIsThis[7]='<font color="red">PK : '+Math.floor((this.aSkillDam1+this.aSkillDam2)/2/PKDamRate)+'</font>';
        iWhatIsThis[8]='<font color="red">PK : '+Math.floor((this.bSkillDam1+this.bSkillDam2)/2/PKDamRate)+'</font>';
    }
    return true;
}

// calculate damage per second
theWeapon.prototype.calSecDam = function() {
    //–‚Î‚É‚æ‚éƒNƒŠƒeƒBƒJƒ‹EƒtƒF[ƒ^ƒ‹ƒ_ƒƒW
    var stone_val=1;
    switch(this.masuk3) {
        case 1    :
            stone_val+=0.2*0.03;
            break;
        case 2    :
            stone_val+=0.2*0.06;
            break;
        case 3    :
            stone_val+=0.2*0.12;
            break;
        default     :
        break;
    }
    switch(this.masuk5) {
        case 1    :
            stone_val+=0.5*0.03;
            break;
        case 2    :
            stone_val+=0.5*0.06;
            break;
        case 3    :
            stone_val+=0.5*0.12;
            break;
        default     :
        break;
    }
    if (this.isNoWeap) {
        this.secDamDes=this.bSkillDamDes;
    }
    else if (this.isStaff) {
        this.secDam1=this.bSkillDam1*(1+this.atkSpeed+this.spSpeed)*stone_val;
        this.secDam2=this.bSkillDam2*(1+this.atkSpeed+this.spSpeed)*stone_val;
        this.secDamDes = Math.floor(this.secDam1)+' ` '+Math.floor(this.secDam2)
                       +' ('+Math.floor((this.secDam1+this.secDam2)/2)+')';
    }
    else if (this.isAxe) {
        this.secDam1=this.bSkillDam1*stone_val;
        this.secDam2=this.bSkillDam2*stone_val;
        this.secDamDes = Math.floor(this.secDam1)+' ` '+Math.floor(this.secDam2)
                       +' ('+Math.floor((this.secDam1+this.secDam2)/2)+')';
    }
    else {
        var zspeed=this.atkSpeed;
        //SPƒAƒCƒeƒ€‚É‚æ‚é‘¬“x‘‰Á
        if (this.atkSpeed!=0.6) zspeed=this.atkSpeed-(this.spSpeed==1?0.2:0);
        //ƒnƒCƒuƒŠƒwƒCƒXƒgƒXƒLƒ‹‚É‚æ‚é‘¬“x‘‰Á
        if (theRace=='tHybrid' && myChar.nowSkill2=='30') zspeed -= 0.2;
        this.secDam1=this.bSkillDam1*stone_val/zspeed;
        this.secDam2=this.bSkillDam2*stone_val/zspeed;
        this.secDamDes = Math.floor(this.secDam1)+' ` '+Math.floor(this.secDam2)
                       +' ('+Math.floor((this.secDam1+this.secDam2)/2)+')';
    }
    if (!this.isNoWeap) {   // when having weapon
        iWhatIsThis[9]='<font color="red">PK : '+Math.floor(this.secDam1/PKDamRate)+' ` '+Math.floor(this.secDam2/PKDamRate)
                      +' ('+Math.floor((this.secDam1+this.secDam2)/2/PKDamRate)+')'+'</font>';
    }
    else if (myChar.engRace=='Kairipton') {   // if kailipton
        iWhatIsThis[9]='<font color="red">PK : '+Math.floor(this.bSkillDam1/PKDamRate)+' ` '+Math.floor(this.bSkillDam2/PKDamRate)
                      +' ('+Math.floor((this.bSkillDam1+this.bSkillDam2)/2/PKDamRate)+')'+'</font>';
    }
    else {                  // if no weapon
        iWhatIsThis[9]='<font color="red">PK : '+Math.floor((this.bSkillDam1+this.bSkillDam2)/2/PKDamRate)+'</font>';
    }
    return true;
}

theWeapon.prototype.calGyulChiDam = function() {
    // chi : ChiMyungTa apply rate, gyul : GyulJungTa apply rate
    var gyul=this.masuk3dam;var chi=this.masuk5dam;
    this.gyulChiDam1=this.secDam1;this.gyulChiDam2=this.secDam2;this.gyulChiDamMax=this.bSkillDam2;
    if (this.isNoWeap || this.levelGrade<3) {
        this.gyulChiDamDes = "-";iWhatIsThis[10]='-';
    }
    else {
        // apply GyulJungTa
        if (this.levelGrade==3 || this.levelGrade==4) {
            //tmp=tmp*(gyul*(1+0.2) + (1-gyul)*1)=tmp*(1+0.2*gyul);
            this.gyulChiDam1 *= (1+0.2*gyul);
            this.gyulChiDam2 *= (1+0.2*gyul);
            if (gyul>0) this.gyulChiDamMax *= (1+0.2*1.00);
            else this.gyulChiDamMax *= (1+0+0);
        }
        // apply ChiMyungTa
        if (this.levelGrade>=5) {
            //          chi & gyul            chi only                gyul only                 normal
            //tmp=tmp*(chi*gyul*(1+0.2+0.5) + chi*(1-gyul)*(1+0.2) + (1-chi)*gyul*(1+0.5) + (1-chi)*(1-gyul)*1);
            //   =tmp*(1+0.2*gyul+0.5*chi);
            this.gyulChiDam1 *= (1+0.2*gyul+0.5*chi);
            this.gyulChiDam2 *= (1+0.2*gyul+0.5*chi);
            if      (gyul>0  && chi==0) this.gyulChiDamMax *= (1+0.2+0);
            else if (gyul==0 && chi>0 ) this.gyulChiDamMax *= (1+0+0.5);
            else if (gyul> 0 && chi>0 ) this.gyulChiDamMax *= (1+0.2+0.5);
            else this.gyulChiDamMax *= (1+0+0);
        }
        this.gyulChiDamDes="Å‘åƒ_ƒ[ƒW/”­ "+Math.floor(this.gyulChiDamMax);
        iWhatIsThis[10]="ƒ_ƒ[ƒW/•b "+Math.floor((this.gyulChiDam1+this.gyulChiDam2)/2)
                       +"<br>Å‘åƒ_ƒ[ƒW/”­ "+Math.floor(this.gyulChiDamMax)
                       +"<br><font color='red'>PK(Å‘åƒ_ƒ[ƒW): "+Math.floor(this.gyulChiDamMax/PKDamRate)+"</font>";
    }
}

//////////////////////////////////////////////////
/////       1. weapon  function              /////
//////////////////////////////////////////////////

// calculate plus value
function calPlusA(name,value,seq) {
    var result=0;
    // kai : floor , others : round , don't know why?
    if (name.charAt(0)=='s') result=Math.floor(value*(1+plusValueA[seq]/0.57)*10*10);
    else result=Math.round(value * (1+plusValueA[seq]));
    return result;
}

// calculate plus value, for diamond item
function calPlusB(name,value,seq) {
    var result=0;
    // kai : floor , others : round , don't know why?
    if (name.charAt(0)=='s') result=Math.floor(value*(1+plusValueB[seq]/0.57)*10*10);
    else result=Math.floor(value * (1+plusValueB[seq]));
    return result;
}

// calculate plus value, for R_diamond item
function calPlusC(name,value,seq) {
    var result=0;
    // kai : floor , others : round , don't know why?
    if (name.charAt(0)=='s') result=Math.floor(value*(1+plusValueC[seq]/0.748)*10*10);
    else result=Math.floor(value * (1+plusValueC[seq]));
    return result;
}

// do this when the onClick event in menu is occurred
// parameter : zweap=,zname,zmin,zmax,zupnum
function chooseWeapon(zweap,zname,zupnum) {
    myWeapon = new theWeapon(zweap,zname,zupnum);
    //if (myWeapon.isNoWeap) {doNoWeap(zname);return true;}
    updateSkillTip();   // update skill tooltip
    updateDamage();     // update screen damage information
    updateArmor2();     // call this in getArmorClass.js
    return true;
}

function canvasWeapon() {
    // note for weapon
    if (myWeapon.isNoWeap) {idCWMsg[0]="";return true;}
    var whatIsWeap = "";
    var znote = ""; var znote2="";
    // ƒtƒHƒ“ƒg‚ðƒQ[ƒ€“à‚Ì•\Ž¦‚É‡‚í‚¹‚é
    var weapHead = '<TABLE width="185" align="center" class="font9" style="background-color:#E0E7E7;font-family:‚l‚r –¾’©;">'
                 + '<tr><td>';
    var weapTail = '</td></tr></table>';
    var zzTrTdS = '<tr><td>';
    var zzTrTdE = '</td></tr>';
    //name:#FF5973,lvl:#DE969C,masuk:#009900,atk:#006699,str:#9C9B99
    //‹­‰»•i‚Ìê‡‚ÍF‚ð•ÏX
    if(myWeapon.korName.indexOf("+")==-1) {
      whatIsWeap += "<font color='#FF5973'>"+myWeapon.korName+"</font><br>";
    } else {
      whatIsWeap += "<font color='#009900'>"+myWeapon.korName+"</font><br>";
    }
    whatIsWeap += "<font color='#FF5973'>•K—vƒŒƒxƒ‹: "+myWeapon.weapLevel+"<br></font>";
    whatIsWeap += "<font color='#009900'>"
                + (myWeapon.levelGrade>=1 ? (myWeapon.masuk1dam>0 ? myWeapon.masuk1note+" "+ (myWeapon.isStaff ? Math.floor(myWeapon.masuk1dam*100)+"% ƒ_ƒEƒ“" : myWeapon.masuk1dam+" ƒAƒbƒv") +"<br>":"") : "")
                + (myWeapon.levelGrade>=2 ? (myWeapon.masuk2dam>0 ? myWeapon.masuk2note+" "+ (myWeapon.isStaff ? Math.floor(myWeapon.masuk2dam*100)+"%" : myWeapon.masuk2dam) +" ƒAƒbƒv"+"<br>":"") : "")
                + (myWeapon.levelGrade>=4 ? (myWeapon.masuk4dam>0 ? myWeapon.masuk4note+"&nbsp;&nbsp;"+myWeapon.masuk4dam +"&nbsp;&nbsp;ƒAƒbƒv"+"<br>":"")  : "")
                + (myWeapon.levelGrade>=6 ? (myWeapon.masuk6dam>0 ? myWeapon.masuk6note.substring(0,myWeapon.masuk6note.length-2)+" "+Math.floor(myWeapon.masuk6dam*100)+"%"+'&nbsp;ƒAƒbƒv'+"<br>":"")  : "")
                + (myWeapon.levelGrade>=3 ? (myWeapon.masuk3dam>0 ? myWeapon.masuk3note+" "+Math.floor(myWeapon.masuk3dam*100) +"%<br>":"")  : "")
                + (myWeapon.levelGrade>=5 ? (myWeapon.masuk5dam>0 ? myWeapon.masuk5note+" "+Math.floor(myWeapon.masuk5dam*100)+"%<br>":"")  : "");
    // special item
    if (myWeapon.spDamage>0) whatIsWeap += "“ÁŽêUŒ‚—Í&nbsp;"+myWeapon.spDamage+"&nbsp;ã¸<br>";
    if (myWeapon.spSpeed>0) 
        whatIsWeap += (myWeapon.isStaff ? "–‚–@‘¬“xã¸&nbsp;"+myWeapon.spSpeed*100+"%<br>":myWeapon.spSpeed==1?"UŒ‚‘¬“xã¸&nbsp;<br>":"");
    whatIsWeap += "</font>";

    // etc (attack speed,STR/WIS/DEX/mana usage/electricity usage/price
    //whatIsWeap += (myWeapon.isStaff ? "¸¶¹ý¼Óµµ +"+Math.floor(myWeapon.staffDam*100)+"%" : "°ø°Ý·Â: "+(Math.round(myWeapon.weapDam1)+"~"+Math.round(myWeapon.weapDam2)))+"</font><br>";
    whatIsWeap += "<font color='#006699'>";
    // below is small bug in Laghaim, handle it cafefully
    // example:Tornado rifle (compare with magic stone full up value)
    var zweap1=Math.round(myWeapon.weapDam1);var zweap2=Math.floor(myWeapon.weapDam2);
    if (zweap1>zweap2) zweap1=zweap2;
    //whatIsWeap += "°ø°Ý·Â: "+(myWeapon.isStaff ? "+"+Math.floor(myWeapon.staffDam*100)+"%" : zweap1+"~"+zweap2)+"</font><br>";
    //whatIsWeap += "°ø°Ý·Â: "+(myWeapon.isStaff ? "+"+Math.floor(myWeapon.staffDam*100)+"%" : (Math.round(myWeapon.weapDam1)+"~"+Math.round(myWeapon.weapDam2)))+"</font><br>";
    //whatIsWeap += (myWeapon.isStaff ? "Magic Dam +"+Math.floor(myWeapon.staffDam*100)+"%" : "Damage: "+(Math.round(myWeapon.weapDam1)+"~"+Math.round(myWeapon.weapDam2)))+"<br>";
    // *100 À» ÇÒ°æ¿EºÎµ¿¼Ò¼öÁ¡ ¿¬»EÌ ¸Å¿EÀÌ»óÇÏ°Ô Ç¥½ÃµÊ. *10*10 À¸·Î ÇÒ°Í.
    // ¿¹:1¸µ, *100 ½Ã 114.99999999999998, *10*10 ½Ã 115 ·Î Ç¥½ÃµÊ
    if (myWeapon.isStaff) whatIsWeap += "–‚–@UŒ‚—Í +"+Math.floor(myWeapon.staffDam*10*10)+"%"+"<br>";
    else if (myWeapon.isAxe || myWeapon.isSword) {
        if (myWeapon.isTwohand) {    // if both hand
            whatIsWeap += "—¼ŽèUŒ‚—Í: "+(Math.round(myWeapon.weapDam1t)+"`"+Math.floor(myWeapon.weapDam2t))+"<br>";
            whatIsWeap += "•ÐŽèUŒ‚—Í: "+(Math.floor(myWeapon.weapDam1o)+"`"+Math.round(myWeapon.weapDam2o))+"<br>";
        }
        else whatIsWeap += "UŒ‚—Í: "+(Math.round(myWeapon.weapDam1)+"`"+Math.round(myWeapon.weapDam2))+"<br>";
    }
    else whatIsWeap += "UŒ‚—Í: "+(Math.round(myWeapon.weapDam1)+"`"+Math.round(myWeapon.weapDam2))+"<br>";
    var zspeed=Math.round((myWeapon.atkSpeed-myWeapon.spSpeed*0.2)*100)/100;
    if (myWeapon.isStaff) whatIsWeap += "–‚–@‘¬“x "+Math.floor((myWeapon.atkSpeed+myWeapon.spSpeed)*100)+"% ã¸"+"<br>";
    else {
        switch(zspeed) {
            case 0.4: znote="”ñí‚É‘¬‚¢";break;   // possible when you have increase attack spped option in your special item
            case 0.6: znote="”ñí‚É‘¬‚¢";break;
            case 0.8: znote="‘¬‚¢";break;
            case 1.0: znote="•’Ê";break;
            case 1.2: znote="’x‚¢";break;
        }
        whatIsWeap += "UŒ‚‘¬“x: "+znote+"<br>";
    }
    whatIsWeap += (myWeapon.isAxe || myWeapon.isSword) ? (myWeapon.isTwohand ? "—¼ŽèŽ‚¿" : "•ÐŽèŽ‚¿")+"</font><br>" : "";
    whatIsWeap += "<font color='#646464'>•K—v‘Ì—Í: "+myWeapon.strLimit+"<br>";
    whatIsWeap += (myWeapon.isStaff || myWeapon.isRing) ? "•K—v’m—Í: "+myWeapon.wisLimit+"<br>" : "";
    whatIsWeap += myWeapon.isGun ? "•K—v‘f‘‚³: "+myWeapon.spdLimit+"<br>" : "";
    whatIsWeap += myWeapon.isGun ? "Á”ïƒGƒl: "+myWeapon.etc+"<br>" : "";
    whatIsWeap += myWeapon.isRing ? "Á”ïƒ}ƒi: "+myWeapon.etc+"<br>" : "";
    whatIsWeap += "‰¿Ši: "+myWeapon.itemPrice+" G";
    whatIsWeap += "</font>";
    idCWMsg[0]=weapHead+whatIsWeap+weapTail;
}

// update screen damage information
function updateDamage() {
    myWeapon.upgradeWeapon();
    canvasWeapon();
    // call genWriteIt in myPopUp.js
    var txtArrId=new Array('aSkillDamID','bSkillDamID','idCW','basicDam','aSkillDam','bSkillDam','secDam','damNote','gyulChiDam');
    var txtArr=new Array(aSkillDamNote,bSkillDamNote,myWeapon.korName,myWeapon.basicDamDes,myWeapon.aSkillDamDes,myWeapon.bSkillDamDes,myWeapon.secDamDes,myWeapon.damNote,myWeapon.gyulChiDamDes);
    for (var i=0;i<txtArrId.length;i++) genWriteIt(txtArrId[i],txtArr[i]);
    return true;
}

// layer for masuk choosing
function canvasMasuk() {
    //if (myToolTip.isTipOn) return false;
    var zzTrTd = '<tr><td>';
    var zzTd = '</td><td style="color:black">';
    var masukHead = '<TABLE width="275" height="150" class="font9" align="center" style="background-color:#E0E7E7;">';
    var masukTail = '</td></tr><tr>'
                  + '<td height="20" colspan="2">'
                  + '<BUTTON onClick="updateDamage();popOutFixed()">OK</BUTTON>';
    var whatIsMasuk = '';
    // 1:lvl 1~30, 2:31-60, 3:61-90, 4:91-120, 5:121-150, 6:151-180
    if (myWeapon.isNoWeap) whatIsMasuk='<tr><td>•Ší‚È‚µ';
    else {
        var foButton = "";
        whatIsMasuk += '<tr height="25"><td colspan="2" class="black9b">–‚Î</td></tr><tr><td>';
        if (myWeapon.levelGrade>=1) {
            whatIsMasuk += myWeapon.masuk1note+(myWeapon.isStaff?'ƒ_ƒEƒ“':'')+zzTd
                         + '<input type="radio" name="masuk1" value="0" onClick="applyMasuk(this)">0'
                         + '<input type="radio" name="masuk1" value="1" onClick="applyMasuk(this)">1'
                         + '<input type="radio" name="masuk1" value="2" onClick="applyMasuk(this)">2'
                         + '<input type="radio" name="masuk1" value="3" onClick="applyMasuk(this)">3';
            foButton += 'masuk1(3).checked = true;myWeapon.masuk1=3;myWeapon.masuk1dam=getMasukDam(1,myWeapon.masuk1);';
            if (myWeapon.levelGrade>=2) {
                whatIsMasuk += '</td></tr>'+zzTrTd+myWeapon.masuk2note+(myWeapon.isStaff?'ƒAƒbƒv':'')+zzTd
                             + '<input type="radio" name="masuk2" value="0" onClick="applyMasuk(this)">0'
                             + '<input type="radio" name="masuk2" value="1" onClick="applyMasuk(this)">1'
                             + '<input type="radio" name="masuk2" value="2" onClick="applyMasuk(this)">2'
                             + '<input type="radio" name="masuk2" value="3" onClick="applyMasuk(this)">3';
                foButton += 'masuk2(3).checked = true;myWeapon.masuk2=3;myWeapon.masuk2dam=getMasukDam(2,myWeapon.masuk2);';
                if (myWeapon.levelGrade>=3) {
                    whatIsMasuk += '</td></tr>'+zzTrTd+myWeapon.masuk3note+zzTd
                                 + '<input type="radio" name="masuk3" value="0" onClick="applyMasuk(this)">0'
                                 + '<input type="radio" name="masuk3" value="1" onClick="applyMasuk(this)">1'
                                 + '<input type="radio" name="masuk3" value="2" onClick="applyMasuk(this)">2'
                                 + '<input type="radio" name="masuk3" value="3" onClick="applyMasuk(this)">3';
                    foButton += 'masuk3(3).checked = true;myWeapon.masuk3=3;myWeapon.masuk3dam=getMasukDam(3,myWeapon.masuk3);';
                    if (myWeapon.levelGrade>=4) {
                        whatIsMasuk += '</td></tr>'+zzTrTd+myWeapon.masuk4note+zzTd
                                     + '<input type="radio" name="masuk4" value="0" onClick="applyMasuk(this)">0'
                                     + '<input type="radio" name="masuk4" value="1" onClick="applyMasuk(this)">1'
                                     + '<input type="radio" name="masuk4" value="2" onClick="applyMasuk(this)">2'
                                     + '<input type="radio" name="masuk4" value="3" onClick="applyMasuk(this)">3';
                        foButton += 'masuk4(3).checked = true;myWeapon.masuk4=3;myWeapon.masuk4dam=getMasukDam(4,myWeapon.masuk4);';
                        if (myWeapon.levelGrade>=5) {
                            whatIsMasuk += '</td></tr>'+zzTrTd+myWeapon.masuk5note+zzTd
                                         + '<input type="radio" name="masuk5" value="0" onClick="applyMasuk(this)">0'
                                         + '<input type="radio" name="masuk5" value="1" onClick="applyMasuk(this)">1'
                                         + '<input type="radio" name="masuk5" value="2" onClick="applyMasuk(this)">2'
                                         + '<input type="radio" name="masuk5" value="3" onClick="applyMasuk(this)">3';
                            foButton += 'masuk5(3).checked = true;myWeapon.masuk5=3;myWeapon.masuk5dam=getMasukDam(5,myWeapon.masuk5);';
                            if (myWeapon.levelGrade>=6) {
                                whatIsMasuk += '</td></tr>'+zzTrTd+myWeapon.masuk6note+zzTd
                                             + '<input type="radio" name="masuk6" value="0" onClick="applyMasuk(this)">0'
                                             + '<input type="radio" name="masuk6" value="1" onClick="applyMasuk(this)">1'
                                             + '<input type="radio" name="masuk6" value="2" onClick="applyMasuk(this)">2'
                                             + '<input type="radio" name="masuk6" value="3" onClick="applyMasuk(this)">3<br>';
                                foButton += 'masuk6(3).checked = true;myWeapon.masuk6=3;myWeapon.masuk6dam=getMasukDam(6,myWeapon.masuk6);';
                            }
                        }
                    }
                }
            }
            masukTail += '&nbsp;&nbsp;&nbsp;&nbsp;'
                      +  '<input type="BUTTON" class="BUTTON1" onClick="' + foButton + '" value="ƒtƒ‹ƒIƒvƒVƒ‡ƒ“">';

        }
        else whatIsMasuk += '<br>–‚Î‚Í•t‰Á‚Å‚«‚Ü‚¹‚ñB<br>';
    }
    masukTail += '</td></tr></table>';
    idcanvasMasukMsg[0]=masukHead+whatIsMasuk+masukTail;
    popUpMsg(idcanvasMasukMsg);
    // read the myWeapon.masuk value and display it
    var zlevelGrade=myWeapon.levelGrade;
    zlevelGrade=zlevelGrade==7?6:zlevelGrade;   // ´ÙÀÌ¾Æ±Þ¹«±âÀÇ °æ¿E¸¶¼®Àº ±âÁ¸°Í°Eµ¿ÀÏÇÏ°Ô
    for (var x=1;x<=zlevelGrade;x++) {
        var zMasuk = eval('myWeapon.masuk'+x);
        var zzz = 'document.all.masuk'+x+'['+zMasuk+'].checked=true';
        eval(zzz);
    }
}

// apply masuk if selected
function applyMasuk(obj) {
    var value=parseInt(obj.value);
    switch(obj.name) {
        case 'masuk1' : myWeapon.masuk1=value;myWeapon.masuk1dam=getMasukDam(1,myWeapon.masuk1);break;
        case 'masuk2' : myWeapon.masuk2=value;myWeapon.masuk2dam=getMasukDam(2,myWeapon.masuk2);break;
        case 'masuk3' : myWeapon.masuk3=value;myWeapon.masuk3dam=getMasukDam(3,myWeapon.masuk3);break;
        case 'masuk4' : myWeapon.masuk4=value;myWeapon.masuk4dam=getMasukDam(4,myWeapon.masuk4);break;
        case 'masuk5' : myWeapon.masuk5=value;myWeapon.masuk5dam=getMasukDam(5,myWeapon.masuk5);break;
        case 'masuk6' : myWeapon.masuk6=value;myWeapon.masuk6dam=getMasukDam(6,myWeapon.masuk6);break;
    }
}

function getMasukDam(seq,value) {
    var masDam = 0;
    if (value==0) masDam=0;
    else {
        var num=(seq-1)*3+value;
        masDam=iMASUK[num];
    }
    return masDam;
}

// layer for special item
function canvasSpecial() {
    //if (myToolTip.isTipOn) return false;
    var zzTrTd = '<tr><td>';
    var zzTd = '</td><td style="color:black">';
    var spHead = '<TABLE width="250" height="150" class="font9" align="center" style="background-color:#E0E7E7;">';
    var spTail = '<tr><td height="20" colspan="2">'
               + '<BUTTON onClick="updateDamage();popOutFixed()">OK</BUTTON>'
               + '</td></tr></table>';
    var whatIsSp = '';
    if (myWeapon.isNoWeap) whatIsSp='<tr><td colspan="2">•Ší‚È‚µ</td></tr>';
    else {
        whatIsSp += '<tr height="25"><td colspan="2" class="black9b">SP•Ší</td></tr>'
                  + '<tr><td width="100">“ÁŽêUŒ‚—Í</td>'
                  + '<td class="black9"><INPUT TYPE="text" NAME="idSpDamage" SIZE="2" MAXLENGTH="2" onBlur="applySpecial(this)" class="tdtext">'
                  + '&nbsp;('+myWeapon.spDamageMin+'`'+myWeapon.spDamageMax+')&nbsp;</td></tr>'
        if (myChar.engRace=='Kairipton') {
            whatIsSp += '<tr><td>–‚–@‘¬“xã¸</td>'
                      + '<td class="black9"><INPUT TYPE="text" NAME="idSpSpeed" SIZE="2" MAXLENGTH="2" onBlur="applySpecial(this)" class="tdtext"> (0`10%)</td></tr>';
        }
        else {
            whatIsSp += '<tr><td>UŒ‚‘¬“xã¸</td><td class="black9">'
                      + '<input type="radio" name="idSpSpeed" value="1" onClick="applySpecial(this)">‘¬“xã¸'
                      + '<input type="radio" name="idSpSpeed" value="0" onClick="applySpecial(this)">ƒm[ƒ}ƒ‹'
                      +'</td></tr>';
        }
    }
    idcanvasSpecialMsg[0]=spHead+whatIsSp+spTail;
    popUpMsg(idcanvasSpecialMsg);
    // read the myWeapon.masuk value and display it
    if (!myWeapon.isNoWeap) {
        document.getElementById('idSpDamage').value=myWeapon.spDamage;
        if (myChar.engRace=='Kairipton') {document.getElementById('idSpSpeed').value=myWeapon.spSpeed*100;}
        else {
            var zSp=eval('myWeapon.spSpeed');
            if (zSp==0) document.all.idSpSpeed[1].checked=true;
            else document.all.idSpSpeed[0].checked=true;
        }
    }
}

// update myweapon special property
function applySpecial(obj) {
    if (obj.name=='idSpDamage') {
        var result=isNumber2(obj.value);
        if (result==-1) {obj.focus();obj.select();return false;}
        if (result<myWeapon.spDamageMin || result>myWeapon.spDamageMax) {
            alert("•s³‚È’l‚Å‚·");obj.focus();obj.select();return false;
        }
        myWeapon.spDamage=result;
    }
    else {  // if idSpSpeed
        if (myChar.engRace=='Kairipton') {
            if (obj.name=='idSpSpeed') {
                var result=isNumber2(obj.value)/100;
                if (result==-0.01) {obj.focus();obj.select();return false;}
                if (result<myWeapon.spSpeedMin || result>myWeapon.spSpeedMax) {
                    alert("•s³‚È’l‚Å‚·");obj.focus();obj.select();return false;
                }
                myWeapon.spSpeed=result;
            }
        }
        else {
            if (obj.name=='idSpSpeed') myWeapon.spSpeed=obj.value;
        }
    }
}

// advise msg window for GyulChiDamDes
function whatIsThis(obj) {
    var msgArr=new Array("",0,2,0,0,0);
    var msg='';
    var msgHead = '<table width="230"><tr><td class="tipText">';
    var msgTail = '</td></tr></table>';
    //var zstr="msg="+obj.id+"Msg[0]";eval(zstr);
    switch(obj.id) {
        // iWhatIsThis : "basicDam","aSkillDam","bSkillDam","secDam","gyulChiDam"
        //               "totalAC","specialAC (cold/stone/bolt/volcanic)"
        case "basicDamID"  : msg=iWhatIsThis[1];break;
        case "basicDam"    : msg=iWhatIsThis[6];break;
        case "aSkillDamID" : msg=iWhatIsThis[2];break;
        case "aSkillDam"   : msg=iWhatIsThis[7];break;
        case "bSkillDamID" : msg=iWhatIsThis[3];break;
        case "bSkillDam"   : msg=iWhatIsThis[8];break;
        case "secDamID"    : msg=iWhatIsThis[4];break;
        case "secDam"      : msg=iWhatIsThis[9];break;
        case "gyulChiDamID": msg=iWhatIsThis[5];break;
        case "gyulChiDam"  : msg=iWhatIsThis[10];break;
        case "totalACID"   : msg=iWhatIsThis[11];break;
        case "totalACIDz"  : msg=iWhatIsThis[12];break;
        case "specialACID" : msg=iWhatIsThis[13];break;
        case "specialACIDz": msg=iWhatIsThis[14];break;
        default: msg='unknown';break;
    }
    // when haveing no content, discard "width"
    if (msg=='') msgHead='<table><tr><td class="tipText">';
    msgArr[0]=msgHead+msg+msgTail;popUpMsg(msgArr);
    return;
}

