
//---------------------------------------------------------
// Funktion:     fc_options_recalc
// Beschreibung: Optionen auswerten, neuen Preis errechnen u. darstellen
// Parameter:    f_nr  - Formular Nr.
//---------------------------------------------------------
  function fc_options_recalc(f_nr) {
    sum=form_price_basic[f_nr];

    for (var i = 0; i < form_id[f_nr].length; i++) {

      obj = document.getElementById(form_id[f_nr][i]);
      if (obj == null) continue;

      if( obj.type == 'radio' ) {
        if( obj.checked == true ) {
          sum += form_optval[f_nr][i];
          fc_setze_zsum(form_zsum[f_nr][i], form_optval[f_nr][i], form_optval[f_nr][i]);
        }
      } else if( obj.type == 'text' || obj.type == 'hidden' ) {
        if( obj.value.length > 0 ) {
          sum += form_optval[f_nr][i];
          fc_setze_zsum(form_zsum[f_nr][i], form_optval[f_nr][i], form_optval[f_nr][i]);
        }
        else {
          fc_setze_zsum(form_zsum[f_nr][i], 0, form_optval[f_nr][i]);
        }
      } else {
        if( obj.selected == true ) {
          sum += form_optval[f_nr][i];
          fc_setze_zsum(form_zsum[f_nr][i], form_optval[f_nr][i], form_optval[f_nr][i]);
        }
      }
    }
    fc_setze_preis(f_nr, sum);
  }


//---------------------------------------------------------
// Funktion:     fc_setze_preis
// Beschreibung: Preis neu darstellen
// Parameter:    f_nr  - Formular Nr.
//               price - Preis (zahl)
//---------------------------------------------------------
  function fc_setze_preis( f_nr, price ) {
    obj=document.getElementById('f'+f_nr+'_price');
    if( obj != null )
      obj.innerHTML = fc_darstellung_wert(price);
  }

  function fc_setze_zsum( f_nr, price, opt_price ) {
    obj=document.getElementById('f'+f_nr+'_price');
    if( obj != null ) {
      obj.innerHTML = opt_price == 0 ? '' : (opt_price < 0 ? '- ' : (opt_price > 0 ? '+ ' : '')) + fc_darstellung_wert(Math.abs(opt_price));
      obj.style.fontStyle = price == 0 ? 'italic' : '';
      obj.style.color = price == 0 ? '#a0a0a0' : '';
    }
  }

//---------------------------------------------------------
// Funktion:     fc_darstellung_wert
// Beschreibung: Aus Wert korrekte Preisangabe bilden
// Parameter:    Zahl
// Return:       string
//---------------------------------------------------------
function fc_darstellung_wert( number ) {
  laenge = curr_format_decimal_places;
  sep    = curr_format_decimal_point;
  th_sep = curr_format_thousands_point;

  number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);
  str_number = number+"";
  arr_int = str_number.split(".");
  if(!arr_int[0]) arr_int[0] = "0";
  if(!arr_int[1]) arr_int[1] = "";
  if(arr_int[1].length < laenge){
    nachkomma = arr_int[1];
    for(i=arr_int[1].length+1; i <= laenge; i++){  nachkomma += "0";  }
    arr_int[1] = nachkomma;
  }
  if(th_sep != "" && arr_int[0].length > 3){
    Begriff = arr_int[0];
    arr_int[0] = "";
    for(j = 3; j < Begriff.length ; j+=3){
      Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
      arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
    }
    str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));
    arr_int[0] = str_first + arr_int[0];
  }
  ret = arr_int[0]+sep+arr_int[1];

  if( curr_format_symbol_left != '' ) {
    ret = curr_format_symbol_left+ret;
  }
  if( curr_format_symbol_right != '' ) {
    ret = ret+' '+curr_format_symbol_right;
  }
  return ret;

}








