function Setup(){SetOptions();document.getElementById("ddLongFeet13").selectedIndex=0;document.getElementById("ddLongInch13").selectedIndex=0;document.getElementById("ddLongFrac13").selectedIndex=0;document.getElementById("ddLongFeet5").selectedIndex=0;document.getElementById("ddLongInch5").selectedIndex=7;document.getElementById("ddLongFrac5").selectedIndex=20;document.getElementById("ddHighFeet6").selectedIndex=0;document.getElementById("ddHighInch6").selectedIndex=7;document.getElementById("ddHighFrac6").selectedIndex=
20;document.getElementById("ddHighFeet10").selectedIndex=0;document.getElementById("ddHighInch10").selectedIndex=7;document.getElementById("ddHighFrac10").selectedIndex=20;SetNumeric()}var a,l,h,d,lu,r,c,ctrl,val,centres=0,rad=180/Math.PI;
function CheckRange(b,e,g){val=b.value;if(val=="")return b.focus(),alert("Please Enter a Value"),b.select(),false;else if(isNaN(val))return b.focus(),alert("Please Enter a Valid Value"),b.select(),false;else if(val<e)return b.focus(),alert("Thats too Low"),b.select(),false;else if(val>g)return b.focus(),alert("Thats too High"),b.select(),false;return true}
function HeightFromAngleLength(){l=GetMeasure("ddFe","ddIn","ddFr");ctrl=document.getElementById("_txtAngle1");if(CheckRange(ctrl,1,89))a=ctrl.value,h=Math.round(l*Math.tan(a/rad)),document.getElementById("fntHeigthFromAngleLength").innerHTML="Its "+ConEng(h,true)+" high"}
function AngleFromLengthAndHeight(){h=GetMeasure("ddHighFeet2","ddHighInch2","ddHighFrac2");l=GetMeasure("ddLongFeet2","ddLongInch2","ddLongFrac2");a=Math.atan2(h,l)*rad;document.getElementById("fntAngleFromLengthAndHeight").innerHTML=a.toFixed(2)+" &deg;"}
function LenghtUpFromLengthHeight(){h=GetMeasure("ddHighFeet3","ddHighInch3","ddHighFrac3");l=GetMeasure("ddLongFeet3","ddLongInch3","ddLongFrac3");lu=Math.round(Math.sqrt(h*h+l*l));document.getElementById("fntLenghtUpFromLengthHeight").innerHTML=ConEng(lu,true)}
function LengthUpFromLengthAngle(){l=GetMeasure("ddLongFeet4","ddLongInch4","ddLongFrac4");ctrl=document.getElementById("_txtAngle4");if(CheckRange(ctrl,1,89))a=ctrl.value,lu=Math.round(l/Math.cos(a/rad)),document.getElementById("fntLengthUpFromLengthAngle").innerHTML=ConEng(lu,true)}
function PlumbCenters(){l=GetMeasure("ddLongFeet11","ddLongInch11","ddLongFrac11");ctrl=document.getElementById("_txtAngle11");if(CheckRange(ctrl,1,89))a=ctrl.value/rad,centres=l/Math.cos(a),document.getElementById("fntPlumbCenters").innerHTML=ConEng(Math.round(centres),true)+" centres"}
function Dif(){h=GetMeasure("ddLongFeet5","ddLongInch5","ddLongFrac5");ctrl=document.getElementById("_txtAngle5");if(CheckRange(ctrl,1,89))a=ctrl.value,d=Math.round(h*Math.tan(a/rad)),document.getElementById("fntDif").innerHTML=ConEng(d,false)+" difference"}
function PlumbCut(){h=GetMeasure("ddHighFeet6","ddHighInch6","ddHighFrac6");ctrl=document.getElementById("_txtAngle6");if(CheckRange(ctrl,1,89))a=ctrl.value,d=Math.round(h*Math.tan(a/rad)),document.getElementById("fntPlumbCut").innerHTML=ConEng(d,false)}function Circ(){c=GetMeasure("ddLongFeet20","ddLongInch20","ddLongFrac20");var b=Math.PI*c*c/147456;c=Math.round(c*2*Math.PI);document.getElementById("fntCirc").innerHTML=ConEng(c,true)+" round and the area's "+RoundTo(b,2)+" sq ft"}
function PartCirc(){r=GetMeasure("ddLongFeet21","ddLongInch21","ddLongFrac21");ctrl=document.getElementById("txtDegrees8");if(CheckRange(ctrl,1,360)){a=ctrl.value/rad;c=Math.round(a*r);var b=a/2*r*r,e=(b-r*r*Math.sin(a)/2)/147456;document.getElementById("fntPartCirc").innerHTML="It's "+ConEng(c,true)+" round. Area inside the bow part is "+RoundTo(e,3)+" sq ft and the whole slice is "+RoundTo(b/147456,3)+" sq ft"}}
function AccrossCirc(){r=GetMeasure("ddLongFeet22","ddLongInch22","ddLongFrac22");ctrl=document.getElementById("txtDegrees9");if(CheckRange(ctrl,1,360))a=ctrl.value/rad,c=Math.round(Math.sin(a/2)*r*2),document.getElementById("fntAccrossCirc").innerHTML=ConEng(c,true)+" accross"}
function SetDown(){var b;ctrl=document.getElementById("_txtAngle10");if(CheckRange(ctrl,1,89))a=ctrl.value/rad,b=document.getElementById("ddBeams10").value,h=GetMeasure("ddHighFeet10","ddHighInch10","ddHighFrac10"),h*=1,h+=12,c=h/Math.cos(a),c=Math.round(c*b),document.getElementById("fntSetDown").innerHTML=ConEng(c,true)+" set down"}
function PlumbOver(){l=GetMeasure("ddLongFeet12","ddLongInch12","ddLongFrac12");ctrl=document.getElementById("_txtAngle12");if(CheckRange(ctrl,1,89))a=ctrl.value/rad,c=Math.round(l/Math.cos(a)),document.getElementById("fntPlumbOver").innerHTML=ConEng(c,true)+" up"}
function Accross(){ctrl=document.getElementById("_txtAngle13");if(CheckRange(ctrl,1,89))a=(180-ctrl.value)/rad,l=GetMeasure("ddLongFeet23","ddLongInch23","ddLongFrac23"),c=Math.round(Math.sin(a/2)*l*2),document.getElementById("fntAccross13").innerHTML=ConEng(c,true)+" accross"}
function AngleFromAccross(){var b;b=GetMeasure("ddLongFeet24","ddLongInch24","ddLongFrac24");b=GetMeasure("ddLongFeet25","ddLongInch25","ddLongFrac25")/b;b=Math.asin(b)*rad;b*=2;a=180-b;document.getElementById("fntAngle14").innerHTML=a.toFixed(2)+" &deg;"}function PitchRise_onchange(b){var e=document.getElementById("ddPitchIn").value,g=Math.atan(b.value/e)*rad;document.getElementById("fntPitch").innerHTML=b.value+" in "+e+" = "+g.toFixed(2)+" &deg;"}
function PitchIn_onchange(b){var e=document.getElementById("ddPitchRise").value,g=Math.atan(e/b.value)*rad;document.getElementById("fntPitch").innerHTML=e+" in "+b.value+" = "+g.toFixed(2)+" &deg;"}function ShowSill_onclick(){window.open("Sheets/SillHeights.htm","SillHeight","width=650,height=920,status=no,toolbar=no,menubar=no,location=no").focus()}
function ShowCount_onclick(){window.open("Sheets/QuickCount.htm","QuickCount","width=650,height=920,status=no,toolbar=no,menubar=no,location=no").focus()}
function RunningUp(){PlumbCenters();if(centres!=0){var b=GetMeasure("ddLongFeet13","ddLongInch13","ddLongFrac13");ctrl=document.getElementById("_txtAngle11");if(CheckRange(ctrl,1,89)){b/=Math.cos(ctrl.value/rad);var e=window.open("","RunningUp","width=400,height=850,status=no,toolbar=no,menubar=no,location=no");e.document.open();e.document.write("<html><head>");e.document.write("</head><body onload='javascript:window.print();window.close()'>");e.document.write("Starting at ");e.document.write(ConEng(b,
true));e.document.write(" with ");e.document.write(ConEng(centres,true));e.document.write(" centres<br />");for(var g=0;g<40;g++)b+=centres,e.document.write("<br />"),e.document.write(ConEng(Math.round(b),true));e.document.write("<br /><input type='button' value='Close Window' onclick='javascript:window.close()'></div></body></html>");e.document.close();e.focus()}}}
function SetOptions(){for(var b=document.getElementById("ddFr").options,e=document.getElementById("ddIn").options,g=document.getElementById("ddFe").options,j=document.getElementsByTagName("select"),i=0;i<j.length;i++){if(j[i].id.indexOf("Frac")>-1){for(var f=0;f<b.length;f++)j[i].options[f]=new Option(b[f].text,b[f].value);j[i].selectedIndex=Math.floor(Math.random()*30)+1}if(j[i].id.indexOf("Inch")>-1){for(f=0;f<e.length;f++)j[i].options[f]=new Option(e[f].text,e[f].value);j[i].selectedIndex=Math.floor(Math.random()*
9)+1}if(j[i].id.indexOf("Feet")>-1){for(f=0;f<g.length;f++)j[i].options[f]=new Option(g[f].text,g[f].value);j[i].selectedIndex=Math.floor(Math.random()*8)+1}}}function GetMeasure(b,e,g){return parseInt(document.getElementById(b).value)*384+parseInt(document.getElementById(e).value)*32+parseInt(document.getElementById(g).value)};
