<?php echo $header; ?>
<div id="content">
  <ul class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
	    <li><?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
    <?php } ?>
  </ul>
  <div class="product-info">
    <div class="left <?php if(!$images){ echo "noThumb"; } ?>">
    <?php if ($images) : //Product Thumbnails ?>
    <div class="thumbs">
    	<?php if(count($images) > 4): ?>
            <ul class="thumbBtns">
                <li><a href="javascript:void(0);" class="up">up</a></li>
                <li><a href="javascript:void(0);" class="down">down</a></li>
            </ul>
    	<?php endif; ?>
        <div class="thumbWrap">
                <?php foreach ($images as $image) : ?>
                    <div><a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="fancybox" rel="fancybox"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a></div>
                <?php endforeach; ?>
        </div>
    </div>
    <?php endif; ?>

    <?php if ($thumb || $images) : //Product Image ?>
         <div class="mainImg">
            <?php if ($thumb) : ?>
                    <a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="fancybox" rel="fancybox"><img src="					<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" /></a>
            <?php endif; ?>
         </div>
    <?php endif; ?>
     </div>
    
<div class="right">
	<!-- AddThis Button BEGIN -->
        <ul class="addthis_toolbox addthis_default_style share">
        	<li><a class="addthis_button_tweet"></a></li>
            <li><a class="addthis_button_google_plusone" g:plusone:size="medium"></a></li>
            <li><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a></li>
        </ul>
        <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4ead658750c660a2"></script>
    <!-- AddThis Button END -->
	<div class="innerRight">
        <div class="prodDesc">
            <h1><?php echo $heading_title; //Product Title ?></h1>
             <div class="description"><?php echo $description; //Product Description ?></div>
             <ul>
                  <?php if ($price) : //Product Price ?>
                        <?php if (!$special) : ?>
                             <li>
                                <span class="normal"><?php echo $text_price; ?></span> 
                                <strong><span class="price"><?php echo $price; ?></span> </strong>
                             </li>  
                        <?php else: ?>
                            <li class="special">
                                <span class="price-old"><?php echo $price; ?></span> 
                                <strong><span class="price-new"><?php echo $special; ?></span></strong>
                            </li>
                        <?php endif; ?>
                  <?php endif; ?>      
                  <li class="stock"><strong><?php echo $stock; ?></strong></li>
				   <?php if ($review_status) : //Reviews ?>
                           <li class="review">
                                <img src="catalog/view/theme/teez/image/stars-<?php echo $rating; ?>.png" alt="<?php echo $reviews; ?>" />
                                <a onclick="$('a[href=\'#tab\']').trigger('click');" class="reviews" rel="reviews"><?php echo $reviews; ?></a>
                           </li>
                    <?php endif; ?>
              </ul>
              <div class="clear"></div>
           </div>

	<?php if ($discounts) : ?>
        <ul>
              <?php foreach ($discounts as $discount) : ?>
                <li><span><?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?></span></li>
              <?php endforeach; ?>
        </ul>
        <?php endif; ?>
      
      <?php include("includes/options.tpl"); //Product Options ?>
     <?php if ($minimum > 1) : ?>
          <div class="minimum"><p><?php echo $text_minimum; ?></p></div>
     <?php endif; ?>
     <div class="qty">                  
                  <strong><span class="text_qty"><?php echo $text_qty; ?></span></strong>
                  <a class="qtyBtn decrease" href="javascript:void(0);">-</a>
                    <input id="qty" type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />      
                  <a class="qtyBtn increase" href="javascript:void(0);">+</a>          
                  <input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />
                <div class="clear"></div>
     </div>
        <div class="addTo">
            
          
             <div class="cart">
                <a id="button-cart" class="button"><?php echo $button_cart; ?></a>
             </div>
                  
	 <div class="wishlist"><a onclick="addToWishList('<?php echo $product_id; ?>');"><?php echo $button_wishlist; ?></a></div>
      	 <div class="compare"><a onclick="addToCompare('<?php echo $product_id; ?>');" data-reveal-id="notification"><?php echo $button_compare; ?></a></div>
            <div class="clear"></div>
       </div>
    </div>
    </div><!-- End Product Inner -->
    <div class="clear"></div>
	</div><!-- End Product Info -->
    
    <ul id="tab" class="tabs">
   		<?php if ($products) { ?>
            <li><a href="javascript:void(0);" class="active" rel="related"><?php echo $tab_related; ?> (<?php echo count($products); ?>)</a></li>
        <?php } ?>
		<?php if ($attribute_groups) { ?>
            <li><a href="javascript:void(0);" rel="attributes"><?php echo $tab_attribute; ?></a></li>
        <?php } ?>
        <?php if ($review_status) { ?>
            <li><a href="javascript:void(0);" rel="reviews"><?php echo $tab_review; ?></a></li>
        <?php } ?>
    </ul>    
     <?php if ($products) { ?>
          <div class="tab related">
            <?php include("includes/related.tpl"); ?>
            <div class="clear"></div>
          </div>
  	 <?php } ?>

   
  <?php if ($attribute_groups) { ?>
          <div class="tab attributes">
          	<?php include("includes/attributes.tpl"); ?>
          </div>
  <?php } ?>
  <?php if ($review_status) { ?>
          <div class="tab reviews">
            <?php include("review_form.tpl"); ?>
            <div class="clear"></div>
          </div>
  <?php } ?>

