var shape="T";function Window_onload(){Show("R",2);AutoFill();Calculate();CalcBags();CalcVolume()}
function Show(e,a){if(e!=shape){document.getElementById("img"+shape).src="images/Concrete/Concrete"+shape+"s.gif";document.getElementById("img"+e).src="images/Concrete/Concrete"+e+".gif";for(var c=document.getElementById("tdSides"),d=c.childNodes.length,h=0;h<d;h++)c.removeChild(c.childNodes[0]);var j;for(h=0;h<a;h++){j=document.createElement("div");j.innerHTML+="Side "+(h+1)+" ";d=document.createElement("input");d.setAttribute("type","text");d.setAttribute("class","Imp");d.setAttribute("style","width:65px");
d.setAttribute("id","txt"+h);j.appendChild(d);c.appendChild(j)}SetNumeric();shape=e;document.getElementById("divResult").innerHTML="";document.getElementById("divSlab").style.display="none";document.getElementById("divSection").style.display="none"}}
function Calculate(){for(var e=document.getElementById("tdSides").getElementsByTagName("input"),a=[],c,d=0;d<e.length;d++){a[d]=ConvertTo32nds(e[d].value);if(isNaN(a[d])||a[d]<384){alert("Please enter Side "+(d+1)+"\n\nLength in Inches\n\nMin 12");return}}switch(shape){case "R":a[2]=a[0];a[3]=a[1];c=a[0]*a[1];break;case "L":if(a[2]>=a[0]){alert("Side 3 must be shorter than Side 1");return}if(a[3]>=a[1]){alert("Side 4 must be shorter than Side 2");return}a[4]=a[0]-a[2];a[5]=a[1]-a[3];c=a[0]*a[1];c-=
a[3]*a[4];break;case "U":if(a[2]<=a[4]){alert("Side 5 must be shorter than Side 3");return}if(a[3]+a[5]>=a[1]){alert("Sides 4 and 6 must add to less than Side 2");return}if(a[2]-a[4]>=a[0]){alert("Side 5 must be longer than "+(a[2]-a[0]).toString());return}a[6]=a[0]-(a[2]-a[4]);a[7]=a[1]-a[3]-a[5];c=a[0]*(a[1]-a[3]-a[5]);e=a[5]*(a[0]-a[6]);c+=e;e=a[2]*a[3];c+=e;break;case "T":if(a[2]+a[4]<=a[0]){alert("Sides 3 and 5 must add to more than Side 1");return}if(a[3]+a[5]>=a[1]){alert("Sides 4 and 6 must add to less than Side 2");
return}a[6]=a[2]+a[4]-a[0];a[7]=a[1]-a[3]-a[5];c=a[0]*a[7];e=a[2]*a[3];c+=e;e=(a[2]+a[4])*a[5];c+=e;break;case "H":if(a[2]+(a[6]-(a[4]+a[8]))>=a[0]){alert("Side 1 to short");return}if(a[7]+a[9]>=a[1]+a[3]+a[5]){alert("Sides 8 and 10 must not add to more than sides 2, 4 and 6");return}if(a[6]-a[8]-a[4]<=0){alert("Sides 5 and 9 must not add to more than side 7");return}a[10]=a[0]-a[2]+a[4]-a[6]+a[8];e=a[1]+a[3]+a[5];a[11]=e-a[7]-a[9];c=(a[0]-a[2]-a[10])*e;e=a[1]*a[2];c+=e;e=a[10]*a[11];c+=e;e=a[4]*
a[5];c+=e;e=a[7]*a[8];c+=e}var h=0;for(d=0;d<a.length;d++)h+=a[d];e=ConvertTo32nds(document.getElementById("txtSlabThick").value);var j=ConvertTo32nds(document.getElementById("txtEdgeThick").value);if(j<e)j=e;var l=ConvertTo32nds(document.getElementById("txtEdgeWidth").value),o=ConvertTo32nds(document.getElementById("txtThickLength").value),p=ConvertTo32nds(document.getElementById("txtThickWidth").value),m=ConvertTo32nds(document.getElementById("txtThickThick").value),n=c*e;if(l>0&&j>e){d=j-e;n+=
h*l*d;if(document.getElementById("cbSplay").checked)n+=d*d*h/2}if(o>0&&m>e){d=m-e;n+=o*p*d;if(document.getElementById("cbSplay").checked)n+=d*d*o}n/=56623104;c/=147456;h/=384;d="Area "+RoundTo(c/9,2)+" y&sup2; = "+RoundTo(c,2)+" ft&sup2;<br />Volume "+RoundTo(n/27,2)+" y&sup3; = "+RoundTo(n,2)+" ft&sup3;<br />Perimeter "+RoundTo(h,2)+" ft";document.getElementById("divResult").innerHTML=d;document.getElementById("divSlab").style.display="block";c=document.getElementById("cnvsSlab");if(c.getContext){h=
[];for(d=0;d<a.length;d++)h[d]=ConEng(a[d],true);var b,g;switch(shape){case "R":g=a[0];b=a[1];break;case "L":g=a[0];b=a[1];break;case "U":g=Math.max(a[0],a[2]);b=a[1];break;case "T":g=a[2]+a[4];b=a[1];break;case "H":b=a[1]+a[3]+a[5];g=a[0];if(a[4]>a[2])g+=a[4]-a[2];d=a[2]-a[4]+a[6];if(d>a[0])g+=d-a[0]}var i=c.width-4,k=i/(b/g);c.setAttribute("height",k+4);g=i/b;for(d=0;d<a.length;d++)a[d]*=g;g=[];b=c.getContext("2d");b.font="16px Verdana";b.textBaseline="top";b.beginPath();b.fillStyle="#dcdcdc";b.strokeStyle=
"#808080";var f;switch(shape){case "R":b.moveTo(0,0);b.lineTo(i,0);b.lineTo(i,k);b.lineTo(0,k);c=new Point(6,k/2-10);g[0]=c;c=new Point(i/2-b.measureText(h[1]).width/2,0);g[1]=c;break;case "L":b.moveTo(0,k);b.lineTo(0,0);c=new Point(6,k/2-10);g[0]=c;b.lineTo(i,0);b.lineTo(i,a[2]);c=new Point(i/2-b.measureText(h[1]).width-6,0);g[1]=c;b.lineTo(i-a[3],a[2]);c=new Point(i-b.measureText(h[2]).width-6,a[2]/2-6);g[2]=c;b.lineTo(i-a[3],k);c=new Point(i-a[3]/2-b.measureText(h[3]).width/2,a[2]-20);g[3]=c;break;
case "U":b.moveTo(0,a[0]);b.lineTo(0,0);c=new Point(6,a[0]/2-6);g[0]=c;b.lineTo(i,0);c=new Point(i/2-b.measureText(h[1]).width/2,0);g[1]=c;f=a[2];b.lineTo(i,f);c=new Point(i-b.measureText(h[2]).width-6,f-a[2]/2-6);g[2]=c;d=i-a[3];b.lineTo(d,f);c=new Point(d+a[3]/2-b.measureText(h[3]).width/2,f-20);g[3]=c;f-=a[4];b.lineTo(d,f);c=new Point(d+6,f+a[4]/2-10);g[4]=c;d-=a[5];b.lineTo(d,f);c=new Point(d+a[5]/2-b.measureText(h[5]).width/2,f-20);g[5]=c;b.lineTo(d,a[0]);break;case "T":b.moveTo(0,a[0]);b.lineTo(0,
0);c=new Point(6,a[0]/2-6);g[0]=c;b.lineTo(i,0);c=new Point(i/2-b.measureText(h[1]).width/2,0);g[1]=c;f=a[2];b.lineTo(i,f);c=new Point(i-b.measureText(h[2]).width-6,f-a[2]/2-6);g[2]=c;d=i-a[3];b.lineTo(d,f);c=new Point(d+a[3]/2-b.measureText(h[3]).width/2,f-20);g[3]=c;f=k;b.lineTo(d,f);c=new Point(d-b.measureText(h[4]).width-6,f-a[4]/2-10);g[4]=c;d-=a[5];b.lineTo(d,f);c=new Point(d+a[5]/2-b.measureText(h[5]).width/2,f-20);g[5]=c;b.lineTo(d,a[0]);break;case "H":k=0;if(a[4]>a[2]){k=f=a[4]-a[2];b.moveTo(0,
a[0]+f);b.lineTo(0,f)}else{f=0;b.moveTo(0,a[0]);b.lineTo(0,0)}c=new Point(2,f+a[0]/2);g[0]=c;d=a[1];b.lineTo(d,f);c=new Point(d/2-b.measureText(h[1]).width/2,f);g[1]=c;f+=a[2];b.lineTo(d,f);c=new Point(d-b.measureText(h[2]).width-6,f-a[2]/2-10);g[2]=c;d+=a[3];b.lineTo(d,f);c=new Point(d-a[3]/2-b.measureText(h[3]).width/2,f);g[3]=c;f-=a[4];b.lineTo(d,f);c=new Point(d+6,f+a[4]/2);g[4]=c;d=i;b.lineTo(d,f);c=new Point(d-a[5]/2-b.measureText(h[5]).width/2,f);g[5]=c;f+=a[6];b.lineTo(d,f);c=new Point(d-
b.measureText(h[6]).width-6,f-a[6]/2);g[6]=c;d-=a[7];b.lineTo(d,f);c=new Point(d+a[7]/2-b.measureText(h[7]).width/2,f-20);g[7]=c;f-=a[8];b.lineTo(d,f);c=new Point(d+6,f+a[8]/2-6);g[8]=c;d-=a[9];b.lineTo(d,f);c=new Point(d+a[9]/2-b.measureText(h[9]).width/2,f-20);g[9]=c;f=a[0]+k;b.lineTo(d,f)}b.closePath();b.save();b.shadowOffsetY=4;b.shadowOffsetX=4;b.shadowBlur=6;b.shadowColor="#c0c0c0";b.fill();b.restore();b.stroke();b.fillStyle="black";for(d=0;d<g.length;d++){c=g[d];b.fillText(h[d],c._x,c._y)}}document.getElementById("divSection").style.display=
"block";c=document.getElementById("cnvsSection");if(c.getContext){k=document.getElementById("cbSplay").checked;g=(c.height-20)/Math.max(j,m);f=(j-e)*g;a=e*g;h=j*g;i=l*g;b=c.getContext("2d");b.clearRect(0,0,c.width,c.height);b.beginPath();b.moveTo(0,h);b.lineTo(0,0);b.lineTo(c.width,0);var s=0,t=e*g/6;for(d=0;d<6;d++){b.lineTo(c.width-s,d*t);s=s>0?0:Math.random()*10+8}b.lineTo(c.width,a);d=c.width*0.8;if(m>e&&p>0&&o>0){c=(m-e)*g;k?b.lineTo(d+c,a):b.lineTo(d,a);var r=m*g;b.lineTo(d,r);var q=p*g;b.lineTo(d-
q,r);k?b.lineTo(d-q-c,a):b.lineTo(d-q,a)}k?b.lineTo(i+f,a):b.lineTo(i,a);b.lineTo(i,h);b.closePath();c=new Image;c.src=document.getElementById("imgBg").src;c=b.createPattern(c,"repeat");b.fillStyle=c;b.fill();b.strokeStyle="#808080";b.stroke();b.fillStyle="#f00";b.font="bold 16px verdana";b.textBaseline="top";b.fillText(ConEng(j,false),0,h/2);if(h>a){b.fillStyle="#00f";l=ConEng(l,false);j=b.measureText(l).width;b.fillText(l,i/2-j/2,h+2);b.fillStyle="#f00";b.fillText(ConEng(e,false),310,a/2-8)}if(m>
e&&p>0&&o>0){b.fillStyle="#f00";l=ConEng(m,false);j=b.measureText(l).width;b.fillText(l,d-q/2-j/2,r*0.2);b.fillStyle="#00f";l=ConEng(p,false);j=b.measureText(l).width;b.fillText(l,d-q/2-j/2,r+2)}b.fillStyle="#000";b.fillText("Volume "+RoundTo(n,2)+" ft3",100,2)}}function Point(e,a){this._x=e;this._y=a}
function AutoFill(){var e;switch(shape){case "R":e="144,192";break;case "L":e="144,144,72,72";break;case "U":e="72,108,72,36,36,36";break;case "T":e="48,144,48,48,48,48";break;case "H":e="144,48,48,48,48,48,144,48,48,48"}e=e.split(",");for(var a=0;a<e.length;a++)document.getElementById("txt"+a).setAttribute("value",e[a]);Calculate()}
function CalculateColumn(){var e=parseInt(document.getElementById("txtColumnDiameter").value),a=parseInt(document.getElementById("txtColumnLength").value),c=parseInt(document.getElementById("txtColumns").value);e=e/2;a=Math.PI*e*e*a*c/46656;document.getElementById("btnCalculateColumn").value=RoundTo(a,2)+" y\u00b3"}
function CalcBags(){var e=parseFloat(document.getElementById("_txtft3Bags").value),a=e/0.45,c=e/0.6;document.getElementById("spnFt2").innerHTML=e;document.getElementById("spnBags60").innerHTML=a.toFixed(1);document.getElementById("spnBags80").innerHTML=c.toFixed(1)}
function CalcVolume(){var e=parseFloat(document.getElementById("txtBags").value),a=document.getElementById("ddBagWeight").value;e=e*a/3600;a=e*27;document.getElementById("spnVolume").innerHTML=RoundTo(e,2)+" y\u00b3 or "+RoundTo(a,2)+" ft\u00b3"}
function Demo(){alert("Click image to select slab shape.\n\n");Show("T",6);alert("T shape selected.\n\nEnter side lengths in displayed Input boxes.\n\nAll input in inches.\n\n");AutoFill();alert('Enter slab thickness (depth) and edge footing dimensions.\n\neg: 6" thick slab with 18" wide x 12" thick edge beam.\n\n');document.getElementById("txtThickLength").value="240";document.getElementById("txtThickWidth").value="12";document.getElementById("txtThickThick").value="8";alert('Enter internal thickening Total Length (eg: 240").\n\nInternal thickening Width (eg: 12")\n\nand internal thickening Thicknes (eg: 8"0).\n\n');
alert("Hit 'Calculate' to dispaly results.\n\n");Calculate()};
