function Window_onload(){Calculate();SetNumeric()}
function Calculate(){var b=180/Math.PI,c=parseFloat(document.getElementById("txtRadius").value);if(isNaN(c))alert("Please Enter Radius");else{var e=parseFloat(document.getElementById("txtAngle").value);if(isNaN(e))alert("Please Enter Angle");else if(e>179)alert("Please Enter Angle Under 180");else{var f=e/b,q=c*Math.cos(f/2),v=c-q,r=Math.round(c*2*Math.PI),k=Math.PI*c*c,i=k/(360/e),s=Math.round(f*c),w=r-s,t=k-i,j=Math.round(Math.sin(f/2)*c*2),n=i-c*c*Math.sin(f)/2;f=i-n;k*=1.0E-6;f*=1.0E-6;n*=1.0E-6;
t*=1.0E-6;i*=1.0E-6;var o=1.33333*Math.PI*Math.pow(c,3),h=Math.sqrt(Math.pow(c,2)-Math.pow(j/2,2)),p=0.33333*Math.PI*Math.pow(j/2,2)*h;c=c-h;h=Math.PI/6*(3*Math.pow(j/2,2)+Math.pow(c,2))*c;c=o-p-h;o*=1.0E-6;c*=1.0E-6;p*=1.0E-6;h*=1.0E-6;var g=document.getElementById("cnvsCircle"),l=g.width,d=l/2,m=d-1,a=g.getContext("2d");a.clearRect(0,0,g.width,g.height);a.beginPath();a.fillStyle="#87ceeb";a.strokeStyle="#000";a.save();a.shadowOffsetY=6;a.shadowBlur=6;a.shadowColor="#c0c0c0";a.arc(d,d,m,0,360/b,
false);a.fill();a.restore();a.beginPath();a.fillStyle="#f00";e=e/2;g=d-Math.sin(e/b)*m;var u=d-Math.cos(e/b)*m;l=l-g;a.arc(d+1,d,m,(270-e)/b,(270+e)/b,false);a.fill();a.beginPath();a.fillStyle="#7cfc00";a.moveTo(d,d);a.lineTo(g,u);a.lineTo(l,u);a.lineTo(d,d);a.fill();a.fillStyle="#000";a.font="12px Arial";a.textBaseline="top";a.fillText("Radius",d+46,d+7);a.fillText("Angle",d-54,d+7);b="Around Red = "+s+"<br />Across Red = "+j+"<br />Height Red = "+Math.round(v)+"<br />Area Red = "+RoundTo(n,3)+" m&sup2;<br />Area Green + Red = "+
RoundTo(i,3)+" m&sup2;<br />Sphere Red Vol = "+RoundTo(h,2)+" litres";document.getElementById("spnTop").innerHTML=b;b="Across Green = "+j+"<br />Height Green = "+Math.round(q)+"<br />Area Green "+RoundTo(f,3)+" m&sup2;<br />Sphere Green Vol = "+RoundTo(p,2)+" litres";document.getElementById("spnMid").innerHTML=b;b="Around Blue = "+w+"<br />Area Blue = "+RoundTo(t,3)+" m&sup2;<br />Sphere Blue Vol = "+RoundTo(c,2)+" litres";document.getElementById("spnLower").innerHTML=b;b="Total Circumference = "+
r+"<br />Total Area = "+RoundTo(k,3)+" m&sup2;;<br />Sphere Total Vol = "+RoundTo(o,2)+" litres";document.getElementById("spnTotals").innerHTML=b}}}var animTimer,isAnim=false;function AnimStart(b){if(isAnim)AnimStop();else{isAnim=true;animTimer=setInterval("Anim("+b+")",40)}}function AnimStop(){clearInterval(animTimer);isAnim=false}function Anim(b){b=parseFloat(document.getElementById("txtAngle").value)+b;if(b>1&&b<179){document.getElementById("txtAngle").value=b;Calculate()}else AnimStop()};
