var p,q,x1,x2,nf,auto=(1==0);


function neu()
{
	clear(0);
	var L=document.f.level.selectedIndex;
	//document.f.reset();
	for(i=0;i<document.images.length;i++)document.images[i].scr="nix.gif";
	document.f.p.value="";document.f.q.value="";
	document.f.f00.value="";document.f.f01.value="";document.f.f02.value="";
	document.f.f10.value="";document.f.f11.value="";document.f.f12.value="";
	document.f.f20.value="";document.f.f21.value="";
	document.f.f40.value="";document.f.f41.value="";document.f.f42.value="";
	document.f.f50.value="";document.f.f51.value="";document.f.f52.value="";
	document.f.level.selectedIndex=L;
	document.images[23].src="nix.gif";
	document.images[27].src="nix.gif";
	document.images[31].src="nix.gif";
	document.images[32].src="nix.gif";
	document.images[34].src="nix.gif";
	document.images[35].src="nix.gif";
	x1=Math.floor(Math.random()*40-20);
	do{
	x2=Math.floor(Math.random()*40-20);
	}while(x2==-x1);
	if(Math.random()<0.2)x2=x1;
	if(x1>x2){var xx=x1;x1=x2;x2=xx;}
	p=-x1-x2;
	//if(Math.random()<.2)q=p*p/4+Math.floor(Math.random()*5);
	q=x1*x2;
	nf=formatTerm("x² + "+p+"x + "+q);
	var t="";
	var a= Math.floor(Math.random()*30-15)/2;if(a==0)a=-1;
	var b= Math.floor(Math.random()*20-10);
	var c= Math.floor(Math.random()*20-10);
	var d;
	do{d=Math.floor(Math.random()*20-10);}while(Math.abs(d)==Math.abs(a));
	var e= Math.floor(Math.random()*20-10);
	var f= Math.floor(Math.random()*20-10);
	var level=13*(L+1)/5+3;
	var typ=Math.floor(Math.random()*level); //typ=8;
	if (typ==0)typ=1;
	switch(typ)
	{
	case 0:
		t="x² + "+p+"x + "+q+" = 0";	break;
	case 1:
		t="x² + "+p+"x = " + (-q);	break;
	case 2:
		t=a+"x² + "+a*p+"x + "+(a*q)+" = 0";	break;
	case 3:
		t=a+"x² + "+a*p+"x = " + (-a*q);	break;
	case 4:
		t="x² + "+q+" = "+(-p)+"x";	break;
	case 5:
		t="x² = " + (-q) +" + "+(-p)+"x";	break;
	case 6:
		t=a+"x² + "+(a*q)+" = "+(-a*p)+"x";	break;
	case 7:
		b=Math.round(b/3);c=Math.round(c/5);
		if((b==0)||(b==-1))b=1;if(c==0)c=1;if(d==0)d=1;
		a=b*c;
		t=a+"x² = "+(-b)+"·("+c*p+"x + "+(c*q)+")"; break;
	case 8:
		b=Math.round(b/3);c=Math.round(c/5);d=Math.round(d/5);
		if((b==0)||(b==-1))b=1;if(c==0)c=1;if(d==0)d=1;
		a=b*c;
		if(Math.random()>.4)
			{t=a+"x² +"+(-d*b)+" = "+(-b)+"·("+(c*p)+"x + "+(c*q+d)+")"; break;}
		else
			{t=a+"x² +"+(-d*b)+" = "+(-b)+"·("+(c*q+d)+" + "+(c*p)+"x)"; break;}
	case 9:
		t=a+"x² = " + (-a*q) +" + "+(-a*p)+"x";	break;
	case 10:
		t=(a)+"x² + "+(p*a)+"x + "+(a*q+f)+" = " + (f); break;
	case 11:
		t=(a)+"x·("+(p)+" + x) + "+(a*q+f)+" = " + (f); break;
	case 12:
		t=(d+a)+"x² + "+(p*a+e)+"x + "+(q*a)+" = "+(d)+"x² + "+(e)+"x"; break;
	case 13:
		t=(a+d)+"x² + "+(e)+"x + "+(a*q+f)+" = "+(d)+"x² + "+(e-p*a)+"x + "+(f); break;
	case 14:
		f=Math.round(b/4);g=Math.round(c/4);
		if(f==0)f=1;if(g==0)g=-1;if(b==0)b=1;if(c==0)c=1;if(d==0)d=1;if(e==0)e=-1;
		a=f*g;
		var h=Math.floor(Math.random()*20-10);if(h==0)h=2;
		var k=Math.floor(Math.random()*20-10);if(k==0)k=-2;
		if(Math.random()>0.5)
			{t="("+f+"x + "+h+")·("+k+" + "+g+"x) = "+(f*k+h*g-a*p)+"x + "+(h*k-a*q) ;break;}
		else
			{t="("+f+"x + "+h+")·("+g+"x + "+k+") = "+(f*k+h*g-a*p)+"x + "+(h*k-a*q) ;break;}
	case 15:
		if(b==0)b=1;if(c==0)c=1;if(d==0)d=1;if(e==0)e=-1;
		f=Math.sqrt(Math.abs(a+b*d));if(f<1)f=1;
		for(f=Math.round(f);f>1;f--){if((a+b*d)%f==0)break;}var g=(a+b*d)/f;
		var h=Math.floor(Math.random()*20-10);if(h==0)h=2;
		var k=Math.round((a*p+b*e+c*d-g*h)/f);
		var m=(a*p+b*e+c*d-g*h)-k*f;
		t="("+b+"x + "+c+")("+d+"x + "+e+") +"+(-m)+"x = ("+h+" + "+f+"x)("+g+"x + "+k+") + "+(a*q+c*e-h*k);break;
	default: alert("Hallo");
	}
	T=t;
	t=formatTerm(t);
	if(Math.random()>.7)
	{
		tt=t.split(" = ");
		t=tt[1]+" = "+tt[0];
	}
	t=t.replace(/\+ =/,"=").replace(/- =/,"=").replace(/= \- /,"= -").replace(/= \+/,"=");
	document.f.g0.value=t;
	//document.f.u1.value="p="+p+"    q="+q;
	//document.f.u2.value="x1="+x1+"    x2="+x2;
	//document.f.u3.value=typ;
	if(t=="0x² = 0")alert(T);
	document.f.neubutton.focus();
	document.f.u0.focus();
}

