<script src="catalog/view/javascript/jquery/datetimepicker/moment/moment.min.js" type="text/javascript"></script>
<script src="catalog/view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js" type="text/javascript"></script>
<script src="catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css" type="text/css" rel="stylesheet" media="screen" />
<div class="quickview-wrapper-inner container">
	<div class="quickview-container">
		<div class="row pro-deatil">
			<div class="col-sm-5 quick-product-left">
				{% if thumb or images %}
					<div class="thumbnails">
						{% if thumb %}
							<div class="pro-image">
								<a title="{{ heading_title }}" class="">
									<img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" />
								</a>
							</div>
						{% endif %}
						{% if images %}
							<div id="quick-carousel" class="owl-carousel owl-theme clearfix">
								<div class="image-additional">
									<a title="{{ heading_title }}">
										<img src="{{ thumb }}"  title="{{ heading_title }}" data-image-large-src="{{ thumb }}" alt="{{ heading_title }}" />
									</a>
								</div>
								{% for image in images %}
									<div class="image-additional">
										<a title="{{ heading_title }}">
											<img src="{{ image.thumb }}" title="{{ heading_title }}" data-image-large-src="{{ image.thumb }}" alt="{{ heading_title }}"/>
										</a>
									</div>
								{% endfor %}
							</div>
						{% endif %}
					</div>
				{% endif %}
			</div>
			<div class="col-sm-7">
			<div class="quick-product-right right_info">
				<h1>{{ heading_title }}</h1>
				{% if review_status %}
					<div class="rating clearfix">
						<div class="product-rating">{% for i in 1..5 %}
							{% if rating < i %}<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-1x"></i></span>{% else %}<span class="fa fa-stack"><i class="fa fa-star fa-stack-1x"></i><i class="fa fa-star-o fa-stack-1x"></i></span>{% endif %}
							{% endfor %}
						</div>
						<a class="reviews">{{ reviews }}</a>
					</div>
				{% endif %}	
				<hr>
				<ul class="list-unstyled">					
					{% if manufacturer %}
						<li><span class="disc">{{ text_manufacturer }}:</span> <a class="disc1" href="{{ manufacturers }}">{{ manufacturer }}</a></li>
					{% endif %}
					<li><span class="disc">{{ text_model }}</span><span class="disc1"> {{ model }}</span></li>
					{% if reward %}
						<li><span class="disc">{{ text_reward }}</span><span class="disc1"> {{ reward }}</span></li>
					{% endif %}
					<li><span class="disc">{{ text_stock }}</span><span class="disc1"> {{ stock }}</span></li>
				</ul>
				{% if price %}
					<hr>
					<ul class="list-unstyled">
						{% if not special %}
							<li>
								<span class="pro_price">{{ price }}</span>
							</li>
						{% else %}
							<li>
								<span class="pro_price">{{ special }}</span><span class="pro_oldprice" style="text-decoration: line-through;">{{ price }}</span>
							</li>
						{% endif %}
						{% if tax %}
							<li class="tax">{{ text_tax }} {{ tax }}</li>
						{% endif %}
						{% if points %}
							<li>{{ text_points }} {{ points }}</li>
						{% endif %}
						{% if discounts %}
							{% for discount in discounts %}
								<li>{{ discount.quantity }}{{ text_discount }}{{ discount.price }}</li>
							{% endfor %}
						{% endif %}
					</ul>
					<hr>
				{% endif %}
				<div id="product" class="product-options">
					{% if options %}
						<h3>{{ text_option }}</h3>
						{% for option in options %}
							{% if option.type == 'select' %}
								<div class="form-group{% if option.required %} required {% endif %}">
									<label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
									<select name="option[{{ option.product_option_id }}]" id="input-option{{ option.product_option_id }}" class="form-control">
										<option value="">{{ text_select }}</option>
										{% for option_value in option.product_option_value %}
											<option value="{{ option_value.product_option_value_id }}">{{ option_value.name }}
												{% if option_value.price %}
													({{ option_value.price_prefix }}{{ option_value.price }})
												{% endif %}
											</option>
										{% endfor %}
									</select>
								</div>
							{% endif %}
							{% if option.type == 'radio' %}
								<div class="form-group{% if option.required %} required {% endif %}">
									<label class="control-label">{{ option.name }}</label>
									<div id="input-option{{ option.product_option_id }}">
										{% for option_value in option.product_option_value %}
											<div class="radio">
												<label>
													<input type="radio" name="option[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" />
													{% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" />
													{% endif %}
													{{ option_value.name }}
													{% if option_value.price %}
														({{ option_value.price_prefix }}{{ option_value.price }})
													{% endif %}
												</label>
											</div>
										{% endfor %}
									</div>
								</div>
							{% endif %}
							{% if option.type == 'checkbox' %}
								<div class="form-group{% if option.required %} required {% endif %}">
									<label class="control-label">{{ option.name }}</label>
									<div id="input-option{{ option.product_option_id }}">
										{% for option_value in option.product_option_value %}
											<div class="checkbox">
												<label>
													<input type="checkbox" name="option[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" />
													{% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %}
													{{ option_value.name }}
													{% if option_value.price %}
														({{ option_value.price_prefix }}{{ option_value.price }})
													{% endif %}
												</label>
											</div>
										{% endfor %}
									</div>
								</div>
							{% endif %}
							{% if option.type == 'text' %}
								<div class="form-group{% if option.required %} required {% endif %}">
									<label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
									<input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control" />
								</div>
							{% endif %}
							{% if option.type == 'textarea' %}
								<div class="form-group{% if option.required %} required {% endif %}">
									<label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
									<textarea name="option[{{ option.product_option_id }}]" rows="5" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control">{{ option.value }}</textarea>
								</div>
							{% endif %}
							{% if option.type == 'file' %}
								<div class="form-group{% if option.required %} required {% endif %}">
									<label class="control-label">{{ option.name }}</label>
									<button type="button" id="button-upload{{ option.product_option_id }}" data-loading-text="{{ text_loading }}" class="btn btn-default btn-block"><i class="fa fa-upload"></i> {{ button_upload }}</button>
									<input type="hidden" name="option[{{ option.product_option_id }}]" value="" id="input-option{{ option.product_option_id }}" />
								</div>
							{% endif %}
							{% if option.type == 'date' %}
								<div class="form-group{% if option.required %} required {% endif %}">
									<label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
									<div class="input-group date">
										<input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="YYYY-MM-DD" id="input-option{{ option.product_option_id }}" class="form-control" />
										<span class="input-group-btn">
											<button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
										</span>
									</div>
								</div>
							{% endif %}
							{% if option.type == 'datetime' %}
								<div class="form-group{% if option.required %} required {% endif %}">
									<label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
									<div class="input-group datetime">
										<input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="YYYY-MM-DD HH:mm" id="input-option{{ option.product_option_id }}" class="form-control" />
										<span class="input-group-btn">
											<button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
										</span>
									</div>
								</div>
							{% endif %}
							{% if option.type == 'time' %}
								<div class="form-group{% if option.required %} required {% endif %}">
									<label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
									<div class="input-group time">
										<input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="HH:mm" id="input-option{{ option.product_option_id }}" class="form-control" />
										<span class="input-group-btn">
											<button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
										</span>
									</div>
								</div>
							{% endif %}
						{% endfor %}
					{% endif %}
					{% if recurrings %}
						<hr>
						<h3>{{ text_payment_recurring }}</h3>
						<div class="form-group required">
							<select name="recurring_id" class="form-control">
								<option value="">{{ text_select }}</option>
								{% for recurring in recurrings %}
									<option value="{{ recurring.recurring_id }}">{{ recurring.name }}</option>
								{% endfor %}
							</select>
							<div class="help-block" id="recurring-description"></div>
						</div>
					{% endif %}
					<div class="form-group">
						<div class="product-btn-quantity">
							<label class="control-label qty" for="input-quantity">{{ entry_qty }}</label>
                            <div class="minus-plus">
                            	<button class="minus"><i class="fa fa-minus"></i></button>
                            	<input type="text" name="quantity" value="{{ minimum }}" size="2" id="input-quantity" class="form-control" />
                            	<button class="plus"><i class="fa fa-plus"></i></button>	                            	
                            </div>
                            <button type="button" id="quick-cart" data-loading-text="{{ text_loading }}" class="btn btn-primary btn-lg btn-block">{{ button_cart }}</button>
                            <input type="hidden" name="product_id" value="{{ product_id }}" />
                        </div>
                    </div>
                   	<div class="btn-group">						
						<button type="button" class="pro_wish" title="{{ button_wishlist }}" onclick="addWishlist('{{ product_id }}');"><i class="icon-heart"></i>{{ button_wishlist }}</button>
						<button type="button" class="pro_comper" title="{{ button_compare }}" onclick="addCompare('{{ product_id }}');"><i class="icon-change"></i>{{ button_compare }}</button>
					</div>                       
					
					{% if minimum > 1 %}
						<div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_minimum }}</div>
					{% endif %}
				</div>
			</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript"><!--
