<link href="catalog/view/javascript/jquery/magnific/magnific-popup.css" type="text/css" rel="stylesheet" media="screen" />
<link href="catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css" type="text/css" rel="stylesheet" media="screen" />
<script src="catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js" type="text/javascript"></script>
<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>
{% if use_swatches %}
<script src="catalog/view/javascript/plaza/swatches/swatches.js" type="text/javascript"></script>
{% endif %}
{% if use_zoom %}
<link href="catalog/view/theme/tt_safira1/stylesheet/plaza/product/zoom.css" type="text/css" rel="stylesheet" media="screen" />
<link href="catalog/view/javascript/plaza/cloudzoom/css/cloud-zoom.css" type="text/css" rel="stylesheet" media="screen" />
{% endif %}
<div class="product-details">
	<div class="row">
		<div class="col-sm-6 product-image-details">
			{% if use_zoom %}
				<input type="hidden" id="check-use-zoom" value="1" />
				<input type="hidden" id="light-box-position" value="1" />
				<input type="hidden" id="product-identify" value="{{ product_id }}" />
				<div class="lightbox-container"></div>
				{% if use_swatches %}
					<div class="product-zoom-image">
						{% if thumb %}
							<a href="{{ popup }}" class="cloud-zoom main-image" id="product-cloud-zoom" style="width: {{ thumb_dimension.width }}px; height: {{ thumb_dimension.height }}px;"
							   rel="{% if product_zoom_settings.title %} showTitle: true {% else %} showTitle: false {% endif %},
									zoomWidth:{{ thumb_dimension.width }},zoomHeight:{{ thumb_dimension.height }},
									{% if product_zoom_settings.type == 'inner' %} position:'inside', adjustX: 0 {% else %} adjustX: {{ product_zoom_settings.space }} {% endif %}">
								<img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" />
							</a>
						{% endif %}
					</div>
					<div class="additional-container">
					<div class="swiper-viewport">
						<div class="additional-images swiper-container">
							<div class="swiper-wrapper">
								{% if images %}
									{% set img_count = 2 %}
									{% for image in images %}
										<div class="item swiper-slide">
											<a class="cloud-zoom-gallery sub-image" id="product-image-options-{{ image.product_option_value_id }}" href="{{ image.popup }}" title="{{ heading_title }}"
											   rel="useZoom: 'product-cloud-zoom', smallImage: '{{ image.product_image_option }}'" data-pos="{{ img_count }}">
												<img src="{{ image.thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" />
											</a>
										</div>
										{% set img_count = img_count + 1 %}
									{% endfor %}
								{% endif %}
							</div>
						</div>
						<div class="swiper-pager">
							<div class="swiper-button-next additional-button-next"></div>
							<div class="swiper-button-prev additional-button-prev"></div>
						</div>
					</div>
					</div>
				{% else %}
					<div class="product-zoom-image">
						{% if thumb %}
							<a href="{{ popup }}" class="cloud-zoom main-image" id="product-cloud-zoom" style="width: {{ thumb_dimension.width }}px; height: {{ thumb_dimension.height }}px;"
							   rel="{% if product_zoom_settings.title %} showTitle: true {% else %} showTitle: false {% endif %},
									zoomWidth:{{ thumb_dimension.width }},zoomHeight:{{ thumb_dimension.height }},
									adjustX: {{ product_zoom_settings.space }},
									{% if product_zoom_settings.type == 'inner' %} position:'inside' {% endif %}">
								<img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" />
							</a>
						{% endif %}
					</div>
					<div class="additional-container">
						<div class="swiper-viewport">
							<div class="additional-images swiper-container">
								<div class="swiper-wrapper">
									{% if thumb %}
										<div class="item swiper-slide">
											<a class="cloud-zoom-gallery sub-image" href="{{ popup }}" title="{{ heading_title }}"
											   rel="useZoom: 'product-cloud-zoom', smallImage: '{{ thumb }}'" data-pos="1">
												<img src="{{ small_image }}" title="{{ heading_title }}" alt="{{ heading_title }}" />
											</a>
										</div>
									{% endif %}
									{% if images %}
										{% set img_count = 2 %}
										{% for image in images %}
											<div class="item swiper-slide">
												<a class="cloud-zoom-gallery sub-image" href="{{ image.popup }}" title="{{ heading_title }}"
												   rel="useZoom: 'product-cloud-zoom', smallImage: '{{ image.product_image_option }}'" data-pos="{{ img_count }}">
													<img src="{{ image.thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" />
												</a>
											</div>
											{% set img_count = img_count + 1 %}
										{% endfor %}
									{% endif %}
								</div>
							</div>
							<div class="swiper-pager">
								<div class="swiper-button-next additional-button-next"></div>
								<div class="swiper-button-prev additional-button-prev"></div>
							</div>
						</div>
					</div>
				{% endif %}
			{% else %}
				<input type="hidden" id="check-use-zoom" value="0" />
				{% if use_swatches %}
					{% if thumb or images %}
						<ul class="thumbnails" id="swatches-image-container">
							{% if thumb %}
								<li><a class="thumbnail swatches-image" href="{{ popup }}" title="{{ heading_title }}"><img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" /></a></li>
							{% endif %}
							{% if images %}
								{% for image in images %}
									<li class="image-additional"><a class="thumbnail" href="{{ image.popup }}" title="{{ heading_title }}"> <img src="{{ image.thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" /></a></li>
								{% endfor %}
							{% endif %}
						</ul>
						{% if thumb %}
							<input type="hidden" id="product-image-default" data-thumb="{{ thumb }}" data-popup="{{ popup }}" />
						{% endif %}
						{% if images %}
							{% for image in images %}
								<input type="hidden" id="product-image-options-{{ image.product_option_value_id }}" data-thumb="{{ image.product_image_option }}" data-popup="{{ image.popup }}" />
							{% endfor %}
						{% endif %}
					{% endif %}
				{% else %}
					{% if thumb or images %}
						<ul class="thumbnails">
							{% if thumb %}
								<li><a class="thumbnail" href="{{ popup }}" title="{{ heading_title }}"><img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" /></a></li>
							{% endif %}
							{% if images %}
								{% for image in images %}
									<li class="image-additional"><a class="thumbnail" href="{{ image.popup }}" title="{{ heading_title }}"> <img src="{{ image.thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" /></a></li>
								{% endfor %}
							{% endif %}
						</ul>
					{% endif %}
				{% endif %}
			{% endif %}
		</div>
		<div class="col-sm-6 product-info-details">
			<div class="inner">
			<h1><a href="{{ product_link }}">{{ heading_title }}</a></h1>
			{% if review_status %}
				{% if rating %}
					<div class="rating">
						{% for i in 1..5 %}
							{% if rating < i %}
							<span class="icon-ratings"><i class="icon-rating icon-rating-o"></i></span>
							{% else %}
							<span class="icon-ratings"><i class="icon-rating icon-rating-x"></i></span>
							{% endif %}
						{% endfor %} 
						
					</div>
				{% endif %}
			{% endif %}
			{% if show_product_price and price %}
				<p class="price">
					{% if not special %}
						{{ price }}
					{% else %}
						<span class="price-new">{{ special }}</span> <span class="price-old">{{ price }}</span>
					{% endif %}
				</p>
			{% endif %}

			<ul class="list-unstyled">
				{% if manufacturer %}
					<li class="manufacture-product">{{ text_manufacturer }} <a href="{{ manufacturers }}">{{ manufacturer }}</a></li>
				{% endif %}
				<li>{{ text_model }} <span>{{ model }}</span></li>
				{% if reward %}
					<li>{{ text_reward }} <span>{{ reward }}</span></li>
				{% endif %}
				<li>{{ text_stock }} <span>{{ stock }}</span></li>
				{% if show_product_tax and tax %}
					<li>{{ text_tax }} <span>{{ tax }}</span></li>
				{% endif %}
				{% if points %}
					<li>{{ text_points }} <span>{{ points }}</span></li>
				{% endif %}
				{% if discounts %}
					<li>
						<hr>
					</li>
					{% for discount in discounts %}
						<li>{{ discount.quantity }}{{ text_discount }}{{ discount.price }}</li>
					{% endfor %}
				{% endif %}
			</ul>
			
			<div id="product">
				{% if (show_product_button_cart or show_product_options) and options %}
					
					<h3>{{ text_option }}</h3>
					{% for option in options %}
						{% if use_swatches %}
							{% if option.type == 'select' %}
								{% if option.option_id == swatches_option %}
									<div class="form-group{% if option.required %} required {% endif %}">
										<label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
										<ul class="ul-swatches-colors" data-product-option="{{ option.product_option_id }}" data-type="select">
											{% for option_value in option.product_option_value %}
												<li class="swatches-options">
													<a href="javascript:void(0);" onclick="swatches.changeOption($(this));" title="{{ option_value.name }} {% if option_value.price %}({{ option_value.price_prefix }}{{ option_value.price }}){% endif %}"
													   style="{% if option_value.image %} width: {{ icon_swatches_width }}px; height: {{ icon_swatches_height }}px;
													background-image: url('{{ option_value.image }}') {% endif %}"
													   data-product-option-value-id="{{ option_value.product_option_value_id }}">{% if not option_value.image %} {{ option_value.name }} {% endif %}</a>
												</li>
											{% endfor %}
											<li class="swatches-info"></li>
										</ul>
										<select name="option[{{ option.product_option_id }}]" id="input-option{{ option.product_option_id }}" class="form-control option-swatches">
											<option value="0">{{ 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>
								{% else %}
									<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 %}
							{% endif %}
							{% if option.type == 'radio' %}
								{% if option.option_id == swatches_option %}
									<div class="form-group{% if option.required %} required {% endif %}">
										<label class="control-label">{{ option.name }}</label>
										<ul class="ul-swatches-colors" data-product-option="{{ option.product_option_id }}" data-type="radio">
											{% for option_value in option.product_option_value %}
												<li class="swatches-options">
													<a href="javascript:void(0);" onclick="swatches.changeOption($(this));" title="{{ option_value.name }} {% if option_value.price %}({{ option_value.price_prefix }}{{ option_value.price }}){% endif %}"
													   style="{% if option_value.image %} width: {{ icon_swatches_width }}px; height: {{ icon_swatches_height }}px;
												background-image: url('{{ option_value.image }}') {% endif %}"
													   data-product-option-value-id="{{ option_value.product_option_value_id }}">{% if not option_value.image %} {{ option_value.name }} {% endif %}</a>
												</li>
											{% endfor %}
											<li class="swatches-info"></li>
										</ul>
										<div class="option-swatches" id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %}
												<div class="radio">
													<label>
														<input type="radio" class="radio-option-value" id="radio-option-value-{{ option_value.product_option_value_id }}" 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>
								{% else %}
									<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 %}
							{% endif %}
						{% else %}
							{% 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 %}
						{% 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 %}
				{% if show_product_button_cart %}
					<div class="form-group">
						<div class="quantity-content">
							<input type="text" name="quantity" value="{{ minimum }}" size="2" id="input-quantity" class="form-control" />
							<input type="button" id="plus" value="" class="form-control"/>
							<input type="button" id="minus" value="" class="form-control" />
						</div>
						<input type="hidden" name="product_id" value="{{ product_id }}" />
						<button type="button" id="button-cart" data-loading-text="{{ text_loading }}" class="btn btn-primary btn-lg btn-block">{{ button_cart }}</button>
					{% endif %}		
						{% if show_product_button_wishlist or show_product_button_compare %}
							<div class="btn-group">
								{% if show_product_button_wishlist %}
									<button type="button"  class="btn btn-default btn-wishlist" title="{{ button_wishlist }}" onclick="addWishlist('{{ product_id }}');">{{ button_wishlist }}</button>
								{% endif %}
								{% if show_product_button_compare %}
									<button type="button"  class="btn btn-default btn-compare" title="{{ button_compare }}" onclick="addCompare('{{ product_id }}');">{{ button_compare }}</button>
								{% endif %}
							</div>
						{% endif %}
				{% if show_product_button_cart %}		
					</div>
					{% if minimum > 1 %}
						<div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_minimum }}</div>
					{% endif %}
				{% endif %}
			</div>
			
			{% if show_product_tags and tags %}
				<p class="product-tags">{{ text_tags }}
					{% for i in 0..tags|length %}
						{% if i < (tags|length - 1) %} <a href="{{ tags[i].href }}">{{ tags[i].tag }}</a>,
						{% else %} <a href="{{ tags[i].href }}">{{ tags[i].tag }}</a> {% endif %}
					{% endfor %} </p>
			{% endif %}
			{% if show_product_social %}
			<!-- AddThis Button BEGIN -->
			<!--<div class="addthis_toolbox addthis_default_style" data-url="{{ share }}"><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> <a class="addthis_button_tweet"></a> <a class="addthis_button_pinterest_pinit"></a> <a class="addthis_counter addthis_pill_style"></a></div>
			<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-515eeaf54693130e"></script>-->
			<!-- AddThis Button END -->
			{% endif %}	
			</div>
		</div>
	</div>