function checkgl()
{
	var i;
	for(i=1;i<12;i++)
	{
		var t="",t0,u="";
		if((document.images[i*2].src.indexOf("haken1.gif")>-1)&&(document.images[i*2-1].src.indexOf("haken1.gif")>-1))continue;
		if(i>0)eval("u=document.f.u"+(i-1)+".value;");
		u=u.toLowerCase();
		if(u.indexOf("t")>-1)u="V";
		eval("t=document.f.g"+i+".value;");
		if((u!="")&&(u.toLowerCase().indexOf("v")==-1))u=formatTerm(u).replace(/ +/g,"");
		if(u.indexOf(":-")>-1)
		{
			alert("Beim Dividieren durch negative Zahlen muß der Divisor eingeklammert werden, denn es dürfen nicht zwei Rechenzeichen hintereinander stehen.");
			document.images[i*2-1].src="roterpunkt.gif";
			clear(i+1);
			eval("document.f.u"+(i-1)+".focus();document.f.u"+(i-1)+".select();");
			return;
		}
		if(u.indexOf("·-")>-1)
		{
			alert("Beim Multiplizieren mit einer negativen Zahl muß der Faktor eingeklammert werden, denn es dürfen nicht zwei Rechenzeichen hintereinander stehen.");
			document.images[i*2-1].src="roterpunkt.gif";
			clear(i+1);
			eval("document.f.u"+(i-1)+".focus();document.f.u"+(i-1)+".select();");
			return;
		}
		if((u!="")&&(t=="")&&(!auto))
		{
			alert("Die Gleichung entsprechend umformen!");
			clear(i+1);
			eval("document.f.g"+i+".focus();");
			return;
		}
		if((t=="")&&(!auto))
		{
			clear(i);
			if(testNormalform(i-1))
			{
				alert("Normalform gefunden!\nJetzt müssen p und q abgelesen werden.");
				document.f.p.focus();
				eval("document.f.g"+(i-1)+".focus()");
				document.f.p.focus();
				document.f.p.select();
				return;		
			}
			autoSetFocus();return;
		}
		t=formatTerm(t);
		if(u.substr(0,1)=="-")u="- "+u.substr(1,u.length);
		//eval("document.f.u"+(i-1)+".value=u;");
		eval("t0=document.f.g"+(i-1)+".value;");
		t0=formatTerm(t0);
		eval("document.f.g"+i+".value=t;");
		//if(i>0)u=u.replace(/,/g,".").replace(/ +/g,"");
		t=t.replace(/,/g,".").replace(/ +/g,"");
		if(t!="")
		{
			t=makeParseble(t);
			var T=t.split("=");
			if(T.length==1)
			{
				eval("document.f.g"+i+".focus();document.f.g"+i+".select();");
				alert("Keine Gleichung!");
				return;
			}
			var tt=T[0]+"-("+T[1]+")";
			t0=makeParseble(t0);
			var T0=t0.split("=");
			if((u.replace(/ +/g,"")!="")&&(u.toLowerCase().indexOf("v")==-1))
			{
				eval("document.f.u"+(i-1)+".value=u.replace(/ +/g,'');");
				u=(makeParseble(u));
				if((u.indexOf("x")>-1)&&(u.indexOf("/")>-1))
				{
					alert("Es ist nicht sinnvoll, durch x zu teilen.");
					document.images[i*2-1].src="roterpunkt.gif";
					clear(i+1);
					eval("document.f.u"+(i-1)+".focus();document.f.u"+(i-1)+".select();");
					return;
				}
				for(var x=-10;x<11;x+=2)
				{
					document.parser.parse("("+T0[0]+")"+u);
					var uy0=document.parser.calcY(x);
					document.parser.parse("("+T0[1]+")"+u);
					var uy1=document.parser.calcY(x);
					document.parser.parse(T[0]);					
					var uy2=document.parser.calcY(x);
					document.parser.parse(T[1]);					
					var uy3=document.parser.calcY(x);
					if((uy0!=uy2)&&(uy1!=uy3))
					{
						alert("Die Angabe der Umformung ist nicht korrekt");
						document.images[i*2-1].src="roterpunkt.gif";
						document.images[i*2].src="roterpunkt.gif";
						clear(i+1);
						eval("document.f.u"+(i-1)+".focus();document.f.u"+(i-1)+".select();");
						return;
					}
					if((uy0!=uy2)||(uy1!=uy3))
					{
						alert("Auf der "+((uy0==uy2)?"rechten":"linken")+" Seite wurde falsch umgeformt.");
						document.images[i*2].src="roterpunkt.gif";
						clear(i+1);
						eval("document.f.g"+(i)+".focus();document.f.g"+(i)+".select();");
						return;
					}
				}
			}
			else
			{
				var U0=0;
				for(var x=-10;x<11;x+=2)
				{
					document.parser.parse(T0[0]);
					var uy0=document.parser.calcY(x);
					document.parser.parse(T0[1]);
					var uy1=document.parser.calcY(x);
					document.parser.parse(T[0]);					
					var uy2=document.parser.calcY(x);
					document.parser.parse(T[1]);					
					var uy3=document.parser.calcY(x);
					if((uy0!=uy1)&&(uy2!=uy3))
					{
						U0++;
						continue;
					}
					if((uy0!=uy2)&&(uy1!=uy3))
					{
					//	alert(uy0+" "+uy1+" "+uy2+" "+uy3);
						alert("Die Angabe der Umformung fehlt oder ist falsch");
						clear(i+1);
						eval("document.f.u"+(i-1)+".focus();document.f.u"+(i-1)+".select();");
						return;
					}
					if(((uy0!=uy2)&&(uy1==uy3))||((uy0==uy2)&&(uy1!=uy3)))
					{
						alert("Auf der "+((uy0==uy2)?"rechten":"linken")+" Seite wurde falsch vereinfacht");
						clear(i+1);
						eval("document.f.g"+(i)+".focus();document.f.g"+(i)+".select();");
						return;
					}
				}
				if(U0==10)
				{
					clear(i+1);
					document.images[2*i-1].src="haken1.gif";
					document.images[2*i].src="haken1.gif";
					eval("document.f.u"+(i-1)+".value='V';");
					if(testNormalform(i-1))
					{
						document.f.p.focus();
						eval("document.f.g"+(i)+".focus()");
						document.f.p.focus();return;		
					}
					autoSetFocus();
					return;						
					}
				eval("document.f.u"+(i-1)+".value='V';");
			}

			document.parser.parse(tt);
			
			var ns=String(document.parser.getNullstellen(x1-5,x2+5,20,0.001,1e-14,100000,";")).split(";");
			if((ns.length==1)&&(x1==x2))ns[1]=ns[0];
			if(ns.length!=2)
			{
				document.images[2*i].src="roterpunkt.gif";
				clear(i+1);
//				alert("Die "+(i+1)+". Gleichung ist nicht äquivalent!\nL={"+x1+" ;  "+x2+"}\nns={"+ns+"}");
				alert("Die Gleichung ist nicht äquivalent!");
				break;
			}
			var n1=Number(ns[0].replace(/,/,".")),n2=Number(ns[1].replace(/,/,"."));
			if(n1>n2){var nn=n1;n1=n2;n2=nn;}
//			if((n1!=x1)||(n2!=x2)){alert("Gleichung "+i+" ist nicht äquivalent\nx1 = "+x1+"\nx2 = "+x2+"\nn1 = "+n1+"\nn2 = "+n2);break;}
			if((n1!=x1)||(n2!=x2)){alert("Die Gleichung ist nicht äquivalent.");break;}
			document.images[2*i].src="haken1.gif";
		}
		else
		{
			clear(i);
			autoSetFocus();
			break;
		}
		document.images[2*i-1].src="haken1.gif";
		document.images[2*i].src="haken1.gif";
	}
	i=autoSetFocus();
}

