<!--
var neues;
var didopen=false;

function bill4net(theURL,xxx,yyy) { 
    if  (didopen)  neues.close();
	didopen=true;
 features = "left=1,top=1,width="+xxx+",height="+yyy+",scrollbars=no,resizable=no";
 neues = window.open(theURL,"displaywindow",features);
}

function b_alles_null_setzen() {
  window.document.tarife.min_tarif_tot.value = 0;
  window.document.tarife.min_tarif_mobil_tot.value = 0;
  window.document.tarife.netzleistung_min_tot.value = 0;
  window.document.tarife.netzleistung_call_tot.value = 0;
  window.document.tarife.handling_charge_tot.value = 0;
  window.document.tarife.handling_charge.value = 0;
  window.document.tarife.f_ausfall_tot.value = 0;
  window.document.tarife.zweit_inkasso_tot.value = 0;
  window.document.tarife.gebuehren.value = 0;
  window.document.tarife.gebuehren_tot.value = 0;
  window.document.tarife.gebuehren_menge.value = 0;
  window.document.tarife.gebuehren_chf.value = 0;
  window.document.tarife.netzleistung_min_menge.value = 0;
  window.document.tarife.netzleistung_min_chf.value = 0;
  window.document.tarife.netzleistung_call_menge.value = 0;
  window.document.tarife.netzleistung_call_chf.value = 0;
  window.document.tarife.handling_charge_menge.value = 0;
  window.document.tarife.handling_charge_chf.value = 0;
  window.document.tarife.min_tarif.value = 0;
  window.document.tarife.min_tarif_chf.value = 0;
  window.document.tarife.min_tarif_mobil.value = 0;
  window.document.tarife.min_tarif_mobil_chf.value = 0;
  window.document.tarife.f_ausfall.value = 0;
  window.document.tarife.f_ausfall_chf.value = 0;
  window.document.tarife.zweit_inkasso.value = 0;
  window.document.tarife.zweit_inkasso_chf.value = 0;
  b_zwischensumme();
  b_netz_leistung_tot();
  b_umsatz_tot();
  
}

function b_zwischensumme() {
  var erg = 0;
  tot_1  = window.document.tarife.min_tarif_tot.value;
  tot_2  = window.document.tarife.min_tarif_mobil_tot.value;
  tot_3  = window.document.tarife.netzleistung_min_tot.value;
  tot_4  = window.document.tarife.netzleistung_call_tot.value;
  tot_5  = window.document.tarife.handling_charge_tot.value;
  tot_6  = window.document.tarife.f_ausfall_tot.value;
  tot_7  = window.document.tarife.zweit_inkasso_tot.value;
  tot_8  = window.document.tarife.gebuehren_tot.value;
  tot_1 = tot_1 / 1;
  tot_2 = tot_2 / 1;
  tot_3 = tot_3 / 1;
  tot_4 = tot_4 / 1;
  tot_5 = tot_5 / 1;
  tot_6 = tot_6 / 1;
  tot_7 = tot_7 / 1;
  if (tot_1 > 0) erg += tot_1;
  if (tot_2 > 0) erg += tot_2;
  if (tot_3 > 0) erg -= tot_3;
  if (tot_4 > 0) erg -= tot_4;
  if (tot_5 > 0) erg -= tot_5;
  if (tot_6 > 0) erg -= tot_6;
  if (tot_7 > 0) erg -= tot_7;
  window.document.tarife.zwischensumme.value = kaufm(erg);
}

function b_gebuehren() {
  menge         = window.document.tarife.gebuehren_menge.value;
  gebuehren_chf = window.document.tarife.gebuehren_chf.value;
  erg = menge * gebuehren_chf;
  window.document.tarife.gebuehren_tot.value = kaufm(erg);
  window.document.tarife.gebuehren.value = kaufm(erg);
  b_zwischensumme();
}


function b_netzleistung_min() {
  menge                = window.document.tarife.netzleistung_min_menge.value;
  netzleistung_min_chf = window.document.tarife.netzleistung_min_chf.value;
  erg = menge * netzleistung_min_chf;
  window.document.tarife.netzleistung_min_tot.value = kaufm(erg);
  b_netz_leistung_tot();
  b_zwischensumme();
}

