// funkce na onclick formulářových prvků
// google přeložil jako "druhá kontrola"
function zweipruefen (d){
  preisdarstellen ();
}

// funkce vracici castku z textu typu "cena:nazev"
function vratCenu(astr)
{
  var lnIdx = -1;
  var str = new String(astr);
  
  lnIdx = str.indexOf(':');
  if (lnIdx<1)
    return 0
  else  
    return parseFloat(str.substring(0, lnIdx))+0;   
}

// funkce na onChange formulářových prvků
// volána též z funkce zweipruefen
// sčítá všechny ceny a vypisuje je do souhrnu 
// původní německý kód byl neskutečný, přeprogramoval jsem to, snad to bude OK
function preisdarstellen () {

  var cenaDopravy = 0;
  var cenaZbozi = 0;
  var cenaCelkem = 0;
  var idx = 0;
  
  // zakladni cena
  for (idx=0;idx<20;idx++) {
    if (document.Formular.bestellung1[idx]) { 
      if (document.Formular.bestellung1[idx].checked) {
         cenaZbozi += vratCenu(document.Formular.bestellung1[idx].value);
      }
    }
  }  
  // dodatečné kurzy 
  if (document.Formular.bestellung2) cenaZbozi += vratCenu(document.Formular.bestellung2.options[document.Formular.bestellung2.selectedIndex].value);
  if (document.Formular.bestellung3) cenaZbozi += vratCenu(document.Formular.bestellung3.options[document.Formular.bestellung3.selectedIndex].value);
  if (document.Formular.bestellung4) cenaZbozi += vratCenu(document.Formular.bestellung4.options[document.Formular.bestellung4.selectedIndex].value);
  if (document.Formular.bestellung5) cenaZbozi += vratCenu(document.Formular.bestellung5.options[document.Formular.bestellung5.selectedIndex].value);
  if (document.Formular.bestellung6) cenaZbozi += vratCenu(document.Formular.bestellung6.options[document.Formular.bestellung6.selectedIndex].value);
  if (document.Formular.bestellung7) cenaZbozi += vratCenu(document.Formular.bestellung7.options[document.Formular.bestellung7.selectedIndex].value);
  if (document.Formular.bestellung8) cenaZbozi += vratCenu(document.Formular.bestellung8.options[document.Formular.bestellung8.selectedIndex].value);
  // cena dopravy
  for (idx=0;idx<10;idx++) {
    if (document.Formular.bestellung9[idx]) { 
      if (document.Formular.bestellung9[idx].checked) {
         cenaDopravy += vratCenu(document.Formular.bestellung9[idx].value);
      }
    }
  }  
  // cena celkem  
  cenaCelkem = cenaDopravy + cenaZbozi;
  
  document.Formular.kosikCena.value = cenaZbozi + ' KÄŤ'; 
  document.Formular.kosikDoprava.value = cenaDopravy + ' KÄŤ'; 
  document.Formular.kosikCelkem.value = cenaCelkem + ' KÄŤ'; 
}

// funkce, která se volá před placením při změně oslovení - pan, paní, firma atd
// pouye kvůli předchozí kompatibilitě, jinak nemá význam
function ustidform2()
{
  if (ustidformular) 
  {
    ust_id();
  }
  zweipruefen(4);
}