function checkpq()
{
	var pp=Number(document.f.p.value.replace(/,/,"."));
	var qq=Number(document.f.q.value.replace(/,/,"."));
	var t="";var ps=(1==0),qs=(1==0);
	if((p==qq)&&(q=pp)&&(p!=q)){t+="p und q vertauscht!\n";ps=true;}
	if(document.f.p.value.indexOf("x")>-1){t+="Die Variable x gehört nicht zu p!\n";ps=true;}
	if((pp!=p)&&(-pp==p)){t+="Das Vorzeichen von p ist falsch.\n";ps=true;}
	if((pp!=p)&&(-pp!=p)){t+="p ist falsch.\n";ps=true;}
	if((qq!=q)&&(-qq==q)){t+="Das Vorzeichen von q ist falsch.\n";qs=true}
	if((qq!=q)&&(-qq!=q)){t+="q ist falsch.\n";qs=true;}
	if(t!=""){alert(t);document.images[23].src="roterpunkt.gif";return;}
	document.images[23].src="haken1.gif";
	if(qs){document.f.q.focus();}
	if(ps){document.f.p.focus();}
	if((ps==false)&&(qs==false)){document.f.f50.focus();document.f.p.focus();document.f.f00.focus();}
}

function checkf0()
{
	var pp1=Number(document.f.f00.value.replace(/,/,"."));
	var pp2=Number(document.f.f01.value.replace(/,/,"."));
	var qq=Number(document.f.f02.value.replace(/,/,"."));
	var s0=(0==1),s1=s0,s2=s0;
	document.images[27].src="roterpunkt.gif";
	if((pp1!=p)&&(-pp1==p)){document.f.f00.focus();document.f.f00.select();alert("Das Vorzeichen ist falsch.");document.f.f00.focus();return;}
	if((qq!=q)&&(-qq==q)){document.f.f02.focus();document.f.f02.select();alert("Das Vorzeichen ist falsch.");document.f.f02.focus();return;}
	if(pp1!=p){document.f.f00.focus();document.f.f00.select();alert("Eingabe falsch.");document.f.f00.focus();return;}
	if(Math.abs(pp2)!=Math.abs(p)){document.f.f01.focus();document.f.f01.select();alert("Eingabe falsch.");document.f.f01.focus();return;}
	if(qq!=q){document.f.f02.focus();document.f.f02.select();alert("Eingabe falsch.");document.f.f02.focus();return;}
	document.images[27].src="haken1.gif";
	document.f.f10.focus();
}

