
var side=0.0,end=0.0,skale=0.0, side_b=0.0, end_b=0.0;
function percent()
{

	side=Number(document.s.side.value.replace(/,/,"."));
	end=Number(document.s.end.value.replace(/,/,"."));
	side_b=Number(document.s.side_b.value.replace(/,/,"."));
	//var p=Math.pow(10,2);
	d = end/side*100;
	p = (Math.round(d/0.01)*0.01);
	
	e = side_b*p/100;
	end_b = (Math.round(e/0.01)*0.01)
	document.s.skale.value=p;
	document.s.end_b.value=end_b;
	
}

var start=0.0,erg=0.0;
function inch()
{
	start=Number(document.i.start.value.replace(/,/,"."));
	if (document.i.von.selectedIndex==0)
	{
		if (document.i.nach.selectedIndex==0)
		{
			x=start;
			//y=(Math.round(x/0.01)*0.01);
			document.i.ergebnis.value=start+' mm';
		}
		if (document.i.nach.selectedIndex==1)
		{
			x=start/10;
			var e = Math.pow(10, 2);
 			var y = (Math.round(x * e) / e).toString();
			document.i.ergebnis.value=y+' cm';
		}
		if (document.i.nach.selectedIndex==2)
		{
			x=start/25.4;
			var e = Math.pow(10, 2);
 			var y = (Math.round(x * e) / e).toString();
			document.i.ergebnis.value=y+' inch';
		}
	}
	
	if (document.i.von.selectedIndex==1)
	{
		if (document.i.nach.selectedIndex==0)
		{
			x=start*10;
			var e = Math.pow(10, 2);
 			var y = (Math.round(x * e) / e).toString();
			document.i.ergebnis.value=y+' mm';
		}
		if (document.i.nach.selectedIndex==1)
		{
			x=start;
			//y=(Math.round(x/0.01)*0.01);
			document.i.ergebnis.value=start+' cm';
		}
		if (document.i.nach.selectedIndex==2)
		{
			x=start/0.254;
			var e = Math.pow(10, 2);
 			var y = (Math.round(x * e) / e).toString();
			document.i.ergebnis.value=y+' inch';
		}
	}
	
	if (document.i.von.selectedIndex==2)
	{
		if (document.i.nach.selectedIndex==0)
		{
			x=start*25.4;
			var e = Math.pow(10, 2);
 			var y = (Math.round(x * e) / e).toString();
			document.i.ergebnis.value=y+' mm';
		}
		if (document.i.nach.selectedIndex==1)
		{
			x=start*0.254;
			var e = Math.pow(10, 2);
 			var y = (Math.round(x * e) / e).toString();
			document.i.ergebnis.value=y+' cm';
		}
		if (document.i.nach.selectedIndex==2)
		{
			x=start;
			//y=(Math.round(x/0.01)*0.01);
			document.i.ergebnis.value=start+' inch';
		
		}
	}
	
}

