/**
 * Creats a new DefaultPricingRenderer.
 * @constructor
 * @param {Object} options an object with optional/additional variables for rendering options
 */
AJAX_PRICING_PKG.DefaultPricingRenderer = function(options) {
  this.options = options;
  if (options) {
    this.containerName = options.containerName;
    this._properties = options.properties;
  }
};

AJAX_PRICING_PKG.DefaultPricingRenderer.prototype.displayPricing = function(serverResponse) {
  var widgetContainer = document.getElementById('pricingService-' + serverResponse.isbn);
  if(!serverResponse.success) {
    if (!this._renderNoSuccess()) {
      widgetContainer.innerHTML = "";
      return;
    }
  }

  widgetContainer.innerHTML = "";
  this._renderWidget(serverResponse, widgetContainer);
};

AJAX_PRICING_PKG.DefaultPricingRenderer.prototype._renderNoSuccess = function(response) {
  return false;
};

AJAX_PRICING_PKG.DefaultPricingRenderer.prototype._renderWidget = function(response, container) {
  var spanLabel = document.createElement('span');
  spanLabel.style.fontWeight = "bold";
  spanLabel.innerHTML = options.listPriceText;

  var pricingData = null;
  var spanCondition = document.createElement('span');

  if (response.newExists) {
    spanCondition.innerHTML = options.conditionNewText;
    pricingData = response.pricingInfoForBestNew;
  } else {
    spanCondition.innerHTML = options.conditionUsedText;
    pricingData = response.pricingInfoForBestUsed;
  }

  var spanPrice = document.createElement('span');
  spanPrice.className = "price";
  spanPrice.innerHTML = pricingData.bestPriceInPurchaseCurrencyWithCurrencySymbol;
 
  container.appendChild(spanLabel);
  container.appendChild(spanPrice);
  container.appendChild(spanCondition);
};