function checkf1()
{
	var pp1=Number(document.f.f10.value.replace(/,/,"."));
	var pp2=Number(document.f.f11.value.replace(/,/,"."));
	var qq=Number(document.f.f12.value.replace(/,/,"."));
	var v=(document.f.f1v.selectedIndex==1)?q:-q;
	document.images[31].src="roterpunkt.gif";
	if((pp1!=-p/2)&&(pp1==p/2)){document.f.f10.focus();document.f.f10.select();alert("Das Vorzeichen ist falsch.");document.f.f10.focus();return;}
	if((pp2!=p*p/4)&&(-pp2==p*p/4)){document.f.f11.focus();document.f.f11.select();alert("Das Vorzeichen ist falsch.");document.f.f11.focus();return;}
	if(qq<0){document.f.f12.focus();document.f.f12.select();alert("Wähle das Rechenzeichen bitte mit der Auswahlliste.");document.f.f12.focus();return;}
	if(qq!=Math.abs(q)){document.f.f12.focus();document.f.f12.select();alert("Eingabe falsch.");document.f.f12.focus();return;}
	if(v!=qq){document.f.f1v.focus();alert("Das Vorzeichen/Rechenzeichen ist falsch.");document.f.f1v.focus();return;}
	if(pp1==p){document.f.f10.focus();document.f.f10.select();alert("Eingabe falsch.\nDer Teilausdruck muß hier schon berechnet werden.");document.f.f10.focus();return;}
	if(pp1!=-p/2){document.f.f10.focus();document.f.f10.select();alert("Eingabe falsch.");document.f.f10.focus();return;}
	if((pp2==-p/2)&&(pp2!=p*p/4)){document.f.f11.focus();document.f.f11.select();alert("Eingabe falsch.\nDer Teilausdruck muß hier schon berechnet werden.");document.f.f11.focus();return;}
	if(pp2!=p*p/4){document.f.f11.focus();document.f.f11.select();alert("Eingabe falsch.");document.f.f11.focus();return;}
	//if((qq>0)&&(document.f.f12.value.indexOf("+")==-1)){document.f.f12.focus();document.f.f12.select();alert("Das Rechenzeichen + fehlt.");document.f.f12.focus();return;}
	//if(qq!=-q){document.f.f12.focus();document.f.f12.select();alert("Eingabe falsch.");document.f.f12.focus();return;}
	document.images[31].src="haken1.gif";
	document.f.f20.focus();
}

