function Window_onload(){Calculate();SetNumeric()}
function Calculate(){var a=parseFloat(document.getElementById("txtRadius").value);if(isNaN(a))alert("Please enter Radius");else{var b=Math.PI*Math.pow(a,2)/1E6,d=document.getElementById("ddSides").value,g=360/d/(180/Math.PI),c=a*Math.cos(g/2),g=a*Math.sin(g/2)*2,a=Math.PI*a*2,h=a/d,e=g/2*c,f=e*d;e/=1E6;f/=1E6;document.getElementById("spnSideLength").innerHTML=Math.round(g);document.getElementById("spnCentersCircle").innerHTML=Math.round(h);document.getElementById("spnCircleArea").innerHTML=RoundTo(b,
2);document.getElementById("spnCirc").innerHTML=Math.round(a);document.getElementById("spnSliceHeight").innerHTML=Math.round(c);document.getElementById("spnSliceArea").innerHTML=RoundTo(e,3);document.getElementById("spnPolyArea").innerHTML=RoundTo(f,2);b="Triangle,Square,Pentagon,Hexagon,Heptagon,Octagon,Nonagon,Decagong,Hendecagon,Dodecagon,Triskaidecagon,Tetrakaidecagon,Pentakaidecagon,Hexakaidecagon,Heptakaidecagon,Octakaidecagon,Enneakaidecagon,Icosagon,Icosikaihenagon,Icosikaidigon,Icosikaitrigon,Icosikaitetragon,Icosikaipentagon,Icosikaihexagon,Icosikaiheptagon,Icosikaioctagon,Icosikaienneagon,Triacontagon".split(",")[d-
3];document.getElementById("spnPolyType").innerHTML=b;document.getElementById("spnPoly").innerHTML=d+" sided "+b;a=document.getElementById("cnvsPolygon");if(a.getContext){g=Math.PI/180;b=a.getContext("2d");b.clearRect(0,0,a.width,a.height);var c=a.width/2,f=a.width/2,k=-90*g,h=360/d*g,a=k,e=f*Math.cos(a)+c,i=f*Math.sin(a)+c;b.strokeStyle="#000";b.beginPath();b.moveTo(e,i);for(var j=0;j<d;j++)a+=h,e=f*Math.cos(a)+c,i=f*Math.sin(a)+c,b.lineTo(e,i);if(document.getElementById("cbUseColor").checked)b.save(),
b.fillStyle="#87ceeb",b.shadowOffsetY=10,b.shadowBlur=10,b.shadowColor="#c0c0c0",b.fill(),b.restore();b.strokeStyle="#808080";b.stroke();if(document.getElementById("cbDrawSpokes").checked){a=k;b.beginPath();for(j=0;j<d;j++)b.moveTo(c,c),e=f*Math.cos(a)+c,i=f*Math.sin(a)+c,b.lineTo(e,i),a+=h;b.stroke()}if(document.getElementById("cbDrawCircle").checked)b.beginPath(),b.strokeStyle="#080",b.arc(c,c,f-1,0,360*g,true),b.stroke();b.beginPath();b.strokeStyle="#ff0";d=f*Math.cos(h*0.5);b.moveTo(c,c);e=d*
Math.cos(a+h*0.5)+c;i=d*Math.sin(a+h*0.5)+c;b.lineTo(e,i);b.stroke()}}}var animTimer,isAnim=false;function AnimStart(a){isAnim?AnimStop():(isAnim=true,animTimer=setInterval("Anim("+a+")",200))}function AnimStop(){clearInterval(animTimer);isAnim=false}function Anim(a){a=document.getElementById("ddSides").selectedIndex+a;a>-1&&a<28?(document.getElementById("ddSides").selectedIndex=a,Calculate()):AnimStop()};