$('.quickview-container select[name=\'recurring_id\'],.quickview-container input[name="quantity"]').change(function(){
	$.ajax({
		url: 'index.php?route=product/product/getRecurringDescription',
		type: 'post',
		data: $('.quickview-container input[name=\'product_id\'], .quickview-container input[name=\'quantity\'], .quickview-container select[name=\'recurring_id\']'),
		dataType: 'json',
		beforeSend: function() {
			$('.quickview-container #recurring-description').html('');
		},
		success: function(json) {
			$('.alert-dismissible, .text-danger').remove();

			if (json['success']) {
				$('.quickview-container #recurring-description').html(json['success']);
			}
		}
	});
});
//--></script>
<script type="text/javascript"><!--
$('.quickview-container #quick-cart').on('click', function() {

	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: $('.quickview-container input[type=\'text\'], .quickview-container input[type=\'hidden\'], .quickview-container input[type=\'radio\']:checked, .quickview-container input[type=\'checkbox\']:checked, .quickview-container select, .quickview-container textarea'),
		dataType: 'json',
		beforeSend: function() {
			$('.quickview-container #quick-cart').button('loading');
		},
		complete: function() {
			$('.quickview-container #quick-cart').button('reset');
		},
		success: function(json) {
			$('.alert-dismissible, .text-danger').remove();
			$('.form-group').removeClass('has-error');

			if (json['error']) {
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						var element = $('.quickview-container #input-option' + i.replace('_', '-'));

						if (element.parent().hasClass('input-group')) {
							element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
						} else {
							element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
						}
					}
				}

				if (json['error']['recurring']) {
					$('.quickview-container select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
				}

				// Highlight any found errors
				$('.text-danger').parent().addClass('has-error');
			}

			if (json['success']) {
				$('.quickview-wrapper-inner').prepend('<div class="alert alert-success alert-dismissible">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

				$('#cart > button').html('<span id="cart-total">' + json['total'] + '</span>');

				$('.quickview-wrapper').animate({ scrollTop: 0 }, 'slow');

				$('#cart > ul').load('index.php?route=common/cart/info ul li');
			}
		},
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
	});
});
//--></script> 
<script type="text/javascript"><!--
$('.date').datetimepicker({
	language: '{{ datepicker }}',
	pickTime: false
});

