
				{% if reviewprostatus %}
				
				<div class="overallrating">
					{% if review_total %}
					{% if reviewpro_fields.reviewrating %}
					<p class="avgstar">
						{% if forstars %}
							{% for i in 1..5 %}
								{% if i <= forstars %}
									<i class="fa fa-star"></i>
								{% else %}
									<i class="fa fa-star-o"></i>
								{% endif %}
							{% endfor %}
						{% endif %}
					</p>
					{% endif %}
					<p class="fromreview">{{ averagerating }} {{ textadmin.rating }} / {{ review_total }} {{ textadmin.review }}</p>
					<div class="row">
						<div class="col-sm-9">
							{% if reviewpro_fields.differetbars %}
								{% if rating_desc %}
									{% for ratings in rating_desc %}
										<div class="diferent_bar" rel="{{ ratings.rating_id }}">
											<div class="barname text-right">{{ ratings.rating_name }}</div>
											<div class="barrating"><div style="width:{{ avgrating[ratings.rating_id].per }}; {% if avgrating[ratings.rating_id].per %} background-color:#FFCC00; {% else %} background-color:#999; {% endif %}"></div></div>
											<div class="barpercent">{{ avgrating[ratings.rating_id].per }}</div>
											<div class="clearfix"></div>
										</div>
									{% endfor %}
								{% endif %}
							{% endif %}
						</div>
						<div class="col-sm-3 text-right">
							<a class="btn btn-primary {% if guestreview %} openmfp {% endif %}" {% if not guestreview %} data-toggle="tooltip" data-placement="top" title="{{ textadmin['login_review'] }}" {% endif %}>{{ textadmin.reviewbtn }}</a>
						</div>
					</div>
					{% else %}
						<div class="text-center">
							<p class="reviewpro_heading">{% if textadmin.title %} {{ textadmin.newreview }} {% endif %}</p>
							<a class="btn btn-primary {% if guestreview %} openmfp {% endif %}" {% if guestreview %} data-toggle="tooltip" data-placement="top" title="{{ textadmin['login_review'] }}" {% endif %}>{{ textadmin.reviewbtn }}</a>
						</div>
					{% endif %}
				</div>
				
				{% if reviewfilters %}
				<div class="row">
					<div class="col-sm-10 col-xs-6">
						<div class="btn-group sortreview" style="margin-bottom:10px;">
							<button type="button" class="btn btn-rating" rel="1"> {{ text_descending }} <span class="clearfilter filterclose">x</span></button>
							<button type="button" class="btn btn-rating" rel="2">{{ text_asc }} <span class="clearfilter filterclose">x</span></button>
							<button type="button" class="btn btn-rating" rel="3" id="verifypurchase">{{ text_verified }} <span class="clearfilter filterclose">x</span></button>
						</div>
					</div>
					<div class="col-sm-2 col-xs-6">
						<button type="button" class="btn btn-rating clearfilter pull-right"><i class="fa fa-refresh"></i> {{ text_clearfilter }}</button>
					</div>
				</div>
				{% endif %}
				
				<div id="review"></div>
				
				<div id="modal" class="white-popup-block reviewpropopup {% if displayform %} mfp-hide {% endif %}">
					<a class="popup-modal-dismiss" data-effect="mfp-zoom-in" href="#"></a>
					<h5>{{ reviewform.title }}</h5>
					
					<form id="form-reviewpro" method="post" class="form-horizontal" enctype="multipart/form-data">
						
						{% if reviewpro_fields.namefield %}
						<div class="form-group {% if reviewpro_fields.namefield == '2' %} required {% endif %}">
						  <div class="col-sm-12" style="margin-top:20px;">
							<input type="text" name="name" id="input_review_1" value="{{ customer_name }}" placeholder="{{ reviewform.name }}" class="form-control" />
						  </div>
						</div>
						{% endif %}
						
						{% if reviewpro_fields.emailfield %}
						<div class="form-group {% if reviewpro_fields.emailfield == '2' %} required {% endif %}">
						  <div class="col-sm-12">
							<input type="text" name="email" id="input_review_2" value="{{ customer_email }}" placeholder="{{ reviewform.email }}" class="form-control" />
						  </div>
						</div>
						{% endif %}
						
						{% if reviewpro_fields.titlefield %}
						<div class="form-group {% if reviewpro_fields.titlefield == '2' %} required {% endif %}">
						  <div class="col-sm-12">
							<input type="text" name="title" id="input_review_3" value="" placeholder="{{ reviewform.rtitle }}" class="form-control" />
						  </div>
						</div>
						{% endif %}
						
						{% if reviewpro_fields.commentfield %}
						<div class="form-group {% if reviewpro_fields.commentfield == '2' %} required {% endif %}">
						  <div class="col-sm-12">
							<textarea class="form-control" id="input_review_4" name="comment" placeholder="{{ reviewform.comment }}"></textarea>
						  </div>
						</div>
						{% endif %}
						
						{% if reviewpro_fields.ratingreq %}
						<div class="form-group {% if reviewpro_fields.ratingreq == '2' %} required {% endif %}">
						  <div class="col-sm-12">
							{% if ratinglists %}
							{% for ratinglist in ratinglists %}
							<div class="wi_row">
								<label class="col-sm-3" for="input-rating">{{ ratinglist.rating_name }}</label>
								<div class="col-sm-9">
									<div class="rating">
										<input type="radio" id="star5_{{ ratinglist.rating_id }}" name="rating[{{ ratinglist.rating_id }}]" value="5" /><div class="full" for="star5_{{ ratinglist.rating_id }}" title="Awesome - 5 stars"></div>
										<input type="radio" id="star4_{{ ratinglist.rating_id }}" name="rating[{{ ratinglist.rating_id }}]" value="4" /><div class="full" for="star4_{{ ratinglist.rating_id }}" title="Pretty good - 4 stars"></div>
										<input type="radio" id="star3_{{ ratinglist.rating_id }}" name="rating[{{ ratinglist.rating_id }}]" value="3" /><div class="full" for="star3_{{ ratinglist.rating_id }}" title="Meh - 3 stars"></div>
										<input type="radio" id="star2_{{ ratinglist.rating_id }}" name="rating[{{ ratinglist.rating_id }}]" value="2" /><div class="full" for="star2_{{ ratinglist.rating_id }}" title="Kinda bad - 2 stars"></div>
										<input type="radio" id="star1_{{ ratinglist.rating_id }}" name="rating[{{ ratinglist.rating_id }}]" value="1" /><div class="full" for="star1_{{ ratinglist.rating_id }}" title="Sucks big time - 1 star"></div>
									</div>
								</div>
								<script>
									$(".rating div").on('click', function() {
										var rating = $(this).attr('for');
										$( "#" + rating).prop( "checked", true );
									});
								</script>
							</div>
							{% endfor %}
							{% endif %}
							<input type="hidden" id="input_review_6" />
						  </div>
						</div>
						{% endif %}
						
						{% if reviewpro_fields.attachimage %}
						<div class="form-group">
						  <label class="col-sm-3 control-label">{{ reviewform.attachmenttext }}</label>
						  <div class="col-sm-9">
						  <div class="attachedfiles"></div>
							<button type="button" id="button-review-upload" data-loading-text="{{ text_loading }}" class="btn btn-default btn-block"><i class="fa fa-upload"></i> {{ button_upload }}</button>
						  </div>
						</div>
						{% endif %}
						
						{% if reviewpro_fields.capcha %}
						{{ captcha }}
						{% endif %}
						<input type="hidden" value="{{ product_id }}" name="product_id" />
						<div class="buttons clearfix">
						  <div class="pull-right">
							<button type="button" {% if guestreview %} id="button-reviewpro" {% endif %} {% if not guestreview %} data-toggle="tooltip" data-placement="top" title="{{ textadmin['login_review'] }}" {% endif %} data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ reviewform.submitreviewbtn }}</button>
						  </div>
						</div>
						
					</form>
					
				</div>
				
				<script type="text/javascript">
				
					$('#button-reviewpro').on('click', function(){
						$.ajax({
							url: 'index.php?route=extension/reviewpro/writereviewpro',
							type: 'post',
							data: $('#form-reviewpro input[type=\'radio\']:checked, #form-reviewpro input[type=\'text\'], #form-reviewpro textarea, #form-reviewpro input[type=\'hidden\'], #form-reviewpro select, #form-reviewpro input[type=\'file\']'),
							dataType: 'json',
							beforeSend: function() {
								$('#button-reviewpro').button('loading');
							},
							complete: function() {
								$('#button-reviewpro').button('reset');
							},
							success: function(json){
								$('#form-reviewpro .text-danger').remove();
								$('#form-reviewpro .form-group').removeClass('has-error');
								if(json['error']){
									for(i in json['error']){
										var element = $('#input_review_' + i);
										$(element).after('<div class="text-danger">' + json['error'][i] + '</div>');
										$(element).parent().addClass('has-error');
									}
									
									{% if reviewpro_fields.attachimage %}
									if(json['error']['captcha']){
										$('.g-recaptcha').after('<div class="text-danger">' + json['error']['captcha'] + '</div>');
										$('.g-recaptcha').parent().parent().addClass('has-error');
									}
									{% endif %}
								}
								
								if(json['success']){
									$('form#form-reviewpro').html(json['success']);
								}
							},
							error: function(xhr, ajaxOptions, thrownError) {
								alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
							}
						});
					});
					
					$('button[id^=\'button-review-upload\']').on('click', function() {
						var node = this;
						$('#form-upload').remove();
						$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');
						$('#form-upload input[name=\'file\']').trigger('click');
						if (typeof timer != 'undefined') {
							clearInterval(timer);
						}
						timer = setInterval(function() {
							if ($('#form-upload input[name=\'file\']').val() != '') {
								clearInterval(timer);
								$.ajax({
									url: 'index.php?route=extension/reviewpro/reviewfileupload',
									type: 'post',
									dataType: 'json',
									data: new FormData($('#form-upload')[0]),
									cache: false,
									contentType: false,
									processData: false,
									beforeSend: function() {
										$(node).button('loading');
									},
									complete: function() {
										$(node).button('reset');
									},
									success: function(json) {
										$('.text-danger').remove();

										if (json['error']) {
											$(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
										}

										if (json['success']) {
											alert(json['success']);
											if(json['code'] && json['image']){
												if(json['type'] == 'zip'){
													$('.attachedfiles').append('<label style="margin-right:5px;vertical-align:top"><a href="'+ json['href'] +'">'+ json['image'] +'</a><input type="hidden" value="'+ json['code'] +'" name="file[]"></label>')
												}else{
													$('.attachedfiles').append('<label style="width:100px;margin-right:5px;"><img src="'+ json['image'] +'" class="img-responsive"><input type="hidden" value="'+ json['code'] +'" name="file[]"></label>')
												}
											}
										}
									},
									error: function(xhr, ajaxOptions, thrownError) {
										alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
									}
								});
							}
						}, 500);
					});
					
					{% if guestreview %}
					$('.openmfp').on('click', function() {
						$('.openmfp').magnificPopup({
							items: {
								src: '#modal',
								type: 'inline',
								preloader: true,
								fixedContentPos: false
							},
							closeBtnInside: true
						}).magnificPopup('open');
						$(document).on('click', '.popup-modal-dismiss', function (e) {
							e.preventDefault();
							$.magnificPopup.close();
							$('form')[0].reset();
						});
					});
					{% endif %}
				</script>
				<script>
				$('.sortreview button').on('click', function(){
				var sortvalue = $(this).attr('rel');
				var button = this;
				$.ajax({
					url: 'index.php?route=extension/reviewpro/reviewpro&product_id={{ product_id }}&ratings=' + sortvalue,
					type: 'post',
					dataType: 'html',
					beforeSend: function() {
						$(button).addClass('active');
					},
					complete: function() {
						$(button).addClass('active');
					},
					success: function(html){
						$('#review').html(html);
						$('.sortreview button').removeClass('active');
						//$('.sortreview .clearfilter').show();
						$(button).addClass('active');
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});
			});

			$('.diferent_bar').on('click', function(){
				var rating_id = $(this).attr('rel');
				$.ajax({
					url: 'index.php?route=extension/reviewpro/reviewpro&product_id={{ product_id }}&rating_id=' + rating_id,
					type: 'post',
					dataType: 'html',
					beforeSend: function() {
						
					},
					complete: function() {
						
					},
					success: function(html){
						$('#review').html(html);
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});
			});

			$('.clearfilter').on('click', function(){
			$('.sortreview button').attr('disabled','disabled');
				$.ajax({
					url: 'index.php?route=extension/reviewpro/reviewpro&product_id={{ product_id }}&rating_id=0',
					type: 'post',
					dataType: 'html',
					beforeSend: function() {
						
					},
					complete: function() {
						
					},
					success: function(html){
						$('.sortreview button').removeClass('active');
						$('.sortreview .clearfilter').hide();
						$('.sortreview button').prop('disabled', false);
						$('#review').html(html);
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});
			});
			//--></script> 
				{% if reviewsnippet %}
				<script type="application/ld+json">
					{
					  "@context": "http://schema.org",
					  "@type": "Product",
					  "aggregateRating": {
						"@type": "AggregateRating",
						"ratingValue": "{{ averagerating }}",
						"reviewCount": "{{ review_total }}"
					  },
					  "description": "{{ meta_descriptions }}",
					  "name": "{{ heading_title }}",
					  "image": "{{ thumb }}",
					  "offers": {
						"@type": "Offer",
						{% if reviewprice %}
						{% if not reviewspecial %}
						"price": "{{ reviewprice }}",
						{% else %}
						"price": "{{ reviewspecial }}",
						{% endif %}
						{% endif %}
						"priceCurrency": "{{ getcurrencycode }}"
					  },
					  "review": [
						{% set i = 0 %}
						{% for reviews in allreviews %}
						{% if i > 0 %},{% endif %}{
						 "@type": "Review",
						  "author": "{{ reviews.name }}",
						  "datePublished": "{{ reviews.date_added }}",
						  "description": "{{ reviews.comment }}",
						  "reviewRating": {
							"@type": "Rating",
							"bestRating": "5",
							"ratingValue": "{{ reviews.sumrating }}",
							"worstRating": "1"
						  }
						}
						{% set i = i+1 %}
						{% endfor %}
					  ]
					}
				</script>
				{% endif %}
				{% else %}
			
<form class="form-horizontal" id="form-review">
  <div id="review"></div>
  <legend>{{ text_write }}</legend>
  {% if review_status %}
  {% if review_guest %}
    <div class="form-group required">
      <label class="col-sm-2 control-label" for="input-name">{{ entry_name }}</label>
      <div class="col-sm-10">
        <input type="text" name="name" value="{{ customer_name }}" id="input-name" class="form-control" />
      </div>
    </div>
    <div class="form-group required">
      <label class="col-sm-2 control-label" for="input-review">{{ entry_review }}</label>
      <div class="col-sm-10">
        <textarea name="text" rows="5" id="input-review" class="form-control"></textarea>
        <div class="help-block">{{ text_note }}</div>
      </div>
    </div>
    <div class="form-group required">
      <label class="col-sm-2 control-label">{{ entry_rating }}</label>

      <div class="col-sm-10 rate">
        <span>{{ entry_bad }}</span>
        <input type="radio" name="rating" value="1" />

        <input type="radio" name="rating" value="2" />

        <input type="radio" name="rating" value="3" />

        <input type="radio" name="rating" value="4" />

        <input type="radio" name="rating" value="5" />
        <span>{{ entry_good }}</span>
      </div>
    </div>
    {{ captcha }}
    <div class="buttons clearfix">
      <div class="pull-right">
        <button type="button" id="button-review" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_continue }}</button>
      </div>
    </div>
  {% else %}
    {{ text_login }}
  {% endif %}
  {% endif %}
</form>

				{% endif %}
			
