
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 Quote(Nummer,Art)
	{ 
	Nummer = ChkNumber(Nummer);

	if (Nummer < 0)
		{Nummer = 100;
		 alert("Prüfen Sie noch einmal Ihre Eingabe. Die Kostenquote liegt unter 0 %");
		}
	else
		{	if (Nummer > 100)
			{Nummer = 0;
		 	alert("Prüfen Sie noch einmal Ihre Eingabe. Die Kostenquote liegt über 100 				%.");
			}
		else
			{
			Nummer = 100 - Nummer;
			}
		}
	
	return Nummer
	}

function GebRA(StreitW,Fakt,Ins)
{	

	/*alert("StreitWert: " + StreitW + ", Fakt: " + Fakt + ", Instanz: " + Ins);
	*/
	if (StreitW == NaN)
		StreitW = 0;
	if (StreitW > 30000000)
		{StreitW = 30000000;}

	Fakt = Fakt*1;
	/*alert ("Fakt: "+ Fakt);
	*/


	if (Fakt == "0")
		{
		Fakt = 0;
		}

	else	
		{
		Fakt = Fakt*1 + Ins*1;
		}

	Ergebn = parseInt((RAGeb(StreitW)*Fakt*100)+0.5)/100;
		
	return Ergebn;
}



function PTP(Wert1,Wert2,Wert3,Wert4)
	{ Ergebn = Wert1*1+Wert2*1+Wert3*1+Wert4*1;

	Ergebn = Ergebn *0.2;

	if (Ergebn > 20)
		{Ergebn = 20;}

	return Ergebn;
	}

function MW(Wert1,Wert2,Wert3,Wert4,Wert5)
	{ Ergebn = Wert1*1+Wert2*1+Wert3*1+Wert4*1+Wert5*1;

	Ergebn = parseInt(Ergebn *19)/100;

	return Ergebn;
	}


function Anwalt(Wert1,Wert2,Wert3,Wert4,Wert5,Wert6,Vors)
	{ /*alert (Vors);*/

	 if (Vors == true)
		{Wert6 = 0;
		}
	 else
		{Wert6= Wert6;
		}

	 Ergebn = parseInt(Wert1*100+Wert2*100+Wert3*100+Wert4*100+Wert5*100+Wert6*100)/100;


	 return Ergebn;
	}


function Gericht(StreitW,Fakt,Ins)
{	if (StreitW == NaN)
		StreitW = 0;
	if (StreitW > 30000000)
		{StreitW = 30000000;}
	

	if (Ins == 0)
		{	
			if (Fakt == 4)
				{Fakt = 3;}
			else 
				{Fakt = 1;}
		}
	Ergebn = 0;

	Ergebn = parseInt((GerGebZR(StreitW)*Fakt*100)+0.5)/100;
	return Ergebn;

		

}

function Anteil(KAnwK,BAnwK,GerK,Aufh,Quot)
{	Ergebn=0;
	/*alert(Aufh);*/
	if (Aufh == true)
		{ Ergebn = GerK/2 + KAnwK*1;
		}
	else
		{ Ergebn = parseInt(((KAnwK*1 + BAnwK*1 + GerK*1)*Quot)+0.5)/100
		}
	return Ergebn;
}


function Rechen()
 	{

	document.ZivilR.KVGB.focus();
	document.ZivilR.BVGB.focus();
	document.ZivilR.KTGB.focus();
	document.ZivilR.BTGB.focus();
	document.ZivilR.KVglGB.focus();
	document.ZivilR.BVglGB.focus();
	document.ZivilR.KErhB.focus();
	document.ZivilR.BErhB.focus();	
	document.ZivilR.KPost.focus();
	document.ZivilR.BPost.focus();
	document.ZivilR.KMwSt.focus();
	document.ZivilR.BMwSt.focus();
	document.ZivilR.KAK.focus();
	document.ZivilR.BAK.focus();
	document.ZivilR.GGB.focus();

	document.ZivilR.KSum.focus();
	document.ZivilR.BSum.focus();

	document.ZivilR.KSum.focus();
	document.ZivilR.BSum.focus();
	location.replace('#Rechn');
	}


/*********************************************************************/

/* ********** 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;
	}
