

function ChkNumber(Nummer)
	{var Variable="";
	 var Ausgabe = "";
	Komma = 0;

	        Gross = Nummer.length - 1;
		for(i = Gross; i >= 0; i--)
		{ if (isNaN(Nummer.charAt(i)) != true)
			Variable=Variable.concat(Nummer.charAt(i));

		 if(Nummer.charAt(i) == "-")
			{if(Nummer.charAt(0) == "-") 
				Variable=Variable.concat("-");
			}

		if (Nummer.charAt(i)=="," && Komma==0 || Nummer.charAt(i)=="." && Komma==0)
			{Variable=Variable.concat(".");
			 Komma = Komma+1;
			}

		}
		Gross = Variable.length - 1;
		if (Gross == 0)
			Ausgabe="0";
		for(i = Gross; i >= 0; i--)
		{ 
		if (i == Gross && Variable.charAt(i)=="0" )
			{Ausgabe= Ausgabe;
			 Gross=Gross-1;}

		else
			Ausgabe= Ausgabe.concat(Variable.charAt(i));		
		}
		return Ausgabe;

	}   

function GebGerichtA(StreitW,Fakt,Aus,MBK,KlG,BerG)
{	if (StreitW == NaN)
		StreitW = 0;
	if (StreitW > 30000000)
		{StreitW = 30000000;}
	Ergebn = 0;
	
	if (Aus == true)
		{ 
		  if (MBK == true || KlG == true || BerG == true)
			{

			if (Fakt > 1.5)
				{;
				 Fakt = Fakt- 0.75;
				}
			else 
				{
				Fakt = parseInt(Fakt/0.02)/100;
				}
			}
			Ergebn = parseInt((RAGeb(StreitW)*Fakt*100)+0.5)/100;
			if (Ergebn	<10)
				{Ergebn = 10;}
		}

	return Ergebn;

}

function GebMB(StreitW,Fakt,MW)
{	if (StreitW == NaN)
		StreitW = 0;
	if (StreitW > 30000000)
		{StreitW = 30000000;}
	Ergebn = 0;

			Ergebn = parseInt((RAGeb(StreitW)*Fakt*100*MW)+0.5)/100;
			if (Ergebn	<10)
				{Ergebn = 10*MW;}

	return Ergebn;

}

function GebGerichtB(StreitW,MBK,KlG,BerG,Ges)
{	if (StreitW == NaN)
		StreitW = 0;
	if (StreitW > 30000000)
		{StreitW = 30000000;}

	Ergebn = 0;
	Fakt = 0;

 	if (MBK == true || KlG == true || BerG == true)
		{ 
		  if (MBK == true) 
			Fakt = 1.5;
		 
		 if (KlG == true)
			Fakt = 2.5;
		
		if (BerG == true)
			Fakt = 2.8;
			
			Ergebn = parseInt((RAGeb(StreitW)*Fakt*100)+0.5)/100;
			if (Ergebn	<10)
				{Ergebn = 10;}
	if (Ges== true)
		Ergebn = Ergebn *2;
		
		}

	return Ergebn;

}

function GebGerichtC(StreitW,MBK,KlG,BerG,Ver)
{	if (StreitW == NaN)
		StreitW = 0;
	if (StreitW > 30000000)
		{StreitW = 30000000;}

	Ergebn = 0;
	Fakt = 0;

	if (MBK == true || KlG == true || BerG == true)
		{ 
		  if (MBK == true) 
			Fakt = 0.5;
		 
		 if (KlG == true)
			{Fakt = 3.0;
			if (Ver == true)
				Fakt = 1.0;
			}
		
		if (BerG == true)
			{Fakt = 4.0;
			if (Ver == true)
				Fakt = 2.0;
			}
		
	Ergebn = parseInt((GerGebZR(StreitW)*Fakt*100)+0.5)/100;

		  if (MBK == true && Ergebn < 23) 
			{DatE = confirm("Der Mahnbescheid wird nach dem 01.07.2006 bei Gericht eingereicht (sonst Abbrechen drücken)");

			 if (DatE == true)
			  	{
				  Ergebn=23 ;
				}
			else
				{
				if (Ergebn < 18)
					{ 
				  	  Ergebn=18 ;
					}
				}
			}
		}

	return Ergebn;

}

