var currentTab = 1; var enableAlert = 0; function myalert(string) { if(enableAlert==1) { alert(string); } } function stripAlphaChars(pstrSource) { var m_strOut = new String(pstrSource); m_strOut = m_strOut.replace(/[^0-9]/g, ''); return m_strOut; } function checkInput(type) { if(type==1) { document.getElementById('sbp').value = stripAlphaChars(document.getElementById('sbp').value); } else { document.getElementById('dbp').value = stripAlphaChars(document.getElementById('dbp').value); } } function checkVariables(mysbp, mydbp) { var errorType = 0; if(isNaN(mysbp)==false) { if(mysbp>200) { document.getElementById('sbp').value = 200; mysbp = 200; //myalert("SBP value cannot be greater than 200"); //errorType = 1; } else if(mysbp<0) { document.getElementById('sbp').value = 0; mysbp = 0; //myalert("SBP value cannot be less than 0"); //errorType = 1; } } else { mysbp = 0; document.getElementById('sbp').value = 0; myalert("Please enter a SBP value"); errorType = 1; } if(isNaN(mydbp)==false) { if(mydbp>200) { document.getElementById('dbp').value = 200; mydbp = 200; //myalert("DBP value cannot be greater than 200"); //errorType = 1; } else if(mydbp<0) { mydbp = 0; document.getElementById('dbp').value = 0; //myalert("DBP value cannot be less than 0"); //errorType = 1; } } else { mydbp = 0; document.getElementById('dbp').value = 0; myalert("Please enter a DBP value"); errorType = 1; } if(mydbp>=mysbp) { if(mysbp>4) { mydbp = mysbp-5; document.getElementById('dbp').value = mysbp-5; } else { mydbp = 0; document.getElementById('dbp').value = 0; } //myalert("DBP value cannot be greater than SBP"); //errorType = 2; } return errorType; } function blueGraph(blue) { return Math.floor(blue); } function redGraph(red) { return Math.floor(red); } function fillTable(counter, type) { if(type==2) { document.getElementById("redimg1").height = counter; } else { document.getElementById("blueimg1").height = counter; } } function compute() { var mysbp = parseInt(document.getElementById('sbp').value); var mydbp = parseInt(document.getElementById('dbp').value); var type = checkVariables(mysbp, mydbp); var mysbp = parseInt(document.getElementById('sbp').value); var mydbp = parseInt(document.getElementById('dbp').value); var bb = blueGraph(mydbp); var rr = redGraph(mysbp); fillTable(bb,1); fillTable(rr,2); selectImage(); } function changeTab(id) { currentTab = id; selectImage(); } function selectImage() { var mysbp = parseInt(document.getElementById('sbp').value); var mydbp = parseInt(document.getElementById('dbp').value); document.getElementById('jnc1').style.display = "none"; document.getElementById('jnc2').style.display = "none"; document.getElementById('jnc3').style.display = "none"; document.getElementById('jnc4').style.display = "none"; document.getElementById('esh1').style.display = "none"; document.getElementById('esh2').style.display = "none"; document.getElementById('esh3').style.display = "none"; document.getElementById('esh4').style.display = "none"; document.getElementById('esh5').style.display = "none"; document.getElementById('esh6').style.display = "none"; document.getElementById('esh7').style.display = "none"; document.getElementById('who1').style.display = "none"; document.getElementById('who2').style.display = "none"; document.getElementById('who3').style.display = "none"; document.getElementById('who4').style.display = "none"; document.getElementById('who5').style.display = "none"; document.getElementById('who6').style.display = "none"; document.getElementById('who7').style.display = "none"; document.getElementById('who8').style.display = "none"; document.getElementById('who9').style.display = "none"; if(currentTab==1) { if(mysbp>=160 || mydbp>=100) { document.getElementById('jnc4').style.display = "block"; return; } if(mysbp>=140 && mydbp>=90 && mydbp<=99) { document.getElementById('jnc3').style.display = "block"; return; } if(mysbp>=120 && mydbp>=80 && mydbp<=89) { document.getElementById('jnc2').style.display = "block"; return; } if(mysbp<120 || mydbp<80) { document.getElementById('jnc1').style.display = "block"; return; } } else if(currentTab==2) { if(mysbp>=180 || mydbp>=110) { document.getElementById('esh6').style.display = "block"; return; } if(mysbp>=160 && mydbp>=100 && mydbp<=109) { document.getElementById('esh5').style.display = "block"; return; } if(mysbp>=140 && mydbp>=90 && mydbp<=99) { document.getElementById('esh4').style.display = "block"; return; } if(mysbp>=140 && mydbp<90) { document.getElementById('esh7').style.display = "block"; return; } if(mysbp>=130 && mydbp>=85 && mydbp<=89) { document.getElementById('esh3').style.display = "block"; return; } if(mysbp>=120 && mydbp>=80 && mydbp<=84) { document.getElementById('esh2').style.display = "block"; return; } if(mysbp<120 || mydbp<80) { document.getElementById('esh1').style.display = "block"; return; } } else if(currentTab==3) { if(mysbp>=180 || mydbp>=110) { document.getElementById('who7').style.display = "block"; return; } if(mysbp>=160 && mydbp>=100 && mydbp<=109) { document.getElementById('who6').style.display = "block"; return; } if(mysbp>=140 && mydbp>=95 && mydbp<=99) { document.getElementById('who4').style.display = "block"; return; } if(mysbp>=140 && mydbp>=90 && mydbp<=94) { document.getElementById('who5').style.display = "block"; return; } if(mysbp>=149 && mydbp<90) { document.getElementById('who8').style.display = "block"; return; } if(mysbp>=140 && mysbp<=148 && mydbp<90) { document.getElementById('who9').style.display = "block"; return; } if(mysbp>=130 && mydbp>=85) { document.getElementById('who3').style.display = "block"; return; } if(mysbp>=120 && mydbp>=80 && mydbp<=84) { document.getElementById('who2').style.display = "block"; return; } if(mysbp<120 || mydbp<80) { document.getElementById('who1').style.display = "block"; return; } } return; }