var a=0.0,b=0.0,f=0.0,u=0.0,d=0.0;
function rechteck()
{
	zahl=0;
	
	a_x=Number(document.r.a.value.replace(/,/,".")); 
	b_x=Number(document.r.b.value.replace(/,/,".")); 
	d_x=Number(document.r.d.value.replace(/,/,".")); 
	f_x=Number(document.r.f.value.replace(/,/,"."));
	u_x=Number(document.r.u.value.replace(/,/,".")); 
	
	a=Number(document.r.a.value.replace(/,/,".")); if (a>0) { zahl++; }
	b=Number(document.r.b.value.replace(/,/,".")); if (b>0) { zahl++; }
	d=Number(document.r.d.value.replace(/,/,".")); if (d>0) { zahl++; }
	f=Number(document.r.f.value.replace(/,/,".")); if (f>0) { zahl++; }
	u=Number(document.r.u.value.replace(/,/,".")); if (u>0) { zahl++; }
	

	if (zahl > 2) 
	{ 
	alert ("Bitte maximal zwei Werte Eingeben!")
	}
	
	if (a_x>0)
	{
		document.r.a_.value=a;
		
		if(b_x>0)
		{
			document.r.b_.value=b; // Seite B
			
			d = Math.sqrt(a*a+b*b);
			e = Math.pow(10, 2);
 			y = (Math.round(d * e) / e).toString();
			document.r.d_.value=y; // Diagonale
			
			f = a*b;
			e = Math.pow(10, 2);
 			y = (Math.round(f * e) / e).toString();
			document.r.f_.value=y; // Fläche
			
			u = 2*(a+b);
			e = Math.pow(10, 2);
 			y = (Math.round(u * e) / e).toString();
			document.r.u_.value=y; // Umfang
			
			exit();
		
		}
		
		if(d_x>0)
		{
		
			b = Math.sqrt(d*d-a*a);
			e = Math.pow(10, 2);
 			y = (Math.round(b * e) / e).toString();
			document.r.b_.value=y; // Seite B
			
			document.r.d_.value=d; // Diagonale
			
			f = a*b;
			e = Math.pow(10, 2);
 			y = (Math.round(f * e) / e).toString();
			document.r.f_.value=y; // Fläche
			
			u = 2*(a+b);
			e = Math.pow(10, 2);
 			y = (Math.round(u * e) / e).toString();
			document.r.u_.value=y; // Umfang
			
			exit();
		}
		
		if(f_x>0)
		{
		
			b = f/a; 
			e = Math.pow(10, 2);
 			y = (Math.round(b * e) / e).toString();
			document.r.b_.value=y; // Seite B
			
			d = Math.sqrt(a*a+b*b);
			e = Math.pow(10, 2);
 			y = (Math.round(d * e) / e).toString();
			document.r.d_.value=y; // Diagonale
			
			document.r.f_.value=f;// Fläche
			
			u = 2*(a+b);
			e = Math.pow(10, 2);
 			y = (Math.round(u * e) / e).toString();
			document.r.u_.value=y; // Umfang
			
			exit();
		}
		
		if(u_x>0)
		{
		
			b = u/2-a;
			e = Math.pow(10, 2);
 			y = (Math.round(b * e) / e).toString();
			document.r.b_.value=y; // Seite B
			
			d = Math.sqrt(a*a+b*b);
			e = Math.pow(10, 2);
 			y = (Math.round(d * e) / e).toString();
			document.r.d_.value=y; // Diagonale
			
			f = a*b;
			e = Math.pow(10, 2);
 			y = (Math.round(f * e) / e).toString();
			document.r.f_.value=y; // Fläche
			
			document.r.u_.value=u; // Umfang
			exit();
		}
	
		
	
	}
	
	
	if (b_x>0)
	{
		document.r.b_.value=b; // Seite b
				
		if(d_x>0)
		{
		
			a = Math.sqrt(d*d-b*b);
			e = Math.pow(10, 2);
 			y = (Math.round(a * e) / e).toString();
			document.r.a_.value=y; // Seite A
			
			document.r.d_.value=d; // Diagonale
			
			f = a*b;
			e = Math.pow(10, 2);
 			y = (Math.round(f * e) / e).toString();
			document.r.f_.value=y; // Fläche
			
			u = 2*(a+b);
			e = Math.pow(10, 2);
 			y = (Math.round(u * e) / e).toString();
			document.r.u_.value=y; // Umfang
			exit();
		
		}// Ende if B - D
		
		if(f_x>0)
		{
		
			a = f/b; 
			e = Math.pow(10, 2);
 			y = (Math.round(a * e) / e).toString();
			document.r.a_.value=y; // Seite A
			
			d = Math.sqrt(a*a+b*b);
			e = Math.pow(10, 2);
 			y = (Math.round(d * e) / e).toString();
			document.r.d_.value=y; // Diagonale
			
			document.r.f_.value=f;// Fläche
			
			u = 2*(a+b);
			e = Math.pow(10, 2);
 			y = (Math.round(u * e) / e).toString();
			document.r.u_.value=y; // Umfang
			exit();
		
		} // Ende if B - F
		
		if(u_x>0)
		{
		
			a = u/2-b;
			e = Math.pow(10, 2);
 			y = (Math.round(a * e) / e).toString();
			document.r.a_.value=y; // Seite A
			
			d = Math.sqrt(a*a+b*b);
			e = Math.pow(10, 2);
 			y = (Math.round(d * e) / e).toString();
			document.r.d_.value=y; // Diagonale
			
			f = a*b;
			e = Math.pow(10, 2);
 			y = (Math.round(f * e) / e).toString();
			document.r.f_.value=y; // Fläche
			
			document.r.u_.value=u; // Umfang
			exit();

		} // Ende if B - U
		
	
	} // Ende if B
	
	if (d_x>0)
	{
		document.r.d_.value=d; // Diagonale
		
		if(f_x>0)
		{
		
			a = Math.sqrt(2*(d*d-Math.sqrt(d*d*d*d-4*f*f)))/2; 
			e = Math.pow(10, 2);
 			y = (Math.round(a * e) / e).toString();
			document.r.a_.value=y; // Seite A
			
			b = Math.sqrt(2*(d*d+Math.sqrt(d*d*d*d-4*f*f)))/2;
			e = Math.pow(10, 2);
 			y = (Math.round(b * e) / e).toString();
			document.r.b_.value=y; // Seite B
			
			document.r.d_.value=d; // Diagonale
			
			f = a*b;
			e = Math.pow(10, 2);
 			y = (Math.round(f * e) / e).toString();
			document.r.f_.value=y; // Fläche
			
			u = 2*(a+b);
			e = Math.pow(10, 2);
 			y = (Math.round(u * e) / e).toString();
			document.r.u_.value=y; // Umfang
			exit();
		
		} // Ende if D - F
		
		if(u_x>0)
		{
			a=(u-Math.sqrt(8*d*d-u*u))/4;
			e = Math.pow(10, 2);
 			y = (Math.round(a * e) / e).toString();
			document.r.a_.value=y; // Seite A
			
			b=(Math.sqrt(8*d*d-u*u)+u)/4;
			e = Math.pow(10, 2);
 			y = (Math.round(b * e) / e).toString();
			document.r.b_.value=y; // Seite B
			
			d = Math.sqrt(a*a+b*b);
			e = Math.pow(10, 2);
 			y = (Math.round(d * e) / e).toString();
			document.r.d_.value=y; // Diagonale
			
			f = a*b;
			e = Math.pow(10, 2);
 			y = (Math.round(f * e) / e).toString();
			document.r.f_.value=y; // Fläche
			
			document.r.u_.value=u; // Umfang
			exit();

		} // Ende if D - U
	
	}// Ende if D
	
	if (f_x>0)
	{
		document.r.f_.value=f; // Diagonale
		
		if(u_x>0)
		{
		
			a=(u-Math.sqrt(u*u-16*f))/4;
			e = Math.pow(10, 2);
 			y = (Math.round(a * e) / e).toString();
			document.r.a_.value=y; // Seite A
			
			b=(Math.sqrt(u*u-16*f)+u)/4;;
			e = Math.pow(10, 2);
 			y = (Math.round(b * e) / e).toString();
			document.r.b_.value=y; // Seite B
			
			d = Math.sqrt(a*a+b*b);
			e = Math.pow(10, 2);
 			y = (Math.round(d * e) / e).toString();
			document.r.d_.value=y; // Diagonale
			
			f = a*b;
			e = Math.pow(10, 2);
 			y = (Math.round(f * e) / e).toString();
			document.r.f_.value=y; // Fläche
			
			document.r.u_.value=u; // Umfang
			exit();

		} // Ende if D - U
		
	} // Ende if F

}

function exit()
{

}


