/* ---------------------------------------------------------------------
/
/     toolbox pipe_3 - Nominal pipe inside diameter js - /     
/     this file is not to be localized for different countries
/     03.01.05 marion.koerner@kaeser.com
/     04.12.06 mko
/  -------------------------------------------------------------------- */



function Ergebnis(d)
{
  var D1  = window.document.Rechnen.D1.value;
  var V   = window.document.Rechnen.V.value;
  var L   = window.document.Rechnen.L.value;
  var d   = window.document.Rechnen.d.value;
  var p   = window.document.Rechnen.p.value;
  var Erg = window.document.Rechnen.Erg.value;

  var x = 0;
  var y = 0;;
  var m = p;
  var j = 0;
  var q = 0;
  var Ne= 0;
  var k = 0;

  //Abfrage wenn US dann Umrechnung
  if (window.document.Rechnen.ISOUS[1].checked == true) {
    V = V / 35.31467;
    Erg = Erg / 14.5;
    L = L / 3.28083;
    p = p / 14.5;
  }

  x = Math.pow((V/60),1.85);
  y = Math.pow(d,5);
  m = p;
  j = Math.pow(V,1.85);


  /*Umstellung nach "d"*/
  if ((Erg*p)!=0){
    if (D1 != 0) {
      /*bei rauhen Rohren*/
      Ne = (D1*j*L);
      q = Math.round((Ne/(Erg*p))*10000)/10000;
    } else {
      /*bei glatten Rohren*/
      D1 = 160000000;
      Ne = (D1*x*L);
      x = Math.pow((V/60),1.85);
      q = Math.round((Ne/(Erg*m))*10000)/10000;
    }
  }
  k = Math.pow(q,0.2);
  d = Math.round((k)*10000)/10000;

  if (window.document.Rechnen.ISOUS[1].checked == true) {
    d = d * 0.03936996;
  }
 
  d = Math.round(d*100)/100;  

  window.document.Rechnen.d.value = d;
}

function Iso_Us()
{
if (window.document.Rechnen.ISOUS[1].checked == true)
  {
    us();
  } else { iso(); }
}

function us() {
  window.document.getElementById("volu").firstChild.nodeValue = "cfm"; 
  window.document.getElementById("nl").firstChild.nodeValue = "feet"; 
  window.document.getElementById("idr").firstChild.nodeValue = "inches"; 
  window.document.getElementById("bd").firstChild.nodeValue = "psi"; 
  window.document.getElementById("ergeb").firstChild.nodeValue = "psig"; 

  window.document.Rechnen.V.value = 0;
  window.document.Rechnen.L.value = 0; 
  window.document.Rechnen.d.value = 0;
  window.document.Rechnen.p.value = 0;
  window.document.Rechnen.Erg.value = 0;
//  Ergebnis();
}

function iso() {
  window.document.getElementById("volu").firstChild.nodeValue = "m³/min"; 
  window.document.getElementById("nl").firstChild.nodeValue = "m"; 
  window.document.getElementById("idr").firstChild.nodeValue = "mm"; 
  window.document.getElementById("bd").firstChild.nodeValue = "bar"; 
  window.document.getElementById("ergeb").firstChild.nodeValue = "bar"; 

  window.document.Rechnen.V.value = 0;
  window.document.Rechnen.L.value = 0; 
  window.document.Rechnen.d.value = 0;
  window.document.Rechnen.p.value = 0;
  window.document.Rechnen.Erg.value = 0;
//  Ergebnis();
}
