// (C) 2004 halfcolor by Eicha
// 初のオリジナルプログラム（＾＾；
//GOLDさん以外、許可無く転載や改変はしないで下さい。

function BMIcalc()
{
  redone = document.bmiform.text1.value;
   redtwo = document.bmiform.text2.value;
 
greenone = document.bmiform.text5.value;
greentwo = document.bmiform.text6.value;

blueone = document.bmiform.text7.value;
bluetwo = document.bmiform.text8.value;

kazu = document.bmiform.text13.value;//グラデの数読み込み
gradation = parseInt(kazu)+1;//計算式はグラデの数+1を代入

//色1
if(redone < 16){hidarir = "0"+parseInt(redone).toString(16);}
if(redone >= 16){hidarir = parseInt(redone).toString(16);}
if(greenone < 16){hidarig = "0"+parseInt(greenone).toString(16);}
if(greenone >= 16){hidarig = parseInt(greenone).toString(16);}
if(blueone < 16){hidarib = "0"+parseInt(blueone).toString(16);}
if(blueone >= 16){hidarib = parseInt(blueone).toString(16);}

irohidari = hidarir+hidarig+hidarib;
document.all('t10').style.backgroundColor=irohidari;
//色2
if(redtwo < 16){hidarir2 = "0"+parseInt(redtwo).toString(16);}
if(redtwo >= 16){hidarir2 = parseInt(redtwo).toString(16);}
if(greentwo < 16){hidarig2 = "0"+parseInt(greentwo).toString(16);}
if(greentwo >= 16){hidarig2 = parseInt(greentwo).toString(16);}
if(bluetwo < 16){hidarib2 = "0"+parseInt(bluetwo).toString(16);}
if(bluetwo >= 16){hidarib2 = parseInt(bluetwo).toString(16);}

irohidari2 = hidarir2+hidarig2+hidarib2;
document.all('t11').style.backgroundColor=irohidari2;


 
if(parseInt(redone) > parseInt(redtwo)){rsa = hred = redone-(redone-redtwo)/parseInt(gradation);}
  if(parseInt(redone) < parseInt(redtwo)){rsa = hred = (redtwo-redone)/parseInt(gradation)+parseInt(redone);}
 if(parseInt(redone) == parseInt(redtwo)){rsa = hred = parseInt(redone);}

 if(parseInt(greenone) > parseInt(greentwo)){gsa = hgreen = parseInt(greenone)-(greenone-greentwo)/parseInt(gradation);}
  if(parseInt(greenone) < parseInt(greentwo)){gsa = hgreen = (greentwo-greenone)/parseInt(gradation)+parseInt(greenone);}
if(parseInt(greenone) == parseInt(greentwo)){gsa = hgreen = parseInt(greenone);}

 if(parseInt(blueone) > parseInt(bluetwo)){bsa = hblue = parseInt(blueone)-(blueone-bluetwo)/parseInt(gradation);}
  if(parseInt(blueone) < parseInt(bluetwo)){bsa = hblue = (bluetwo-blueone)/parseInt(gradation)+parseInt(blueone);}
if(parseInt(blueone) == parseInt(bluetwo)){bsa = hblue = parseInt(blueone);}



 document.bmiform.text3.value = parseInt(hred);
 document.bmiform.text4.value = parseInt(hgreen);
document.bmiform.text9.value = parseInt(hblue);


if(parseInt(redone) == parseInt(redtwo)){document.bmiform.text21.value = iror1= parseInt(redone);}
else if(parseInt(kazu) >= 2){document.bmiform.text21.value = iror1 = parseInt((hred - redone)+hred);}
if(parseInt(greenone) == parseInt(greentwo)){document.bmiform.text22.value = irog1 = parseInt(greenone);}
else if(parseInt(kazu) >= 2){document.bmiform.text22.value = irog1  = parseInt((hgreen - greenone)+hgreen);}
if(parseInt(blueone) == parseInt(bluetwo)){document.bmiform.text23.value = irob1  = parseInt(blueone);}
else if(parseInt(kazu) >= 2){document.bmiform.text23.value = irob1  = parseInt((hblue - blueone)+hblue);}



if(parseInt(redone) == parseInt(redtwo)){document.bmiform.text31.value =iror2 = parseInt(redone);}
else if(parseInt(kazu) >= 3){document.bmiform.text31.value = iror2 = parseInt((hred - redone)*2+hred);}
if(parseInt(greenone) == parseInt(greentwo)){document.bmiform.text32.value = irog2  = parseInt(greenone);}
else if(parseInt(kazu) >= 3){document.bmiform.text32.value = irog2  = parseInt((hgreen - greenone)*2+hgreen);}
if(parseInt(blueone) == parseInt(bluetwo)){document.bmiform.text33.value = irob2  = parseInt(blueone);}
else if(parseInt(kazu) >= 3){document.bmiform.text33.value = irob2  = parseInt((hblue - blueone)*2+hblue);}

if(parseInt(redone) == parseInt(redtwo)){document.bmiform.text41.value = iror3  = parseInt(redone);}
else if(parseInt(kazu) >= 4){document.bmiform.text41.value = iror3  = parseInt((hred - redone)*3+hred);}
if(parseInt(greenone) == parseInt(greentwo)){document.bmiform.text42.value = irog3  = parseInt(greenone);}
else if(parseInt(kazu) >= 4){document.bmiform.text42.value = irog3  = parseInt((hgreen - greenone)*3+hgreen);}
if(parseInt(blueone) == parseInt(bluetwo)){document.bmiform.text43.value = irob3  = parseInt(blueone);}
else if(parseInt(kazu) >= 4){document.bmiform.text43.value = irob3  = parseInt((hblue - blueone)*3+hblue);}

if(parseInt(redone) == parseInt(redtwo)){document.bmiform.text51.value = iror4 = parseInt(redone);}
else if(parseInt(kazu) >= 5){document.bmiform.text51.value = iror4  = parseInt((hred - redone)*4+hred);}
if(parseInt(greenone) == parseInt(greentwo)){document.bmiform.text52.value = irog4 = parseInt(greenone);}
else if(parseInt(kazu) >= 5){document.bmiform.text52.value  = irog4 = parseInt((hgreen - greenone)*4+hgreen);}
if(parseInt(blueone) == parseInt(bluetwo)){document.bmiform.text53.value  = irob4 = parseInt(blueone);}
else if(parseInt(kazu) >= 5){document.bmiform.text53.value  = irob4 = parseInt((hblue - blueone)*4+hblue);}

if(parseInt(redone) == parseInt(redtwo)){document.bmiform.text61.value = iror5 = parseInt(redone);}
else if(parseInt(kazu) >= 6){document.bmiform.text61.value = iror5 = parseInt((hred - redone)*5+hred);}
if(parseInt(greenone) == parseInt(greentwo)){document.bmiform.text62.value  = irog5 = parseInt(greenone);}
else if(parseInt(kazu) >= 6){document.bmiform.text62.value = irog5  = parseInt((hgreen - greenone)*5+hgreen);}
if(parseInt(blueone) == parseInt(bluetwo)){document.bmiform.text63.value  = irob5 = parseInt(blueone);}
else if(parseInt(kazu) >= 6){document.bmiform.text63.value  = irob5 = parseInt((hblue - blueone)*5+hblue);}

if(parseInt(redone) == parseInt(redtwo)){document.bmiform.text71.value = iror6 = parseInt(redone);}
else if(parseInt(kazu) >= 7){document.bmiform.text71.value = iror6 = parseInt((hred - redone)*6+hred);}
if(parseInt(greenone) == parseInt(greentwo)){document.bmiform.text72.value = irog6 = parseInt(greenone);}
else if(parseInt(kazu) >= 7){document.bmiform.text72.value = irog6 = parseInt((hgreen - greenone)*6+hgreen);}
if(parseInt(blueone) == parseInt(bluetwo)){document.bmiform.text73.value = irob6 = parseInt(blueone);}
else if(parseInt(kazu) >= 7){document.bmiform.text73.value = irob6 = parseInt((hblue - blueone)*6+hblue);}

if(parseInt(redone) == parseInt(redtwo)){document.bmiform.text81.value = iror7 = parseInt(redone);}
else if(parseInt(kazu) >= 8){document.bmiform.text81.value = iror7 = parseInt((hred - redone)*7+hred);}
if(parseInt(greenone) == parseInt(greentwo)){document.bmiform.text82.value = irog7 = parseInt(greenone);}
else if(parseInt(kazu) >= 8){document.bmiform.text82.value = irog7 = parseInt((hgreen - greenone)*7+hgreen);}
if(parseInt(blueone) == parseInt(bluetwo)){document.bmiform.text83.value = irob7 = parseInt(blueone);}
else if(parseInt(kazu) >= 8){document.bmiform.text83.value = irob7 = parseInt((hblue - blueone)*7+hblue);}

if(parseInt(redone) == parseInt(redtwo)){document.bmiform.text91.value = iror8 = parseInt(redone);}
else if(parseInt(kazu) >= 9){document.bmiform.text91.value = iror8 = parseInt((hred - redone)*8+hred);}
if(parseInt(greenone) == parseInt(greentwo)){document.bmiform.text92.value = irog8 = parseInt(greenone);}
else if(parseInt(kazu) >= 9){document.bmiform.text92.value = irog8 = parseInt((hgreen - greenone)*8+hgreen);}
if(parseInt(blueone) == parseInt(bluetwo)){document.bmiform.text93.value = irob8 = parseInt(blueone);}
else if(parseInt(kazu) >= 9){document.bmiform.text93.value = irob8 = parseInt((hblue - blueone)*8+hblue);}

if(parseInt(redone) == parseInt(redtwo)){document.bmiform.text101.value = iror9 = parseInt(redone);}
else if(parseInt(kazu) >= 10){document.bmiform.text101.value = iror9 = parseInt((hred - redone)*9+hred);}
if(parseInt(greenone) == parseInt(greentwo)){document.bmiform.text102.value = irog9 = parseInt(greenone);}
else if(parseInt(kazu) >= 10){document.bmiform.text102.value = irog9 = parseInt((hgreen - greenone)*9+hgreen);}
if(parseInt(blueone) == parseInt(bluetwo)){document.bmiform.text103.value = irob9 = parseInt(blueone);}
else if(parseInt(kazu) >= 10){document.bmiform.text103.value = irob9 = parseInt((hblue - blueone)*9+hblue);}



if(rsa < 16){document.bmiform.text10.value = "0"+parseInt(hred).toString(16);}
if(rsa >= 16){document.bmiform.text10.value = parseInt(hred).toString(16);}
if(gsa < 16){document.bmiform.text11.value = "0"+parseInt(hgreen).toString(16);}
if(gsa >= 16){document.bmiform.text11.value = parseInt(hgreen).toString(16);}
if(bsa < 16){document.bmiform.text12.value = "0"+parseInt(hblue).toString(16);}
if(bsa >= 16){document.bmiform.text12.value = parseInt(hblue).toString(16);}



if(rsa < 16){iror = "0"+parseInt(hred).toString(16);}
if(rsa >= 16){iror = parseInt(hred).toString(16);}
if(gsa < 16){irog = "0"+parseInt(hgreen).toString(16);}
if(gsa >= 16){irog = parseInt(hgreen).toString(16);}
if(bsa < 16){irob = "0"+parseInt(hblue).toString(16);}
if(bsa >= 16){irob = parseInt(hblue).toString(16);}

iro = iror+irog+irob;
document.all('t0').style.backgroundColor=iro;

if(iror1 < 16){document.bmiform.text1000.value = iror1 = "0"+parseInt(iror1).toString(16);}
if(iror1 >= 16){document.bmiform.text1000.value = iror1 = parseInt(iror1).toString(16);}
if(irog1 < 16){document.bmiform.text1001.value = irog1 = "0"+parseInt(irog1).toString(16);}
if(irog1 >= 16){document.bmiform.text1001.value = irog1 = parseInt(irog1).toString(16);}
if(irob1 < 16){document.bmiform.text1002.value = irob1 = "0"+parseInt(irob1).toString(16);}
if(irob1 >= 16){document.bmiform.text1002.value = irob1 = parseInt(irob1).toString(16);}

iro1 = iror1+irog1+irob1;
document.all('t1').style.backgroundColor=iro1;

if(iror2 < 16){document.bmiform.text1010.value = iror2 = "0"+parseInt(iror2).toString(16);}
if(iror2 >= 16){document.bmiform.text1010.value = iror2 = parseInt(iror2).toString(16);}
if(irog2 < 16){document.bmiform.text1011.value = irog2 = "0"+parseInt(irog2).toString(16);}
if(irog2 >= 16){document.bmiform.text1011.value = irog2 = parseInt(irog2).toString(16);}
if(irob2 < 16){document.bmiform.text1012.value = irob2 = "0"+parseInt(irob2).toString(16);}
if(irob2 >= 16){document.bmiform.text1012.value = irob2 = parseInt(irob2).toString(16);}

//
iro2 = iror2+irog2+irob2;
document.all('t2').style.backgroundColor=iro2;

if(iror3 < 16){document.bmiform.text1020.value = iror3 = "0"+parseInt(iror3).toString(16);}
if(iror3 >= 16){document.bmiform.text1020.value = iror3 = parseInt(iror3).toString(16);}
if(irog3 < 16){document.bmiform.text1021.value = irog3 = "0"+parseInt(irog3).toString(16);}
if(irog3 >= 16){document.bmiform.text1021.value = irog3 = parseInt(irog3).toString(16);}
if(irob3 < 16){document.bmiform.text1022.value = irob3 = "0"+parseInt(irob3).toString(16);}
if(irob3 >= 16){document.bmiform.text1022.value = irob3 = parseInt(irob3).toString(16);}

iro3 = iror3+irog3+irob3;
document.all('t3').style.backgroundColor=iro3;

if(iror4 < 16){document.bmiform.text1030.value = iror4 = "0"+parseInt(iror4).toString(16);}
if(iror4 >= 16){document.bmiform.text1030.value = iror4 = parseInt(iror4).toString(16);}
if(irog4 < 16){document.bmiform.text1031.value = irog4 = "0"+parseInt(irog4).toString(16);}
if(irog4 >= 16){document.bmiform.text1031.value = irog4 = parseInt(irog4).toString(16);}
if(irob4 < 16){document.bmiform.text1032.value = irob4 = "0"+parseInt(irob4).toString(16);}
if(irob4 >= 16){document.bmiform.text1032.value = irob4 = parseInt(irob4).toString(16);}

iro4 = iror4+irog4+irob4;
document.all('t4').style.backgroundColor=iro4;

if(iror5 < 16){document.bmiform.text1040.value = iror5 = "0"+parseInt(iror5).toString(16);}
if(iror5 >= 16){document.bmiform.text1040.value = iror5 = parseInt(iror5).toString(16);}
if(irog5 < 16){document.bmiform.text1041.value = irog5 = "0"+parseInt(irog5).toString(16);}
if(irog5 >= 16){document.bmiform.text1041.value = irog5 = parseInt(irog5).toString(16);}
if(irob5 < 16){document.bmiform.text1042.value = irob5 = "0"+parseInt(irob5).toString(16);}
if(irob5 >= 16){document.bmiform.text1042.value = irob5 = parseInt(irob5).toString(16);}

iro5 = iror5+irog5+irob5;
document.all('t5').style.backgroundColor=iro5;

if(iror6 < 16){document.bmiform.text1050.value = iror6 = "0"+parseInt(iror6).toString(16);}
if(iror6 >= 16){document.bmiform.text1050.value = iror6 = parseInt(iror6).toString(16);}
if(irog6 < 16){document.bmiform.text1051.value = irog6 = "0"+parseInt(irog6).toString(16);}
if(irog6 >= 16){document.bmiform.text1051.value = irog6 = parseInt(irog6).toString(16);}
if(irob6 < 16){document.bmiform.text1052.value = irob6 = "0"+parseInt(irob6).toString(16);}
if(irob6 >= 16){document.bmiform.text1052.value = irob6 = parseInt(irob6).toString(16);}

iro6 = iror6+irog6+irob6;
document.all('t6').style.backgroundColor=iro6;

if(iror7 < 16){document.bmiform.text1060.value = iror7 = "0"+parseInt(iror7).toString(16);}
if(iror7 >= 16){document.bmiform.text1060.value = iror7 = parseInt(iror7).toString(16);}
if(irog7 < 16){document.bmiform.text1061.value = irog7 = "0"+parseInt(irog7).toString(16);}
if(irog7 >= 16){document.bmiform.text1061.value = irog7 = parseInt(irog7).toString(16);}
if(irob7 < 16){document.bmiform.text1062.value = irob7 = "0"+parseInt(irob7).toString(16);}
if(irob7 >= 16){document.bmiform.text1062.value = irob7 = parseInt(irob7).toString(16);}

iro7 = iror7+irog7+irob7;
document.all('t7').style.backgroundColor=iro7;

if(iror8 < 16){document.bmiform.text1070.value = iror8 = "0"+parseInt(iror8).toString(16);}
if(iror8 >= 16){document.bmiform.text1070.value = iror8 = parseInt(iror8).toString(16);}
if(irog8 < 16){document.bmiform.text1071.value = irog8 = "0"+parseInt(irog8).toString(16);}
if(irog8 >= 16){document.bmiform.text1071.value = irog8 = parseInt(irog8).toString(16);}
if(irob8 < 16){document.bmiform.text1072.value = irob8 = "0"+parseInt(irob8).toString(16);}
if(irob8 >= 16){document.bmiform.text1072.value = irob8 = parseInt(irob8).toString(16);}

iro8 = iror8+irog8+irob8;
document.all('t8').style.backgroundColor=iro8;

if(iror9 < 16){document.bmiform.text1080.value = iror9 = "0"+parseInt(iror9).toString(16);}
if(iror9 >= 16){document.bmiform.text1080.value = iror9 = parseInt(iror9).toString(16);}
if(irog9 < 16){document.bmiform.text1081.value = irog9 = "0"+parseInt(irog9).toString(16);}
if(irog9 >= 16){document.bmiform.text1081.value = irog9 = parseInt(irog9).toString(16);}
if(irob9 < 16){document.bmiform.text1082.value = irob9 = "0"+parseInt(irob9).toString(16);}
if(irob9 >= 16){document.bmiform.text1082.value = irob9 = parseInt(irob9).toString(16);}

iro9 = iror9+irog9+irob9;
document.all('t9').style.backgroundColor=iro9;



}