</div>
		
<script type="text/javascript"><!--
    $('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();

    ptzoom.initAdditionalImagesSlider();

    $('.product-zoom-image').on('click', function () {
        var pos = $('#light-box-position').val();

        ptzoom.openLightBox(pos);
    });

    $('.sub-image').on('click', function () {
        var pos = $(this).data('pos');
        $('#light-box-position').val(pos);
    });

    $('select[name=\'recurring_id\'], input[name="quantity"]').change(function(){
        $.ajax({
            url: 'index.php?route=product/product/getRecurringDescription',
            type: 'post',
            data: $('input[name=\'product_id\'], input[name=\'quantity\'], select[name=\'recurring_id\']'),
            dataType: 'json',
            beforeSend: function() {
                $('#recurring-description').html('');
            },
            success: function(json) {
                $('.alert-dismissible, .text-danger').remove();

                if (json['success']) {
                    $('#recurring-description').html(json['success']);
                }
            }
        });
    });
    //--></script>
<script type="text/javascript"><!--
    $('#button-cart').on('click', function() {
        $.ajax({
            url: 'index.php?route=checkout/cart/add',
            type: 'post',
            data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
            dataType: 'json',
            beforeSend: function() {
                $('#button-cart').button('loading');
            },
            complete: function() {
                $('#button-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 = $('#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']) {
                        $('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-content').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-container').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: document.cookie.match(new RegExp('language=([^;]+)'))[1],
        pickTime: false
    });

    $('.datetime').datetimepicker({
        language: document.cookie.match(new RegExp('language=([^;]+)'))[1],
        pickDate: true,
        pickTime: true
    });

    $('.time').datetimepicker({
        language: document.cookie.match(new RegExp('language=([^;]+)'))[1],
        pickDate: false
    });

    $('button[id^=\'button-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=tool/upload',
                    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']);

                            $(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"><!--
    $('#review').delegate('.pagination a', 'click', function(e) {
        e.preventdefault();

        $('#review').fadeOut('slow');

        $('#review').load(this.href);

        $('#review').fadeIn('slow');
    });

    $('#review').load('index.php?route=product/product/review&product_id={{ product_id }}');

    $('#button-review').on('click', function() {
        $.ajax({
            url: 'index.php?route=product/product/write&product_id={{ product_id }}',
            type: 'post',
            dataType: 'json',
            data: $("#form-review").serialize(),
            beforeSend: function() {
                $('#button-review').button('loading');
            },
            complete: function() {
                $('#button-review').button('reset');
            },
            success: function(json) {
                $('.alert-dismissible').remove();

                if (json['error']) {
                    $('#review').after('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
                }

                if (json['success']) {
                    $('#review').after('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');

                    $('input[name=\'name\']').val('');
                    $('textarea[name=\'text\']').val('');
                    $('input[name=\'rating\']:checked').prop('checked', false);
                }
            }
        });
    });

    $(document).ready(function() {
        $('.thumbnails').magnificPopup({
            type:'image',
            delegate: 'a',
            gallery: {
                enabled: true
            }
        });
    });
    
    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-content').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-container').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-content').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-container').animate({ scrollTop: 0 }, 'slow');
                }
            },
            error: function(xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
    }
	var minimum = {{ minimum }};
	$("#quickview-content #input-quantity").change(function(){
		if ($(this).val() < minimum) {
		  alert("Minimum Quantity: "+minimum);
		  $("#quickview-content #input-quantity").val(minimum);
		}
	});
	// increase number of product
	function minus(minimum){
		var currentval = parseInt($("#quickview-content #input-quantity").val());
		$("#quickview-content #input-quantity").val(currentval-1);
		if($("#quickview-content #input-quantity").val() <= 0 || $("#quickview-content #input-quantity").val() < minimum){
		  alert("Minimum Quantity: "+minimum);
		  $("#quickview-content #input-quantity").val(minimum);
		}
	};
	// decrease of product
	function plus(){
		var currentval = parseInt($("#quickview-content #input-quantity").val());
		$("#quickview-content #input-quantity").val(currentval+1);
	};
	$('#quickview-content #minus').click(function(){
		minus(minimum);
	});
	$('#quickview-content #plus').click(function(){
		plus();
	});
//--></script>