function checkf2()
{
	var pp1=Number(document.f.f20.value.replace(/,/,"."));
	var pp2=Number(document.f.f21.value.replace(/,/,"."));
	document.images[32].src="roterpunkt.gif";
	if((pp1!=-p/2)&&(pp1==p/2)){document.f.f20.focus();document.f.f20.select();alert("Das Vorzeichen ist falsch.");document.f.f20.focus();return;}
	if(pp1!=-p/2){document.f.f20.focus();document.f.f20.select();alert("Eingabe falsch.");document.f.f20.focus();return;}
	if(pp2!=p*p/4-q){document.f.f21.focus();document.f.f21.select();alert("Eingabe falsch.");document.f.f21.focus();return;}
	document.images[32].src="haken1.gif";
	document.f.f40.focus();
}

function checkf4()
{
	var pp1=Number(document.f.f40.value.replace(/,/,"."));
	var pp2=Number(document.f.f41.value.replace(/,/,"."));
	var pp3=Number(document.f.f42.value.replace(/,/,"."));
	document.images[34].src="roterpunkt.gif";
	if((pp1!=-p/2)&&(pp1==p/2)){document.f.f40.focus();document.f.f40.select();alert("Das Vorzeichen ist falsch.");document.f.f40.focus();return;}
	if(pp1!=-p/2){document.f.f40.focus();document.f.f40.select();alert("Eingabe falsch.");document.f.f40.focus();return;}
	if(pp2!=(x2-x1)/2){document.f.f41.focus();document.f.f41.select();alert("Eingabe falsch.");document.f.f41.focus();return;}
	if(document.f.f42.value==""){document.f.f42.focus();document.f.f42.select();alert("Wurzel korrekt.\nEingabe für x1 fehlt.");document.f.f42.focus();return;}
	if(pp3!=x1){document.f.f42.focus();document.f.f42.select();alert("Eingabe falsch.");document.f.f42.focus();return;}
	document.images[34].src="haken1.gif";
	document.f.f50.value=document.f.f40.value;
	document.f.f51.value=document.f.f41.value;
	document.f.f52.focus();
}

function checkf5()
{
	var pp1=Number(document.f.f50.value.replace(/,/,"."));
	var pp2=Number(document.f.f51.value.replace(/,/,"."));
	var pp3=Number(document.f.f52.value.replace(/,/,"."));
	document.images[35].src="roterpunkt.gif";
	if((pp1!=-p/2)&&(pp1==p/2)){document.f.f50.focus();document.f.f50.select();alert("Das Vorzeichen ist falsch.");document.f.f50.focus();return;}
	if(pp1!=-p/2){document.f.f50.focus();document.f.f50.select();alert("Eingabe falsch.");document.f.f50.focus();return;}
	if(pp2!=(x2-x1)/2){document.f.f51.focus();document.f.f51.select();alert("Eingabe falsch.\n"+(x2-x1));document.f.f51.focus();return;}
	if(document.f.f52.value==""){document.f.f51.focus();document.f.f52.select();alert("Wurzel korrekt.\nEingabe für x2 fehlt.");document.f.f52.focus();return;}
	if(pp3!=x2){document.f.f51.focus();document.f.f52.select();alert("Eingabe falsch.");document.f.f52.focus();return;}
	document.images[35].src="haken1.gif";
	if(confirm("Richtig!\n\nNeue Aufgabe?",""))neu();
}

