if(top!=self)top.location=self.document.location;function Window_onload(){Calculate();SetNumeric()}
function CheckInput(){var b=parseInt(document.getElementById("txtWidth").value);if(isNaN(b)||b<40||b>200){alert("Please Enter Valid Width\n\nMin 40 Max 200");document.getElementById("txtWidth").focus();return false}b=parseInt(document.getElementById("txtRadiusOffset").value);var c=parseInt(document.getElementById("ddSocketThick").value);if(b<c){alert("Radius Offset must be larger than Socket Thickness ("+c+")");document.getElementById("txtRadiusOffset").focus();return false}if(isNaN(b)||b>600){alert("Please Enter Valid Radius\n\nMax 600");
document.getElementById("txtRadiusOffset").focus();return false}return true}
function Calculate(){if(CheckInput()){var b=document.getElementById("cnvsDovetail");if(b.getContext){var c=parseFloat(document.getElementById("txtWidth").value)*3.77952755905512,n=parseFloat(document.getElementById("txtRadiusOffset").value)*3.77952755905512,i=parseFloat(document.getElementById("ddTailThick").value)*3.77952755905512,j=parseFloat(document.getElementById("ddSocketThick").value)*3.77952755905512,o=document.getElementById("cbColor").checked,m=parseFloat(document.getElementById("ddRatio").value),
p=parseFloat(document.getElementById("ddTails").value),k=document.getElementById("cbFullTemplate").checked,l=k?420:280,e=l/2,f=i/2;i=e-f;f=k?e+f:80;var q=i-j;j=f+j;var u=i-n;n=f+n;var r=c/2,a=b.getContext("2d");b.setAttribute("height",l);b.setAttribute("width",c+1);a.clearRect(0,0,b.width,b.height);b=c/(p+1+p*m);m=b*m;a.font="28px Arial";a.textBaseline="top";var g="X",h=a.measureText(g).width;h=h/2;var s=e-h,d=b;a.fillStyle="#000";k&&a.fillText(g,d/2-h,s);e="";for(var t=0;t<p;t++){e+=Math.round(d/
3.77952755905512)+", ";a.beginPath();if(k){a.moveTo(r,u);a.lineTo(d,i);a.lineTo(d,f)}else a.moveTo(d,f);a.lineTo(r,n);d+=m;e+=Math.round(d/3.77952755905512)+", ";a.lineTo(d,f);if(k){a.lineTo(d,i);a.fillText(g,d+b/2-h,s)}a.closePath();if(o){a.save();a.fillStyle="#00f";a.fill();a.restore()}a.stroke();d+=b}e=e.substring(0,e.length-2);a.fillStyle=o?"#00f":"#fff";if(k){a.fillRect(0,0,c,q);a.strokeRect(0,0,c,q)}a.fillRect(0,j,c,l-j);a.strokeRect(0,j,c,l-j);if(k){a.beginPath();a.moveTo(0,i);a.lineTo(c,i);
a.moveTo(0,f);a.lineTo(c,f);a.stroke()}a.font="12px Verdana";a.fillStyle=o?"#fff":"#000";g="Tail Width "+RoundTo(m/3.77952755905512,1)+" - Gap "+RoundTo(b/3.77952755905512,1);h=a.measureText(g).width;a.fillText(g,c/2-h/2,l-40);g="Tails "+e;h=a.measureText(g).width;a.fillText(g,c/2-h/2,l-18)}}};