$('.datetime').datetimepicker({
	language: '{{ datepicker }}',
	pickDate: true,
	pickTime: true
});

$('.time').datetimepicker({
	language: '{{ datepicker }}',
	pickDate: false
});

$('.quickview-container button[id^=\'button-upload\']').on('click', function() {
	var node = this;

	$('#form-upload').remove();

	$('.quickview-wrapper').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

	$('.quickview-container #form-upload input[name=\'file\']').trigger('click');

	if (typeof timer != 'undefined') {
    	clearInterval(timer);
	}

	timer = setInterval(function() {
		if ($('.quickview-container #form-upload input[name=\'file\']').val() != '') {
			clearInterval(timer);

			$.ajax({
				url: 'index.php?route=tool/upload',
				type: 'post',
				dataType: 'json',
				data: new FormData($('.quickview-wrapper #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']);

						$(node).parent().find('input').val(json['code']);
					}
				},
				error: function(xhr, ajaxOptions, thrownError) {
					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
				}
			});
		}
	}, 500);
});
//--></script>
<script type="text/javascript"><!--   
    function addWishlist(product_id) {
        $.ajax({
            url: 'index.php?route=account/wishlist/add',
            type: 'post',
            data: 'product_id=' + product_id,
            dataType: 'json',
            success: function(json) {
                $('.alert-dismissible').remove();

                if (json['redirect']) {
                    location = json['redirect'];
                }

                if (json['success']) {
                    $('.quickview-wrapper-inner').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                }

                $('#wishlist-total span').html(json['total']);
                $('#wishlist-total').attr('title', json['total']);

                $('.quickview-wrapper').animate({ scrollTop: 0 }, 'slow');
            },
            error: function(xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
    }
    
    function addCompare(product_id) {
        $.ajax({
            url: 'index.php?route=product/compare/add',
            type: 'post',
            data: 'product_id=' + product_id,
            dataType: 'json',
            success: function(json) {
                $('.alert-dismissible').remove();

                if (json['success']) {
                    $('.quickview-wrapper-inner').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');

                    $('#compare-total').html(json['total']);

                    $('.quickview-wrapper').animate({ scrollTop: 0 }, 'slow');
                }
            },
            error: function(xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
    }
    
	$(document).ready(function() {
		$('.image-additional img').on(
	      'click',
	      (event) => {
	        $('.pro-image img').attr('src',$(event.target).data('image-large-src'));
	        $('.selected').removeClass('selected');
	        $(event.target).addClass('selected');
	        $('.pro-image img').prop('src', $(event.currentTarget).data('image-large-src'));
	      }	  
	    );
	});
//--></script>