function Probe(Wert)
{	if(Wert)
		Wert = true;	

	return Wert;	
}

function GebGerichtD(StreitW,MBK,KlG,BerG,Ver)
{	
	if (StreitW == NaN)
		{StreitW = 0;}

	if (StreitW > 30000000)
		{StreitW = 30000000;}

	Ergebn = 0;
	Fakt = 0;

	if ( Ver == true)
		{
		 if (MBK == true || KlG == true || BerG == true)
			{Fakt = 1.0;
			 if (BerG == true)
				{Fakt = 1.3;
				}

			 Ergebn = parseInt((RAGeb(StreitW)*Fakt*100)+0.5)/100;

			 if (Ergebn	<10)
				{Ergebn = 10;}
			}
		else
			{Fakt = 1.5;
			 Ergebn = parseInt((RAGeb(StreitW)*Fakt*100)+0.5)/100;

			 if (Ergebn	<10)
				{Ergebn = 10;}
			}
		}
		

	return Ergebn;

}

function PTP(Wert1,Wert2,Wert3,Wert4,Ges)
	{ 
	if (Ges==true)
		Wert2= Wert2 / 2;

	
	Ergebn = Wert1*1+Wert2*1+Wert3*1+Wert4*1;

	Ergebn = Ergebn * 0.2;

	if (Ergebn > 20)
		{Ergebn = 20;}

	/*alert (Ges + Ergebn);*/

	if (Ges==true)
		Ergebn= Ergebn * 2;

	return Ergebn;
	}


function GebGerichtE(StreitW,Fakt)
	{ if (StreitW == NaN)
		{StreitW = 0;}
	if (StreitW > 30000000)
		{StreitW = 30000000;}


	Ergebn = 0;
	
	Ergebn = parseInt((RAGeb(StreitW)*Fakt*100)+0.5)/100;

	return Ergebn;
	}

function Summe(Wert1,Wert2,Wert3,Wert4,WertG,Wert5,Fakt)
	{
	Ergebn =(Wert1*1+Wert2*1+Wert3*1+Wert4*1+Wert5*1)*Fakt+WertG*1
	Ergebn = parseInt(Ergebn *100+0.49)/100;
	return Ergebn;
	}
function Rechen()
 	{ 
		 document.ZivilR.AussG.focus();
		 document.ZivilR.RAG.focus();
		 document.ZivilR.GerG.focus();
		 document.ZivilR.RAV.focus();
		 document.ZivilR.Zu.focus();
		 document.ZivilR.Post.focus();
		 document.ZivilR.Gesamt.focus();
		 document.ZivilR.GesamtA.focus();
	}


/*********************************************************************/
function Gebberechn(StreitW,Faktor,MwSt,Erhoehung,wieviel)
{	Faktor= Faktor*1+(Erhoehung*wieviel);

	Ergebn = parseInt((RAGeb(StreitW)*Faktor*100)+0.5)/100;

	Ergebn = PostundMwst(Ergebn,MwSt,"0");
     	return Ergebn;
} 	

function Gericht(StreitW,Faktor)
{	
	Ergebn = parseInt((GerGebZR(StreitW)*Faktor*100)+0.5)/100;
	return Ergebn;
}

function Arrest(StreitW,Faktor,MwSt,Erhoehung,wieviel)
{	Faktor= Faktor*1+(Erhoehung*wieviel);
	Ergebn = parseInt((RAGeb(StreitW)*Faktor*100)+0.5)/100;

	Ergebn = PostundMwst(Ergebn,MwSt,"0");
     	return Ergebn;
} 	