function b_netzleistung_call() {
  menge                 = window.document.tarife.netzleistung_call_menge.value;
  netzleistung_call_chf = window.document.tarife.netzleistung_call_chf.value;
  erg = menge * netzleistung_call_chf;
  window.document.tarife.netzleistung_call_tot.value = kaufm(erg);
  b_netz_leistung_tot();
  b_zwischensumme();
}

function b_netz_leistung_tot() {
  var erg = 0;
  tot_1  = window.document.tarife.netzleistung_call_tot.value;
  tot_2  = window.document.tarife.netzleistung_min_tot.value;
  tot_1 = tot_1 / 1;
  tot_2 = tot_2 / 1;
  if (tot_1 > 0) erg += tot_1;
  if (tot_2 > 0) erg += tot_2;
  window.document.tarife.netzleistung_call.value = kaufm(erg);
}

function b_handling_charge() {
  menge               = window.document.tarife.handling_charge_menge.value;
  handling_charge_chf = window.document.tarife.handling_charge_chf.value;
  erg = menge * handling_charge_chf;
  window.document.tarife.handling_charge_tot.value = kaufm(erg);
  window.document.tarife.handling_charge.value = kaufm(erg);
  b_zwischensumme();
}

function b_umsatz_tot() {
  var erg = 0;
  tot_1  = window.document.tarife.min_tarif_tot.value;
  tot_2  = window.document.tarife.min_tarif_mobil_tot.value;
  tot_3  = window.document.tarife.f_ausfall_tot.value;
  tot_4  = window.document.tarife.zweit_inkasso_tot.value;
  tot_1 = tot_1 / 1;
  tot_2 = tot_2 / 1;
  tot_3 = tot_3 / 1;
  tot_4 = tot_4 / 1;
  if (tot_1 > 0) erg += tot_1;
  if (tot_2 > 0) erg += tot_2;
  if (tot_3 > 0) erg -= tot_3;
  if (tot_4 > 0) erg -= tot_4;
  window.document.tarife.umsatz_tot.value = kaufm(erg);
}

function b_min_tarif() {
  menge         = window.document.tarife.min_tarif.value;
  min_tarif_chf = window.document.tarife.min_tarif_chf.value;
  erg = menge * min_tarif_chf;
  window.document.tarife.min_tarif_tot.value = kaufm(erg);
  b_umsatz_tot();
  b_zwischensumme();
}

function b_min_tarif_mobil() {
  menge               = window.document.tarife.min_tarif_mobil.value;
  min_tarif_mobil_chf = window.document.tarife.min_tarif_mobil_chf.value;
  erg = menge * min_tarif_mobil_chf;
  window.document.tarife.min_tarif_mobil_tot.value = kaufm(erg);
  b_umsatz_tot();
  b_zwischensumme();
}

function b_f_ausfall() {
  menge         = window.document.tarife.f_ausfall.value;
  f_ausfall_chf = window.document.tarife.f_ausfall_chf.value;
  erg = menge * f_ausfall_chf;
  window.document.tarife.f_ausfall_tot.value = kaufm(erg);
  b_umsatz_tot();
  b_zwischensumme();
}

function b_zweit_inkasso() {
  menge             = window.document.tarife.zweit_inkasso.value;
  zweit_inkasso_chf = window.document.tarife.zweit_inkasso_chf.value;
  erg = menge * zweit_inkasso_chf;
  window.document.tarife.zweit_inkasso_tot.value = kaufm(erg);
  b_umsatz_tot();
  b_zwischensumme();
}
  
function kaufm(x) {
  var k = (Math.round(x * 100) / 100).toString();
  k += (k.indexOf('.') == -1)? '.00' : '00';
  return k.substring(0, k.indexOf('.') + 3);
}

function runde(x, n) {
  if (n < 1 || n > 14) return false;
  var e = Math.pow(10, n);
  var k = (Math.round(x * e) / e).toString();
  if (k.indexOf('.') == -1) k += '.';
  k += e.toString().substring(1);
  return k.substring(0, k.indexOf('.') + n+1);
}

//-->
