Помоги исправить ошибку
<html>
<head>
<script>
function getObj(objID)
{
if (document.getElementById) {return document.getElementById(objID);}
else if (document.all) {return document.all[objID];}
else if (document.layers) {return document.layers[objID];}
}
function checkClick(e)
{
e?evt=e:evt=event;
CSE=evt.target?evt.target:evt.srcElement;
if (getObj('fc'))
if (!isChild(CSE,getObj('fc')))
getObj('fc').style.display='none';
}
function isChild(s,d)
{
while(s) {
if (s==d)
return true;
s=s.parentNode;
}
return false;
}
function Left(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
function Top(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
document.write('<table id="fc" border=1 style="font:12px Arial;position:absolute;border-collapse:collapse;background:#FFFFFF;border:1px solid #303030;display:none;-moz-user-select:none;-khtml-user-select:none;user-select:none;" cellpadding=2>');
document.write('<tr height=25 align="center">');
document.write('<td style="cursor:pointer" width=20 onclick="if (checkNum(this.form.display.value)) { equal(this.form.display) }"> = </td>');
document.write('<td><input type="button" value=" 7 " onClick="addChar(getObj(id1),7)"></td>');
document.write('<td style="cursor:pointer" width=20 onClick="addChar(this.form.display,8)"><b>8</td>');
document.write('<td style="cursor:pointer" width=20 onClick="addChar(this.form.display,9)"><b>9</td>');
document.write('<td style="cursor:pointer" width=20 onClick="selOper(this.form.display,+)">+</td></tr>');
document.write('<tr height=25 align="center">');
document.write('<td style="cursor:pointer" onClick="deleteChar(this.form.display)">C</td>');
document.write('<td style="cursor:pointer" onClick="addChar(this.form.display,4)"><b>4</td>');
document.write('<td style="cursor:pointer" onClick="addChar(this.form.display,5)"><b>5</td>');
document.write('<td style="cursor:pointer" onClick="addChar(this.form.display,6)"><b>6</td>');
document.write('<td style="cursor:pointer" onClick="selOper(this.form.display,-)">-</td></tr>');
document.write('<tr height=25 align="center">');
document.write('<td style="cursor:pointer" onClick="sbros(this.form.display)">CE</td>');
document.write('<td style="cursor:pointer" onClick="addChar(this.form.display,1)"><b>1</td>');
document.write('<td style="cursor:pointer" onClick="addChar(this.form.display,2)"><b>2</td>');
document.write('<td style="cursor:pointer" onClick="addChar(this.form.display,3)"><b>3</td>');
document.write('<td style="cursor:pointer" onClick="selOper(this.form.display,*)">*</td></tr>');
document.write('<tr height=25 align="center">');
document.write('<td style="cursor:pointer" onClick="changeSign(this.form.display)" colspan="2">+/-</td>');
document.write('<td style="cursor:pointer" onClick="addChar(this.form.display,0)"><b>0</td>');
document.write('<td style="cursor:pointer" onClick="addChar(this.form.display,.)">.</td>');
document.write('<td style="cursor:pointer" onClick="selOper(this.form.display,/)">/</td></tr>');
document.write('</table>');
document.all?document.attachEvent('onclick',checkClick):document.addEventListener('click',checkClick,false);
function lcs(ielem)
{
getObj('fc').style.left=Left(ielem);
getObj('fc').style.top=Top(ielem)+ielem.offsetHeight;
getObj('fc').style.display='';
}
function evtTgt(e)
{
var el;
if(e.target)el=e.target;
else if(e.srcElement)el=e.srcElement;
if(el.nodeType==3)el=el.parentNode; // defeat Safari bug
return el;
}
function EvtObj(e) {
if(!e)e=window.event;return e;
}
function cs_over(e) {
evtTgt(EvtObj(e)).style.background='#FFEBCC';
}
function cs_out(e) {
evtTgt(EvtObj(e)).style.background='#FFFFFF';
}
getObj('fc').onmouseover=cs_over;
getObj('fc').onmouseout=cs_out;
</script>
<script language="LiveScript">
var dotdown = 0;
var x=0
var y=0
var operation=0
var eqauldown=0
var twiceoper=0
var isy=0
var level=0
var newnum=0
//проверка введенных символов на корректность
function checkNum(str)
{
for (var i = 0; i < str.length; i++)
{
var ch = str.substring(i, i+1)
if (ch < "0" || ch > "9")
if (ch != "." && ch!="-")
{
alert("invalid entry!")
return false
}
}
return true
}
//функция добавления символа в поле ввода
function addChar(input, character)
{
if (input.value == null || input.value == "0" || newnum == 1)
{
input.value = character
newnum = 0
dotdown = 0
twiceoper = 0
}
else
if (!(dotdown == 1 && character == '.'))
input.value += character
if (character == '.')
dotdown = 1
}
//вычисление результата в зависимости от операции
function calculate(input)
{
var a
var l
switch (operation)
{
case 1:
input.value = eval(x+"+"+y)
break
case 2:
if (y.substring(0,1)=="-")
{
l = y.length
a = y.substring(1,l)
y = a
input.value = eval(x+"+"+y)
}
else
input.value = eval(x+"-"+y)
break
case 3:
input.value = eval(x+"*"+y)
break
case 4:
input.value = eval(x+"/"+y)
break
case 5:
input.value = Math.pow(x,y)
break
}
}
//вызов этой функции осуществляется при нажатии клавиш арифметических операций
function selOper(input, character)
{
equaldown = 0
level++
newnum++
if (newnum == 2)
{
newnum = 1
}
else
{
if (!checkNum (input.value))
{
sbros(input)
return
}
if (level == 1)
{
x = input.value
isy = 0
}
else
{
y = input.value
isy = 1
calculate (input)
x = input.value
level = 1
}
}
switch (character)
{
case '+' :
operation = 1
break
case '-':
operation = 2
break
case '*':
operation = 3
break
case '/':
operation = 4
break
}
}
//удаление символа из строки ввода
function deleteChar(input)
{
if (newnum != 1)
input.value = input.value.substring(0, input.value.length - 1)
}
function changeSign(input)
{
if(input.value.substring(0, 1) == "-")
input.value = input.value.substring(1, input.value.length)
else
input.value = "-" + input.value
}
//инициализация всех используемых переменных
function sbros(input)
{
newnum = 0
operation = 0
dotdown = 0
x = 0
y = 0
isy = 0
level = 0
input.value = 0
}
//предварительные действия при вычислении результата
function equal(input)
{
var f=0
newnum =1
if (isy == 1)
{
calculate(input)
newnum = 1
x = input.value
}
else
{
if (level!=0 && equaldown==0)
{
y = input.value
isy = 1
calculate(input)
x = input.value
newnum = 1
}
}
if (level == 1)
{
level = 0
isy = 0
equaldown = 1
}
}
</script>
</head>
<body>
<center>
<form>
<input type="text" name="display" size="10" value="0" maxlength="10"
onfocus="this.select();lcs(this)"
onclick="event.cancelBubble=true;this.select();lcs(this)"
readonly>
</form>
</center>
</body>
</html>