function Berechnen()
{	
	document.ZivilR.ARAKost.focus();
	document.ZivilR.ZRAKost.focus();
	document.ZivilR.MRAKost.focus();
	document.ZivilR.ARAVergl.focus();

	document.ZivilR.AGerKost.focus();
	document.ZivilR.BGerKost.focus();
	document.ZivilR.CGerKost.focus();
	document.ZivilR.DGerKost.focus();

	document.ZivilR.RANormal.focus();
	document.ZivilR.RAVerglGer.focus();
	document.ZivilR.RAVersaum.focus();
	document.ZivilR.RAMB.focus();

	document.ZivilR.RAEVA.focus();
	document.ZivilR.RAEVB.focus();
	
	document.ZivilR.RABerufg.focus();
	document.ZivilR.RABerufgB.focus();
	document.ZivilR.RABerufgJa.focus();

	document.ZivilR.AGerKost.focus();
	document.ZivilR.BGerKost.focus();
	document.ZivilR.CGerKost.focus();
	document.ZivilR.DGerKost.focus();
	document.ZivilR.AGerKost2.focus();
	document.ZivilR.AGerKost4.focus();
	document.ZivilR.AGerKost6.focus();
	document.ZivilR.AGerKost7.focus();
	document.ZivilR.AGerKost8.focus();
	document.ZivilR.AGerKost9.focus();
	document.ZivilR.AGerKost10.focus();

	location.replace('#Berechn');
}	

function Rechnen(Eingabe)
	{Eingabe=ChkNumber(Eingabe)*1;
	a=300*1;
	b=1000*1;
	c=5000*1
	 if (Eingabe < c)
	 	{Pruefung.Kosten.value= "19.99";}
	 if (Eingabe < b)
	 	{Pruefung.Kosten.value= "9.99";}
	 if (Eingabe < a)
	 	{Pruefung.Kosten.value= "4.99";}
	 if (Eingabe >= c)
	 	{Pruefung.Kosten.value= "29.99";}
	
	 return Eingabe;
	}
/* ********** Gebührenrechnungen in Euro************* */

function RAGeb(StrW)
	{ 

	  if (StrW > 30000000)
		{StrW = 30000000;
		}

 	  var Geb = 25;
	  if (StrW >= 500000)
		{
		Geb = 2996;
		while (StrW > 500000)
   	  	  { StrW = StrW - 50000;
		    Geb = Geb + 150;
		  }
		 StrW = 0;
		}
	  if (StrW >= 200000)
		{
		Geb = 1816;
		while (StrW > 200000)
   	  	  { StrW = StrW - 30000;
		    Geb = Geb + 118;
		  }
		 StrW = 0;
		}
	  if (StrW >= 50000)
		{
		Geb = 1046;
		while (StrW > 50000)
   	  	  { StrW = StrW - 15000;
		    Geb = Geb + 77;
		  }
		 StrW = 0;
		}
	  if (StrW >= 25000)
		{
		Geb = 686;
		while (StrW > 25000)
   	  	  { StrW = StrW - 5000;
		    Geb = Geb + 72;
		  }
		 StrW = 0;
		}
	  if (StrW >= 10000)
		{
		Geb = 486;
		while (StrW > 10000)
   	  	  { StrW = StrW - 3000;
		    Geb = Geb + 40;
		  }
		 StrW = 0;
		}
	  if (StrW >= 5000)
		{
		Geb = 301;
		while (StrW > 5000)
   	  	  { StrW = StrW - 1000;
		    Geb = Geb + 37;
		  }
		 StrW = 0;
		}
	  if (StrW > 1500)
		{
		Geb = 105;
		while (StrW > 1500)
   	  	  { StrW = StrW - 500;
		  Geb= Geb + 28;
		  }
		 StrW = 0;
 		}
	  if (StrW > 300)
		{Geb = 25;
		 while (StrW > 300)
   	  	  { StrW = StrW - 300;
		  Geb= Geb + 20;
		  }
		 StrW = 0; 
		}
	   
	   return Geb;
	}

/* ******Gericht *************** */

