AJAX_AMZWEB_PKG.CustomerReviewRenderer = function(response, properties) {
  this._response = response;
  this._properties = properties;
};

AJAX_AMZWEB_PKG.CustomerReviewRenderer.prototype.display = function() {
  if(this._response.Item) {
    var product = this._response.Item;
    var customerReviews = product.customerReviews;

    if (customerReviews && customerReviews.length > 0) {
      var widgetHTML = '';
      widgetHTML += '<div style="border-bottom: 1px solid #C9D4D7; float:left;margin-bottom:10px;margin-top:15px;width:100%;"><div style="font-weight:bold;font-size:14px;float:left;margin-bottom:0px;padding-bottom:4px;">' + this._properties.titleCustomerReviews + '</div></div>';
      widgetHTML += '<div class="clearAll"></div>';

      for (var i = 0; i < customerReviews.length; i++) {
        var review = customerReviews[i];
        if (!review.content.match("Amazon") && !review.content.match("amazon")) {
          widgetHTML += '<div id="amz-web-service-CustomerReview-' + i + '">';

          var imageSource = AJAX_AMZWEB_PKG.AverageRatingRendererHelper.getStarRatingHTML(review.rating);
          if (imageSource) {
            widgetHTML += '<img alt="' + this._properties.labelAverageReview + product.averageRating + '" src="' + imageSource + '"/> ';
          }
          widgetHTML += '<b>' + review.date + '</b><br/>';
          widgetHTML += '<b>' + review.summary + '</b>&nbsp;&nbsp;By: ' + review.reviewer + '<br/>';
          widgetHTML += '<p class="toggle" style="padding-top:3px;padding-bottom:10px;">' + review.content + '</p></div>';
        }
      }

      document.getElementById('amz-web-service-CustomerReview').innerHTML = widgetHTML;
    }
  }
};

