/* ---------------------------------------------------------------------
/
/     toolbox pipe_2 - Calculation pipe lenght js - /     
/     this file is not to be localized for different countries
/     03.01.05 marion.koerner@kaeser.com
/     04.12.06 mko
/  -------------------------------------------------------------------- */



function Ergebnis()
{
  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 Ne= 0;
	
  //Abfrage wenn US dann Umrechnung
  if (window.document.Rechnen.ISOUS[1].checked == true) {
    V = V / 35.31467;
    Erg = Erg / 14.5;
    d = d / 0.03936996;
    p = p / 14.5;
  }

  x = Math.pow((V/60),1.85);
  y = Math.pow(d,5);


  /*Umstellung nach "L"*/
  if ((d*p)!=0){
    if (D1 != 0) {
      /* bei rauhen Rohren*/
      D1 = 82000
      Ne = (Erg*y*p);
      x = Math.pow((V),1.85);
      L = Math.round((Ne/(D1*x))*10000)/10000;
    } else {
      /* bei glatten Rohren */
      D1 = 160000000;
      Ne = (Erg*y*p);
      x = Math.pow((V/60),1.85);
      L = Math.round((Ne/(D1*x))*10000)/10000;
    }
  }

  if (window.document.Rechnen.ISOUS[1].checked == true) {
    L = L * 3.28083;
  }
 
  L = Math.round(L*100)/100;

window.document.Rechnen.L.value= L;
}

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();
}
