var RAD=Math.PI/180;function Setup(){DrawGazebo();DrawHip();SetInput()}
function DrawGazebo(){var d=document.getElementById("cnvsGazebo");if(d.getContext){var a=gazeboData.split(","),p=parseFloat(a[0]),s=parseFloat(a[1]),j=parseFloat(a[2]),q=a[3],k=a[4]>0,h=a[5]>0,l=parseFloat(a[6]),o=parseFloat(a[7]),m=parseFloat(a[8]);a=d.getContext("2d");a.fillStyle="#fff";a.fillRect(0,0,d.width,d.height);a.strokeStyle="#000";var b=d.width/2-6,n=-90*RAD,c,g=360/p*RAD;a.fillStyle=j>0?"azure":"beige";a.lineWidth=1;c=n;var f=b*Math.cos(c)+b,e=b*Math.sin(c)+b;a.beginPath();a.moveTo(f,
e);for(var i=0;i<p;i++){c+=g;f=b*Math.cos(c)+b;e=b*Math.sin(c)+b;a.lineTo(f,e)}a.save();a.shadowOffsetY=6;a.shadowOffsetX=6;a.shadowBlur=10;a.shadowColor="#c0c0c0";a.fill();a.restore();a.stroke();if(j>0){j=b-b/(s/(j/Math.cos(g/2)));a.fillStyle="#f5f5dc";c=n;f=j*Math.cos(c)+b;e=j*Math.sin(c)+b;a.beginPath();a.moveTo(f,e);for(i=0;i<p;i++){c+=g;f=j*Math.cos(c)+b;e=j*Math.sin(c)+b;a.lineTo(f,e)}a.fill();a.stroke()}else j=b;a.strokeStyle="#ff8c00";c=n;a.beginPath();for(i=0;i<p;i++){a.moveTo(b,b);f=b*Math.cos(c)+
b;e=b*Math.sin(c)+b;a.lineTo(f,e);c+=g}a.stroke();if(h){a.beginPath();a.strokeStyle="#080";a.arc(b,b,j,0,360*RAD,true);a.stroke()}h=b*Math.cos(g*0.5);j=b/2*Math.cos(g*0.5);if(q=="half"){var r=b/2;c=n;f=r*Math.cos(c)+b;e=r*Math.sin(c)+b;a.beginPath();a.moveTo(f,e);for(i=0;i<p;i++){c+=g;f=r*Math.cos(c)+b;e=r*Math.sin(c)+b;a.lineTo(f,e)}c=n;for(i=0;i<p;i++){f=j*Math.cos(c+g*0.5)+b;e=j*Math.sin(c+g*0.5)+b;a.moveTo(f,e);f=h*Math.cos(c+g*0.5)+b;e=h*Math.sin(c+g*0.5)+b;a.lineTo(f,e);c+=g}a.stroke()}if(q==
"full"){c=n;a.beginPath();for(i=0;i<p;i++){a.moveTo(b,b);f=h*Math.cos(c+g*0.5)+b;e=h*Math.sin(c+g*0.5)+b;a.lineTo(f,e);c+=g}a.stroke()}if(k){c=n;e=g/2;f=b*Math.sin(e)/2*Math.cos(e);e=b-Math.tan(e)*f;q=Math.atan(f/e);k=e/Math.cos(q);h=b/2;a.beginPath();for(i=0;i<p;i++){j=h*Math.cos(c)+b;r=h*Math.sin(c)+b;a.moveTo(j,r);f=k*Math.cos(c-q)+b;e=k*Math.sin(c-q)+b;a.lineTo(f,e);a.moveTo(j,r);f=k*Math.cos(c+q)+b;e=k*Math.sin(c+q)+b;a.lineTo(f,e);c+=g}a.stroke()}if(l>0){a.strokeStyle="#00f";a.fillStyle="#fff";
c=n;a.beginPath();a.moveTo(b,b);a.lineTo(b,0);f=b*Math.cos(c+g)+b;e=b*Math.sin(c+g)+b;a.lineTo(f,e);a.lineTo(b,b);a.fill();c=d.width/2/(s/Math.cos(m*RAD));l=l*c;o=b-o*c;if(l<4)l=4;for(c=n;o>10;){f=o*Math.cos(c)+b;e=o*Math.sin(c)+b;a.moveTo(f,e);f=o*Math.cos(c+g)+b;e=o*Math.sin(c+g)+b;a.lineTo(f,e);o-=l}a.stroke()}a.fillStyle="#f0ffff";c=-n;f=10*Math.cos(c)+b;e=10*Math.sin(c)+b;a.beginPath();a.moveTo(f,e);for(i=0;i<p;i++){c+=g;f=10*Math.cos(c)+b;e=10*Math.sin(c)+b;a.lineTo(f,e)}a.save();a.shadowOffsetY=
10;a.shadowBlur=10;a.shadowColor="#c0c0c0";a.fill();a.restore();a.stroke()}}
function DrawHip(){var d=document.getElementById("cnvsHip");if(d.getContext){var a=hipData.split(","),p=a[0],s=parseFloat(a[1]),j=parseFloat(a[2]),q=a[3],k=a[4]=="1",h=parseFloat(a[5]),l=a[6];a=90-j;var o=d.width,m=d.height-20;d=d.getContext("2d");d.font="11px Verdana";d.textBaseline="top";d.fillStyle="#ffa500";d.strokeStyle="#000";var b=m/Math.tan(j*RAD);k=k?b:0;d.beginPath();d.moveTo(k,0);d.lineTo(o,0);d.lineTo(o-b,m);var n,c,g;if(h>0){c=h/(p/m);n=140-b;var f=c*Math.sin(a*RAD);g=n+f/Math.tan(j*
RAD);f=m-f;var e=g+c*Math.cos(a*RAD);c=h*Math.tan(a*RAD);d.lineTo(e,m);d.lineTo(g,f);d.lineTo(140,0);d.lineTo(n,m);d.lineTo(0,m);g=Math.sqrt(Math.pow(c,2)+Math.pow(h,2))}else d.lineTo(0,m);d.lineTo(k,0);d.save();d.shadowOffsetY=6;d.shadowBlur=6;d.shadowColor="#c0c0c0";d.fill();d.restore();d.stroke();d.fillStyle="#000";k=units=="m";if(h>0){d.fillText(k?l:ConEng(l,true),142,2);h=k?Math.round(c):ConEng(c,false);l=d.measureText(h).width;d.fillText(h,140-b-l,m-20);d.fillText(k?Math.round(g):ConEng(g,false),
n-2,m+4)}h="Setback "+(k?s:ConEng(s,false));l=d.measureText(h).width;d.fillText(h,o-l-2,m+4);h=j+"\u00b0";l=d.measureText(h).width;d.fillText(h,o-l-10,2);h=k?q:ConEng(q,true);d.fillText("Length "+h,6,2);h=k?p:ConEng(p,false);d.fillText("Depth "+h,o*0.6,m/2-8);d.fillText("Angle "+a.toFixed(2)+"\u00b0",6,m/2-8)}};