function GerGebZR(StrW)
	{ 
 	  var Geb = 25;
	  if (StrW >= 500000)
		{
		Geb = 2956;
		while (StrW > 500000)
   	  	  { StrW = StrW - 50000;
		    Geb = Geb + 150;
		  }
		 StrW = 0;
		}
	  if (StrW >= 200000)
		{
		Geb = 1456;
		while (StrW > 200000)
   	  	  { StrW = StrW - 30000;
		    Geb = Geb + 150;
		  }
		 StrW = 0;
		}
	  if (StrW >= 50000)
		{
		Geb = 456;
		while (StrW > 50000)
   	  	  { StrW = StrW - 15000;
		    Geb = Geb + 100;
		  }
		 StrW = 0;
		}
	  if (StrW >= 25000)
		{
		Geb = 311;
		while (StrW > 25000)
   	  	  { StrW = StrW - 5000;
		    Geb = Geb + 29;
		  }
		 StrW = 0;
		}
	  if (StrW >= 10000)
		{
		Geb = 196;
		while (StrW > 10000)
   	  	  { StrW = StrW - 3000;
		    Geb = Geb + 23;
		  }
		 StrW = 0;
		}
	  if (StrW >= 5000)
		{
		Geb = 121;
		while (StrW > 5000)
   	  	  { StrW = StrW - 1000;
		    Geb = Geb + 15;
		  }
		 StrW = 0;
		}
	  if (StrW > 1500)
		{
		Geb = 65;
		while (StrW > 1500)
   	  	  { StrW = StrW - 500;
		  Geb= Geb + 8;
		  }
		 StrW = 0;
 		}
	  if (StrW > 300)
		{Geb = 25;
		 while (StrW > 300)
   	  	  { StrW = StrW - 300;
		  Geb= Geb + 10;
		  }
		 StrW = 0; 
		}

	   return Geb;
	}
/* ******Arbeitsgericht *** */
function GerichtsgebAR(StrW) //** in Euro **//
	{ var Geb = 10;
	   Bla = StrW;
	  if (StrW > 12000) 
		{Geb=500;
		 StrW = 0;
		 } 
	  if (StrW >= 5000)
		{
		Geb = 200;
		while (StrW > 5000)
   	  	  { StrW = StrW - 500;
		    Geb = Geb + 20;
		  }
		 StrW = 0;
		}
	  if (StrW > 1500)
		{
		Geb = 60;
		while (StrW > 1500)
   	  	  { StrW = StrW - 250;
		  Geb= Geb + 10;
		  }
		 StrW = 0;
 		}
	  if (StrW > 150)
		{Geb = 6;
		 while (StrW > 150)
   	  	  { StrW = StrW - 150;
		  Geb= Geb + 6;
		  }
		 StrW = 0; 
		}
	  return Geb;
	}

function GK(StreitW,Was)
	{

if (Was == "zivil")  /*zivile Sache*/
			{Ergebn = GerGebZR(StreitW)/2;
			 if (Ergebn < 23)
				Ergebn=23;
			}
	 	else 		/*Arbeitssache*/
			{Ergebn = GerichtsgebAR(StreitW)*0.4;
		 	if ( Ergebn < 18)
				Ergebn = 18;
			}
	 return Ergebn;

	}
function PTPMB(Mahn,VollB,Vollst,MwSt)
	{    
		Ergebn= 0;
		Teil = Mahn/MwSt + VollB/MwSt;


		if (Teil > 100)
			{Ergebn= 20;
			 }
		else 
			{Ergebn = parseInt(Teil*20+0.5)/100;
			}
		Teil = Vollst/MwSt;
		if (Teil > 100)
			{Ergebn = Ergebn + 20;
			 }
		else 
			{Ergebn = Ergebn + (parseInt(Teil*20+0.5)/100);
			}

		Ergebn = parseInt(Ergebn*100*MwSt)/100;

		return Ergebn;
	}

function SummeMB(KGericht,KRA,VBKost,KVollst,Post)
	{
	 Ergebn= parseInt(KGericht * 100 + KRA * 100 + KVollst * 100 + VBKost*100 + Post * 100)/100;

  	 return Ergebn;
}


/* ************** Berechnung der Postauslagen und MwSt.************/
function PostundMwst(Geb,Steu,Post)
	{if (Geb < 10)
		Geb = 10;
	 Steu=Steu*100;
	 Zuschl=0;
	if (Post == 0)
		{ Zuschl = (Geb *20)+0.5;
		  Zuschl = parseInt(Zuschl)/100;
	
		     {if (Zuschl > 20)
			Zuschl = 20;
	     	     }
		}
	 MWSt=parseInt((Geb+Zuschl)*Steu+0.5)/100;
	 return MWSt;
	}