</div>

<script type="text/javascript"><!--
$('.fancybox').fancybox({cyclic: true,padding:0,titleShow:false});
//--></script> 
<script type="text/javascript"><!--
$('#button-cart').bind('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/update',
		type: 'post',
		data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
			
			if (json['error']) {
				if (json['error']['warning']) {
					$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
				
					$('.warning').fadeIn('slow');
				}
				
				for (i in json['error']) {
					$('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>');
				}
			}	 
						
			if (json['success']) {
				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
				
				var notify = $('#notification').html();
				$.blockUI({ message: $(notify) });
				$('.blockOverlay').click(function(){
					$.unblockUI();
				});
					
				$('#cart_total').html(json['total']);
			}	
		}
	});
});
//--></script>
<?php if ($options) { ?>
<script type="text/javascript" src="catalog/view/javascript/jquery/ajaxupload.js"></script>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'file') { ?>
<script type="text/javascript"><!--
new AjaxUpload('#button-option-<?php echo $option['product_option_id']; ?>', {
	action: 'index.php?route=product/product/upload',
	name: 'file',
	autoSubmit: true,
	responseType: 'json',
	onSubmit: function(file, extension) {
		$('#button-option-<?php echo $option['product_option_id']; ?>').after('<img src="catalog/view/theme/default/image/loading.gif" class="loading" style="padding-left: 5px;" />');
	},
	onComplete: function(file, json) {
		$('.error').remove();
		
		if (json.success) {
			alert(json.success);
			
			$('input[name=\'option[<?php echo $option['product_option_id']; ?>]\']').attr('value', json.file);
		}
		
		if (json.error) {
			$('#option-<?php echo $option['product_option_id']; ?>').after('<span class="error">' + json.error + '</span>');
		}
		
		$('.loading').remove();	
	}
});
//--></script>
<?php } ?>
<?php } ?>
<?php } ?>
<script type="text/javascript"><!--
$('#review .pagination a').live('click', function() {
	$('#review').slideUp('slow');
		
	$('#review').load(this.href);
	
	$('#review').slideDown('slow');
	
	return false;
});			

$('#review').load('index.php?route=product/product/review&product_id=<?php echo $product_id; ?>');

$('#button-review').bind('click', function() {
	$.ajax({
		type: 'POST',
		url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#button-review').attr('disabled', true);
			$('#review-title').after('<div class="attention"><img src="catalog/view/theme/default/image/loading.gif" alt="" /> <?php echo $text_wait; ?></div>');
		},
		complete: function() {
			$('#button-review').attr('disabled', false);
			$('.attention').remove();
		},
		success: function(data) {
			if (data.error) {
				$('#review-title').after('<div class="warning">' + data.error + '</div>');
			}
			
			if (data.success) {
				$('#review-title').after('<div class="success">' + data.success + '</div>');
								
				$('input[name=\'name\']').val('');
				$('textarea[name=\'text\']').val('');
				$('input[name=\'rating\']:checked').attr('checked', '');
				$('input[name=\'captcha\']').val('');
			}
		}
	});
});
//--></script> 
<script type="text/javascript" src="catalog/view/javascript/jquery/ui/jquery-ui-timepicker-addon.js"></script> 
<script type="text/javascript"><!--
if ($.browser.msie && $.browser.version == 6) {
	$('.date, .datetime, .time').bgIframe();
}

$('.date').datepicker({dateFormat: 'yy-mm-dd'});
$('.datetime').datetimepicker({
	dateFormat: 'yy-mm-dd',
	timeFormat: 'h:m'
});
$('.time').timepicker({timeFormat: 'h:m'});
//--></script> 
<?php echo $footer; ?>