// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}

function bmi(){
  var weight = document.forms[0].examination_information_weight.value;
  var height = document.forms[0].examination_information_height.value;

  var bmi = weight/height/height *10000;
  bmi  = (bmi  * 100);
  bmi  = Math.round(bmi);
  bmi  = (bmi  / 100);

  document.forms[0].examination_information_bmi.value = bmi;
}

function man_bmi(){
  var weight = document.forms[0].weight.value;
  var height = document.forms[0].height.value;

  var bmi = weight/height/height *10000;
  bmi  = (bmi  * 100);
  bmi  = Math.round(bmi);
  bmi  = (bmi  / 100);

  document.forms[0].bmi.value = bmi;
}

function LH(){
  var ldl = document.forms[0].ldl.value;
  var hdl = document.forms[0].hdl.value;

  var lh =(ldl / hdl).toFixed(3);

  document.forms[0].lh.value = lh;
}


function bmi_detail(){
  alert("やせ       ～18\n" +
      "標準       18～25\n" +
      "肥満1      25～30\n" +
      "肥満2      30～35\n" +
      "肥満3      35～40\n" +
      "肥満4       40～\n")

}

function bp_detail(){
  alert("                  最高   最低\n" +
      "至適              ～120  ～80\n" +
      "正常              ～130  ～85\n" +
      "正常高値        ～140  ～90\n" +
      "I度高血圧       ～160  ～100\n" +
      "Ⅱ度高血圧     ～180  ～110\n" +
      "Ⅲ度高血圧      180～  110～\n")

}

function hem_detail(){
  alert("ヘモグロビンのこと\n" +
      "男性:14～18g/dL\n"+
      "女性:11～15g/dL\n")

}

function rbc_detail(){
  alert("男性:440～560(万/μL) \n"+
      "女性:380～520(万/μL) \n")

}

function got_detail(){
  alert("適正範囲 10 ～40 UI/ L")

}

function gpt_detail(){
  alert("適正範囲 5～40 UI/ L")

}

function gamma_detail(){
  alert("男性：8～61UI/L \n" +
      "女性：5～24UI/L \n" +
      "小児：0～20UI/L \n" +
      "新生児：50～150UI/L \n")

}

function t_cho_detail(){
  alert("適正範囲 120～220mg/dL")

}

function tri_detail(){
  alert("適正範囲 30～150mg/dL")

}

function ldl_detail(){
  alert("適正範囲 ～140mg/dL")

}

function hdl_detail(){
  alert("適正範囲 40～60mg/dL")

}

function glu_detail(){
  alert("空腹時血糖の事 \n" +
      "適正範囲 60～110mg/dL")

}

function hba1c_detail(){
  alert("ヘモグロビンA1cの事 \n" +
      "適正範囲 4.3～5.8 ％")

}
function my_bmi(){
/*
  var weight = document.forms[0].status_weight.value;
  var height = document.forms[0].profile_height.value;
 */
/*
  var weight = document.getElementById("status_weight").value;
  var height = document.getElementById("profile_height").value;

*/
  var weight = $F("status_weight");
  var height = $F("profile_height");

  var bmi = weight/height/height *10000;
  bmi  = (bmi * 100);
  bmi  = Math.round(bmi);
  bmi  = (bmi / 100);

  $("status_bmi").value = bmi;
}
