Taschenrechner in Javascript

Der Quelltext des Taschenrechners:

<html>
<head>
<title>Javascript-TaschenTrechner</title>
<link rel="stylesheet" type="text/css" href="css/rechner.css">
<script type="text/javascript">
<!--
function Check(Eingabe)
{
var gueltig ="0123456789[]()-+*%/";
for (var i = 0; i < Eingabe.length; i++)
if (gueltig.indexOf(Eingabe.charAt(i))<0 ) return false;
return true;
}

function Ergebnis() {
var x = 0;
if (Check(window.document.Trechner.Display.value))
x = eval(window.document.Trechner.Display.value);
window.document.Trechner.Display.value = x;
}

function Hinzufuegen(Zeichen) {
window.document.Trechner.Display.value =
window.document.Trechner.Display.value + Zeichen;
}

function Sonderfunktion(Funktion) {
if (Check(window.document.Trechner.Display.value)) {
if(Funktion == "sqrt") {
var x = 0;
x = eval(window.document.Trechner.Display.value);
window.document.Trechner.Display.value = Math.sqrt(x);
}
if(Funktion == "pow") {
var x = 0;
x = eval(window.document.Trechner.Display.value);
window.document.Trechner.Display.value = x * x;
}
if(Funktion == "log") {
var x = 0;
x = eval(window.document.Trechner.Display.value);
window.document.Trechner.Display.value = Math.log(x);
}
} else window.document.Trechner.Display.value = error
}

function ontop() {
self.focus();
}
//-->
</script>

</head>
<body onload="ontop(), window.resizeTo(280,312)">

<form name="Trechner" action="" onSubmit="Ergebnis();return false;">
<table border="1" cellpadding="8" cellspacing="0" align="center">
<tr>
<td bgcolor="#eeeeee">
<input type="text" name="Display" align="right" class="display"></td>
</tr><tr>
<td bgcolor="#dddddd">
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td><input type="button" width="60" class="button" value=" 7 " onClick="Hinzufuegen('7')"></td>
<td><input type="button" width="60" class="button" value=" 8 " onClick="Hinzufuegen('8')"></td>
<td><input type="button" width="60" class="button" value=" 9 " onClick="Hinzufuegen('9')"></td>
<td><input type="button" width="60" class="button" value=" + " onClick="Hinzufuegen('+')"></td>
</tr>
<tr>
<td><input type="button" width="60" class="button" value=" 4 " onClick="Hinzufuegen('4')"></td>
<td><input type="button" width="60" class="button" value=" 5 " onClick="Hinzufuegen('5')"></td>
<td><input type="button" width="60" class="button" value=" 6 " onClick="Hinzufuegen('6')"></td>
<td><input type="button" width="60" class="button" value=" - " onClick="Hinzufuegen('-')"></td>
</tr>
<tr>
<td><input type="button" width="60" class="button" value=" 1 " onClick="Hinzufuegen('1')"></td>
<td><input type="button" width="60" class="button" value=" 2 " onClick="Hinzufuegen('2')"></td>
<td><input type="button" width="60" class="button" value=" 3 " onClick="Hinzufuegen('3')"></td>
<td><input type="button" width="60" class="button" value=" * " onClick="Hinzufuegen('*')"></td>
</tr>
<tr>
<td><input type="button" width="60" class="button" value=" = " onClick="Ergebnis()"></td>
<td><input type="button" width="60" class="button" value=" 0 " onClick="Hinzufuegen('0')"></td>
<td><input type="button" width="60" class="button" value=" . " onClick="Hinzufuegen('.')"></td>
<td><input type="button" width="60" class="button" value=" / " onClick="Hinzufuegen('/')"></td>
</tr>
<tr>
<td><input type="button" width="60" class="button" value=" sqrt " onClick="Sonderfunktion('sqrt')"></td>
<td><input type="button" width="60" class="button" value=" x² " onClick="Sonderfunktion('pow')"></td>
<td><input type="button" width="60" class="button" value=" log " onClick="Sonderfunktion('log')"></td>
<td><input type="reset" width="60" class="button" value=" C "></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<table width="100%" border="0" align="center">
<tr>
<td align="center"><form>
<input type="button" value="Fenster schließen" onClick=self.close()>
</form>
</td>
</tr>
</table>
</body>
</html>

Und so sieht der fertige Rechner aus: Taschenrechner