function set_Sel_V1 (v0, v1, v2, v3, v4, v5)
{ with (window.document.Parameter)
  { Sel_V1.options[0].text = v0;
    Sel_V1.options[1].text = v1;
    Sel_V1.options[2].text = v2;
    Sel_V1.options[3].text = v3;
    Sel_V1.options[4].text = v4;
    Sel_V1.options[5].text = v5;
  }
}

function selectbox2 ()
{ with (window.document.Parameter)
  { if (Sel_E1.options[0].selected==true) f = 1;
    if (Sel_E1.options[1].selected==true) f = 2;
    if (Sel_E1.options[2].selected==true) f = 2;
    if (Sel_E1.options[3].selected==true) f = 2;
    if (Sel_E1.options[4].selected==true) f = 2;
    if (Sel_E1.options[5].selected==true) f = 2;

    if (f==1) set_Sel_V1 ("µ","m","c","d"," ","k");
    if (f==2) set_Sel_V1 (" "," "," "," "," "," ");
  }
}

function get_faktor (Selectbox)
{ faktor = 1;
  if (Selectbox.options[0].selected==true) faktor = 1e-6;
  if (Selectbox.options[1].selected==true) faktor = 1e-3;
  if (Selectbox.options[2].selected==true) faktor = 1e-2;
  if (Selectbox.options[3].selected==true) faktor = 1e-1;
  if (Selectbox.options[4].selected==true) faktor = 1;
  if (Selectbox.options[5].selected==true) faktor = 1e3;
  return faktor;
}

function umrechnen ()
{ with (window.document.Parameter)
  { faktor1 = get_faktor (Sel_V1);
    faktor2 = get_faktor (Sel_V2);

    W1 = parseFloat(window.document.Parameter.Wert1.value);

    if (Sel_E1.options[0].selected==true) W1 = faktor1 * W1; //meter
    if (Sel_E1.options[1].selected==true) W1 = W1 * 0.3048;  //foot
    if (Sel_E1.options[2].selected==true) W1 = W1 * 0.3048/12;  //inch
    if (Sel_E1.options[3].selected==true) W1 = W1 * 0.3048*3;  //yard
    if (Sel_E1.options[4].selected==true) W1 = W1 * 1609.344;  //mile
    if (Sel_E1.options[5].selected==true) W1 = W1 * 1852;  //sm

    Wert2.value = W1 / faktor2;
    Wert3.value = W1 / 0.3048;
    Wert4.value = W1 / 0.3048*12;
    Wert5.value = W1 / 0.3048/3;
    Wert6.value = W1 / 1609.344;
    Wert7.value = W1 / 1852;
  }
}

// ----------------- Fläche ------------------

function umrechnen_A ()
{ with (window.document.Flaeche)
  { W1 = parseFloat(window.document.Flaeche.Area1.value);
    if (Sel_A1.options[0].selected==true) W1 = W1; // m²
    if (Sel_A1.options[1].selected==true) W1 = W1*100;  // ar
    if (Sel_A1.options[2].selected==true) W1 = W1*10000;  // ha
    if (Sel_A1.options[3].selected==true) W1 = W1*1000000;  // km²
    if (Sel_A1.options[4].selected==true) W1 = W1*0.092903;  // ft²
    if (Sel_A1.options[5].selected==true) W1 = W1*0.092903/144;  // in²
    if (Sel_A1.options[6].selected==true) W1 = W1*0.092903*9;  // yd²
    if (Sel_A1.options[7].selected==true) W1 = W1*4046.86;  // acres
    if (Sel_A1.options[8].selected==true) W1 = W1*2589988;  // mi²
    Area2.value = W1;
    Area3.value = W1/100;
    Area4.value = W1/10000;
    Area5.value = W1/1000000;
    Area6.value = W1/0.092903;
    Area7.value = W1/0.092903*144;
    Area8.value = W1/0.092903/9;
    Area9.value = W1/4046.86;
    Area10.value = W1/2589988;
  }
}


// ----------------- Volumen ------------------

