function zeigMenue(welches)
{
        document.getElementById("products_menue1").style.display="none";
        document.getElementById("products_menue2").style.display="none";
        document.getElementById("products_menue3").style.display="none";
        document.getElementById("products_menue4").style.display="none";
        document.getElementById("products_menue5").style.display="none";
        switch (welches)
        {
        case '1':
                document.getElementById("products_menue1").style.display="block";
                break;

        case '2':
                document.getElementById("products_menue2").style.display="block";
                break;
        case '3':
                document.getElementById("products_menue3").style.display="block";
                break;
        case '4':
                document.getElementById("products_menue4").style.display="block";
                break;
        case '5':
                document.getElementById("products_menue5").style.display="block";
                break;
        default:
        }
}

function chkEingabe (obj)
{
var erlaubt = "0123456789.,";
var laenge = obj.value.length;
if (erlaubt.indexOf(obj.value.charAt(laenge-1)) < 0)
  {
  alert("Only numbers and a decimal separator are allowed!");
  obj.value=obj.value.substring(0, laenge-1);
  obj.focus ();
  return false;
  }
if (obj.value.charAt(laenge-1)==',')
	{
	for (var i = 0; i < laenge-1; i++)
   	if (obj.value.charAt(i)=='.')
      	{
      	alert("Only numbers and ONE decimal separator are allowed!");
      	obj.value=obj.value.substring(0, laenge-1);
  			obj.focus ();
  			return false;
 			}
 		;
 	;	
 	obj.value=obj.value.substring(0, laenge-1) + '.';
 	};
if (obj.value.charAt(laenge-1)=='.')
	for (var i = 0; i < laenge-1; i++)
   	if (obj.value.charAt(i)=='.')
      	{
      	alert("Only numbers and ONE decimal separator are allowed!");
      	obj.value=obj.value.substring(0, laenge-1);
  			obj.focus ();
  			return false;
 			}  
	;
return true;
}

function runden (zahl, stellen)
{
var st = Math.pow (10, stellen)
zahl = 1/st*Math.round(zahl * st)
return zahl;
}

function calculate ()
{
document.calc.urea.value=runden(document.calc.volume_sep.value/1000*4*60.06, 2);
document.calc.gebu_sep.value=runden(document.calc.volume_sep.value/8, 2);
document.calc.gebu_stack.value=runden(document.calc.volume_stack.value/2, 2);
document.calc.acr_sep.value=runden(document.calc.volume_sep.value*document.calc.c_sep.value/document.calc.c_acr.value, 2);
document.calc.acr_stack.value=runden(document.calc.volume_stack.value*document.calc.c_stack.value/document.calc.c_acr.value, 2);
document.calc.water_sep.value=runden(Math.round(document.calc.volume_sep.value*0.842-document.calc.acr_sep.value-document.calc.gebu_sep.value), 2);
if (document.calc.volume_sep.value <=100)
	{
	document.calc.temed_sep.value=runden(5*Math.round(0.2*Math.round(document.calc.volume_sep.value/2)), 2);
	document.calc.aps_sep.value=runden(5*Math.round(0.2*Math.round(document.calc.temed_sep.value*10/3)), 2);
	}
	else
	{
	document.calc.temed_sep.value=runden(5*Math.round(0.2*Math.round(document.calc.volume_sep.value/1.4)), 2);
	document.calc.aps_sep.value=runden(5*Math.round(0.2*Math.round(document.calc.temed_sep.value*5)), 2);
	}
if (document.calc.volume_stack.value >20)
	{
	document.calc.temed_stack.value=runden(5*Math.round(0.2*document.calc.volume_stack.value/(1+(document.calc.volume_stack.value/10-1)/10)), 2);
	}
	else
	{
	document.calc.temed_stack.value=runden(document.calc.volume_stack.value, 2);
	}
document.calc.aps_stack.value=runden(document.calc.temed_stack.value*10, 2);
document.calc.water_stack.value=runden(document.calc.volume_stack.value-document.calc.acr_stack.value-document.calc.gebu_stack.value-(document.calc.temed_stack.value*1+document.calc.aps_stack.value*1)/1000, 2);
var ratio= document.calc.c_acr.value/document.calc.c_bis.value;
document.calc.c_stackc.value=runden(1/ratio*100, 2);
document.calc.c_ratio.value=ratio + ":1";
}
 
function calculate_volume ()
{
var v_sep=document.calc.num_sep.value*document.calc.h_sep.value*document.calc.width.value*document.calc.spacer.value*(1+document.calc.extra.value/100)/1000;
var v_stack=document.calc.num_stack.value*document.calc.h_stack.value*document.calc.width.value*document.calc.spacer.value/1000;
document.calc.volume_sep.value=runden(v_sep, 0);
document.calc.volume_stack.value=runden(v_stack, 1);
calculate ();
}

function show_table ()
{
if ( document.getElementById("parameters").style.display == 'none' )
	{
	document.getElementById("parameters").style.display = '';
	document.calc.calc_button.value="I accept the calculated volumes";
	
	}
	else
	{
	document.getElementById("parameters").style.display = 'none';
	document.calc.calc_button.value="If you don't know how much gel solution you will need, press this button";
	}
} 