function clear(i0)
{
	for(var j=i0;j<12;j++)
	{
		eval("document.f.g"+j+".value=''");
		if(j>0)eval("document.f.u"+(j-1)+".value=''");
		document.images[2*j].src="nix.gif";
		document.images[2*j+1].src="nix.gif";
	}
}	

function autoSetFocus()
{
	for(var i=0;i<12;i++)
	{
		var t="";
		eval("t=document.f.g"+i+".value.replace(/ /g,'');");
		if(t==""){eval("document.f.g"+i+".focus();");return i;}
		eval("t=document.f.u"+i+".value.replace(/ /g,'');");
		if(t==""){eval("document.f.u"+i+".focus();");return i;}
	}
}

function makeParseble(t)
{
	t=t.replace(/,/g,".").replace(/ /g,"").replace(/²/g,"^2").replace(/³/g,"^3").replace(/phi/g,"0.61803398874989").replace(/:/g,"/");
	t=t.replace(/\)\(/g,")*(");
	do{I=t.search(/\dx/);if(I==-1)break;t=t.substr(0,I+1)+"*"+t.substring(I+1,t.length);}while(true);
	do{I=t.search(/\d\(/);if(I==-1)break;t=t.substr(0,I+1)+"*"+t.substring(I+1,t.length);}while(true);
	do{I=t.search(/\)\(/);if(I==-1)break;t=t.substr(0,I+1)+"*"+t.substring(I+1,t.length);}while(true);
	do{I=t.search(/x\(/);if(I==-1)break;t=t.substr(0,I+1)+"*"+t.substring(I+1,t.length);}while(true);
	return t;
}

function formatTerm(t)
{
	t=t.replace(/\./g,",").replace(/-/g," - ").replace(/x2/g,"x²").replace(/\+/g," + ").replace(/\*/g,"·");
	t=t.replace(/\( - /g,"(-").replace(/ 0x²/g," ").replace(/\(1x/g,"(x");
	t=t.replace(/ +/g," ").replace(/\^2/g,"²").replace(/xx/g,"x²");
	t=t.replace(/=/," = ").replace(/\+ \-/g,"- ").replace(/\./g,",").replace(/ 1x/g," x").replace(/ ,/g," 0,").replace(/-,/g,"-0,").replace(/ 0 /g,"");
	if(t.indexOf("1x")==0)t=t.substr(1,t.length);
	if(t.indexOf("-1x")==0)t="-"+t.substr(2,t.length);
	t=t.replace(/\+ 0 /g,"").replace(/\+ 0x/g,"").replace(/ 0 \+/g,"").replace(/ 0x/g,"").replace(/ +/g," ");
	if(t.indexOf("=")>t.length-3)t+=" 0";
	t=t.replace(/\+ =/,"=").replace(/- =/,"=").replace(/= \- /,"= -").replace(/= \+/,"=");
	t=t.replace(/-1x/g,"-x").replace(/-1·\(/g,"-(");
	if(t.substr(0,3)==" - ")t="-"+t.substr(3,t.length);
	var i=t.indexOf("= - ");if(i>-1)t=t.substr(0,i+2)+"-"+t.substr(i+4,t.length);
	while(t.charAt(0)==" ")t=t.substr(1,t.length);
	while(t.charAt(t.length)==" ")t=t.substr(0,t.length-1);
	if(t.substr(0,1)==",")t="0"+t;
	return t;
}

function calc()
{
	var t=document.f.term.value;
	t=makeParseble(t);
	document.parser.parse(t);
	t=String(document.parser.calcY(0)).replace(/\./,",").replace(/-,/,"-0,");
	document.f.erg.value=t;
}

function testNormalform(i)
{
	var t="";
	eval("t=document.f.g"+i+".value.split(' = ');");
	return ((t[0]==nf)||(t[1]==nf));
}

function clearBild(i)
{
	eval("document.images["+(2*i)+"].src='nix.gif'");
	eval("document.images["+(2*i-1)+"].src='nix.gif'");
}