function ClearForm(form){form.weight.value="";form.height.value="";form.bmi.value="";form.my_comment.value="";form.idweight.value="";form.obesity.value="";form.age.value="";form.cal.value="";form.exe.value="";form.idweight2.value="";form.obesity2.value=""}function bmi(weight,height){bmindx=weight/eval(height*height);return bmindx}function idweight(height){idw=22*eval(height*height);return idw}function doPrint(){var pwin=window.open("","print");var printStr=window.document.getElementById("div_Print").innerHTML;pwin.document.body.innerHTML=printStr;pwin.print();pwin.close()}function checkform(form){if(form.weight.value==null||form.weight.value.length==0||form.height.value==null||form.height.value.length==0){alert("\身高、体重必须输入");return false}else if(parseFloat(form.height.value)<=0||parseFloat(form.height.value)>=500||parseFloat(form.weight.value)<=0||parseFloat(form.weight.value)>=500){alert("\n哎、怎么会！？　请再检查一下你所输入数字");ClearForm(form);return false}return true}function computeform(form){if(checkform(form)){yourbmi=Math.round(bmi(form.weight.value,form.height.value/100));form.bmi.value=yourbmi;youridweight=idweight(form.height.value/100);form.idweight.value=Math.round(youridweight);form.obesity.value=Math.round((form.weight.value/youridweight-1)*100);youridweight2=(form.height.value-100)*0.9;form.idweight2.value=Math.round(youridweight2);form.obesity2.value=Math.round((form.weight.value/youridweight2-1)*100);if(form.age.value<=30){nutidx=6}else if(form.age.value>30&&form.age.value<=40){nutidx=5}else if(form.age.value>40&&form.age.value<=50){nutidx=4}else if(form.age.value>50&&form.age.value<=60){nutidx=3}else if(form.age.value>60&&form.age.value<=70){nutidx=2}else if(form.age.value>70&&form.age.value<=80){nutidx=1}else if(form.age.value>=80){nutidx=0}if(form.exe.value&&form.sex.value){if(form.sex.value=="M"){nutidx*=1.5}nutidx+=parseFloat(form.exe.value);nutidx+=20;form.cal.value=Math.round(nutidx*youridweight)}else{form.cal.value="???"}if(yourbmi>40){form.my_comment.value="你已肥到了绝望的程度！　你需要去看医生。"}else if(yourbmi>30&&yourbmi<=40){form.my_comment.value="肥得太厉害了！　不认真减肥是不行的哦。"}else if(yourbmi>27&&yourbmi<=30){form.my_comment.value="太胖了！　趁现在还为时不晚，赶快加油减肥哦。"}else if(yourbmi>23&&yourbmi<=27){form.my_comment.value="有些偏胖！　贪食及缺少运动量都是不好的习惯哦。"}else if(yourbmi>=21&&yourbmi<=23){form.my_comment.value="太棒了！　请保持下去。"}else if(yourbmi>=18&&yourbmi<21){form.my_comment.value="有些偏瘦！　你得好好吃饭？"}else if(yourbmi>=16&&yourbmi<18){form.my_comment.value="太瘦了！　你得补充营养。"}else if(yourbmi<16){form.my_comment.value="营养失调！　如果不是得了重病那还好说 ^_^"}}return}