function Setup(){RestoreFromQs();SetInput();DrawSquare()}
function DrawSquare(){var d=parseFloat(document.getElementById("txtSide1").value),e=parseFloat(document.getElementById("txtSide2").value),g=Math.round(Math.sqrt(d*d+e*e)),b=d*e/1E6;b="Diagonal "+CommaFormat(g)+" mm<br />Area "+RoundTo(b,2)+" m&sup2;";document.getElementById("spnRes").innerHTML=b;var a=document.getElementById("cnvsSquare");if(a.getContext){var f=e/d,c;if(f>1){b=280;c=b/f}else{c=280;b=c*f}a.setAttribute("width",b+8);a.setAttribute("height",c+8);a=a.getContext("2d");a.clearRect(0,0,
b,c);a.save();a.shadowOffsetY=8;a.shadowOffsetX=8;a.shadowBlur=8;a.shadowColor="#c0c0c0";a.fillStyle="gainsboro";a.fillRect(0,0,b,c);a.restore();a.strokeRect(0,0,b,c);a.beginPath();a.moveTo(0,0);a.lineTo(b,c);a.stroke();a.fillStyle="#000";a.font="20px Verdana";a.fillText(CommaFormat(d),2,c*0.7);f=CommaFormat(e);var h=a.measureText(f).width;a.fillText(f,b/2-h/2-10,c-4);a.fillStyle="#f00";a.save();a.translate(b/2,c/2-10);a.rotate(Math.atan(d/e));a.fillText(CommaFormat(g),0,0);a.restore()}};