function umrechnen_V ()
{ with (window.document.Volumen)
  { W1 = parseFloat(window.document.Volumen.Vol1.value);
    if (Sel_V1.options[0].selected==true) W1 = W1; // Liter
    if (Sel_V1.options[1].selected==true) W1 = W1/1000;  // ml
    if (Sel_V1.options[2].selected==true) W1 = W1*1000;  // m³
    if (Sel_V1.options[3].selected==true) W1 = W1*3.7854345;  // gal
    if (Sel_V1.options[4].selected==true) W1 = W1*28.316846592;  // ft³
    if (Sel_V1.options[5].selected==true) W1 = W1*0.016387064;  // in³
    if (Sel_V1.options[6].selected==true) W1 = W1*764.554857984;  // yd³
    if (Sel_V1.options[7].selected==true) W1 = W1*158.7579;  // ptr.bbl
    if (Sel_V1.options[8].selected==true) W1 = W1*0.24;  // cup
    if (Sel_V1.options[9].selected==true) W1 = W1*0.029574;  // fl ounce
    Vol2.value = W1;
    Vol3.value = W1*1000;
    Vol4.value = W1/1000;
    Vol5.value = W1/3.7854345;
    Vol6.value = W1/28.316846592;
    Vol7.value = W1/0.016387064;
    Vol8.value = W1/764.554857984;
    Vol9.value = W1/158.7579;
    Vol10.value = W1/0.24;
    Vol11.value = W1/0.029574;
  }
}


// ----------------- Temperatur ------------------

function umrechnen_T ()
{ with (window.document.Temp)
  { W1 = parseFloat(window.document.Temp.Temp1.value);
    if (Sel_T1.options[0].selected==true) W1 = W1; //Celsius
    if (Sel_T1.options[1].selected==true) W1 = (W1 - 32)*5/9;  //Fahrenheit
    if (Sel_T1.options[2].selected==true) W1 = W1 - 273.15;  //Kelvin
    Temp2.value = W1;
    Temp3.value = W1*9/5 + 32;
    Temp4.value = W1 + 273.15;
  }
}

// ----------------- Masse ------------------

function get_faktor_M (Selectbox)
{ faktor = 1;
  if (Selectbox.options[0].selected==true) faktor = 1e-6;
  if (Selectbox.options[1].selected==true) faktor = 1e-3;
  if (Selectbox.options[2].selected==true) faktor = 1;
  if (Selectbox.options[3].selected==true) faktor = 1e3;
  return faktor;
}

function set_Sel_M0 (v0, v1, v2, v3)
{ with (window.document.Masse)
  { Sel_M0.options[0].text = v0;
    Sel_M0.options[1].text = v1;
    Sel_M0.options[2].text = v2;
    Sel_M0.options[3].text = v3;
  }
}

function selectbox2_M ()
{ with (window.document.Masse)
  { f = 2;
    if (Sel_M1.options[0].selected==true) f = 1;
    if (f==1) set_Sel_M0 ("µ","m"," ","k");
    if (f==2) set_Sel_M0 (" "," "," "," ");
  }
}

function umrechnen_M ()
{ with (window.document.Masse)
  { faktor1 = get_faktor_M (Sel_M0);
    faktor2 = get_faktor_M (Sel_M2);
    W1 = parseFloat(window.document.Masse.Masse1.value);
    if (Sel_M1.options[0].selected==true) W1 = faktor1 * W1; //Gramm
    if (Sel_M1.options[1].selected==true) W1 = W1 / 0.00981;  //Newton
    if (Sel_M1.options[2].selected==true) W1 = W1 * 453.59237;  //pound
    if (Sel_M1.options[3].selected==true) W1 = W1 * 453.59237/16;  //ounce
    Masse2.value = W1 / faktor2;
    Masse3.value = W1 * 0.00981;
    Masse4.value = W1 / 453.59237;
    Masse5.value = W1 / 453.59237*16;
  }
}


// ----------------- Verbrauch ------------------

function umrechnen_Ver ()
{ with (window.document.Verbrauch)
  { W1 = parseFloat(window.document.Verbrauch.Ver1.value);
    if (Sel_Ver1.options[0].selected==true) W1 = W1; // l/100 km
    if (Sel_Ver1.options[1].selected==true) if (W1!=0) W1 = 235.216/W1;  //mi/gal
    if (Sel_Ver1.options[2].selected==true) if (W1!=0) W1 = 100/W1; //km/l
    if (Sel_Ver1.options[3].selected==true) W1 = W1*2.35216;  //gal/100 mi
    Ver2.value = W1;
    if (W1!=0) Ver3.value = 235.216/W1; else Ver3.value = 0;
    if (W1!=0) Ver4.value = 100/W1; else Ver4.value = 0;
    Ver5.value = W1/2.35216;
  }
}