').append($(data.form+' .pricing .price-old .uvp').clone()).html();
    }
  } else {
    data.productPricing = {
      org: data.price,
      cur: priceUpdate_getPriceFromText(data, $(data.form+' .price').html()),
      old: false
    }
  }
  $(data.form+' .product-configure-custom .product-configure-custom-option').each(function(){
    $(this).find('input[type="checkbox"]').each(function(){ $(this).change(function(){
      priceUpdate_updateForm(data, $(this));
    });});
    $(this).find('input[type="radio"]').each(function(){ $(this).change(function(){
      priceUpdate_updateForm(data, $(this));
    });});
    $(this).find('select').each(function(){ $(this).change(function(){
      priceUpdate_updateForm(data, $(this));
    });});
  })
}
// Update het formulier (prijzen etc.)
function priceUpdate_updateForm(data, changeObj) {
  
  oldPrice = data.productPricing.old;
  currentPrice = data.productPricing.cur;
  
  var optionPriceTotal = 0;
  var addValue = 0;
  $(data.form+' .product-configure-custom .product-configure-custom-option').each(function(){
    $(this).find('input[type="checkbox"]:checked').each(function(){
      addValue = priceUpdate_getPriceFromText(data, $(this).parent().children('label[for="'+$(this).attr('id')+'"]').html());
      if (!isNaN(addValue) && addValue != null) { optionPriceTotal += addValue; }
    });
    $(this).find('input[type="radio"]:checked').each(function(){
      addValue = priceUpdate_getPriceFromText(data, $(this).parent().children('label[for="'+$(this).attr('id')+'"]').html());
      if (!isNaN(addValue) && addValue != null) { optionPriceTotal += addValue; }
    });
    $(this).find('select option:selected').each(function(){
      addValue = priceUpdate_getPriceFromText(data, $(this).html());
      if (!isNaN(addValue) && addValue != null) { optionPriceTotal += addValue; }
    });
  })
  //console.log('curr '+currentPrice);
  //console.log('optiontotal: '+optionPriceTotal);
  
  if (oldPrice != false) {
    oldPrice = priceUpdate_formatPrice(oldPrice + optionPriceTotal, data);
  if (data.uvp != false) {oldPrice += ' '+data.uvp};
  }
  currentPrice = priceUpdate_formatPrice(currentPrice + optionPriceTotal, data);
  
  if ($(data.form+' .pricing .price-old').length > 0) {
    $(data.form+' .pricing .price').html('
'+oldPrice+''+currentPrice+'');
    $(data.form+' .pricing .price').addClass('price-offer');
  } else {
    $(data.form+' .pricing .price').html(currentPrice);
    $(data.form+' .pricing .price').removeClass('price-offer');
  }
}
function priceUpdate_formatPrice(value, data) {
  return data.currencysymbol+''+value.formatMoney(2, ',', '.');
}
function priceUpdate_getPriceFromText(data, val) {
  if (val.search(data.currencysymbol) == -1) {
    return null;
  }
  val = val.substring(val.lastIndexOf(data.currencysymbol)+1);
  val = val.replace(/[^0-9-]/g,'');
  valInt = val.substring(0, val.length - 2);
  valDecimals = val.substring(val.length - 2);
  val = valInt + '.' + valDecimals;
  val = parseFloat(val);
  return val;
}
  
if (Number.prototype.formatMoney == undefined) {
Number.prototype.formatMoney = function(c, d, t){
var n = this, 
    c = isNaN(c = Math.abs(c)) ? 2 : c, 
    d = d == undefined ? "." : d, 
    t = t == undefined ? "," : t, 
    s = n < 0 ? "-" : "", 
    i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", 
    j = (j = i.length) > 3 ? j % 3 : 0;
   return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
};
$(document).ready(function() {
  priceUpdate_init();
});