var inType="p",dangle=18.4,rise=400,run=1200,pitch=4,hyp=1265,presc;
function ChangeIn(b){inType=b;document.getElementById("spnPitch").style.display="none";document.getElementById("spnAngle").style.display="none";document.getElementById("spnRise").style.display="none";document.getElementById("btnPitch").setAttribute("class","InActiveButton");document.getElementById("btnAngle").setAttribute("class","InActiveButton");document.getElementById("btnRise").setAttribute("class","InActiveButton");switch(b){case "p":document.getElementById("spnPitch").style.display="block";
document.getElementById("_txtIn").value=RoundTo(pitch,2);document.getElementById("btnPitch").setAttribute("class","ActiveButton");break;case "a":document.getElementById("spnAngle").style.display="block";document.getElementById("_txtIn").value=RoundTo(dangle,2);document.getElementById("btnAngle").setAttribute("class","ActiveButton");break;case "r":document.getElementById("spnRise").style.display="block";document.getElementById("_txtIn").value=Math.round(rise);document.getElementById("btnRise").setAttribute("class",
"ActiveButton");break}document.getElementById("cnvsRiseRun")!=null&&DrawIt()}var RAD=Math.PI/180;
function CalcAll(){run=parseFloat(document.getElementById("txtRun").value);presc=run<100?1:0;var b=parseFloat(document.getElementById("_txtIn").value),a;switch(inType){case "p":pitch=b;a=Math.atan(pitch/12);rise=Math.tan(a)*run;dangle=a/RAD;break;case "a":dangle=b;a=dangle*RAD;pitch=Math.tan(a)*12;rise=Math.tan(a)*run;break;case "r":rise=b;a=Math.atan(rise/run);dangle=a/RAD;pitch=Math.tan(a)*12;break}hyp=run/Math.cos(a);document.getElementById("spnRiseRes").innerHTML=RoundTo(rise,presc);document.getElementById("spnPitchRes").innerHTML=
RoundTo(pitch,1);document.getElementById("spnAngleRes").innerHTML=RoundTo(dangle,1);document.getElementById("spnHyp").innerHTML=RoundTo(hyp,presc);document.getElementById("cnvsRiseRun")!=null&&DrawIt()}function CheckIn(b){var a=parseFloat(b.value);if(inType=="p")if(a>200)b.value="200";else if(a<0.2)b.value="0.2";if(inType=="a")if(a>89.9)b.value="89.9";else if(a<1)b.value="1"}function RoundTo(b,a){a=Math.pow(10,a);return d=Math.round(b*a)/a}function Setup(){SetNumeric();ChangeIn("p");CalcAll()};