<?php
    $_zoom_w = Mage::getStoreConfig('prozoom/prozoom_config/zoom_w');
    $_zoom_h = Mage::getStoreConfig('prozoom/prozoom_config/zoom_h');
	$_border_w = Mage::getStoreConfig('prozoom/prozoom_config/zoom_border_w');
	$_border_color = Mage::getStoreConfig('prozoom/prozoom_config/zoom_border_color');
    $_lightbox_w = Mage::getStoreConfig('prozoom/prozoom_config/lightbox_w');   
    $_lightbox_h = Mage::getStoreConfig('prozoom/prozoom_config/lightbox_h');
    $_thumbnail_qty = Mage::getStoreConfig('prozoom/prozoom_config/thumbnail_qty');   
    $_thumbnail_w = Mage::getStoreConfig('prozoom/prozoom_config/thumbnail_w');
    $_thumbnail_h = Mage::getStoreConfig('prozoom/prozoom_config/thumbnail_h');
	$_scroll_qty = Mage::getStoreConfig('prozoom/prozoom_config/scroll_qty');
	$_auto = Mage::getStoreConfig('prozoom/prozoom_config/auto_scroll');
?>
<?php
    $_product = $this->getProduct();
    $_helper = $this->helper('catalog/output');
?>

<?php if ( count($this->getGalleryImages()) > 0 ): ?>
	<?php if( (!Mage::getStoreConfig('prozoom/prozoom_config/enabled_thumbnail')) || ( count($this->getGalleryImages()) < $_thumbnail_qty )|| ( count($this->getGalleryImages()) == $_thumbnail_qty )) { ?>
		<div class="more-views ma-more-img">
			<h2><?php echo $this->__('More Views') ?></h2>
			<ul>
			<?php foreach ($this->getGalleryImages() as $_image): ?>
				<li>
					<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize(1200,1200); ?>" class="cloud-zoom-gallery" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" name="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize($_lightbox_w, $_lightbox_h); ?>"
										rel="useZoom: 'ma-zoom1', smallImage: '<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize(265); ?>'">
					<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($_thumbnail_w, $_thumbnail_h); ?>" width="<?php echo $_thumbnail_w ?>" height="<?php echo $_thumbnail_h ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
				</li>
			<?php endforeach; ?>
			</ul>
			<!-- thumbnail for lighbox-->
				<ul class="mt-thumb-light" style="display:none;">
					<?php foreach ($this->getGalleryImages() as $_image): ?>
						<li>
							<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize($_lightbox_w, $_lightbox_h); ?>" rel="lightbox[rotation]" title="<?php echo $_product->getName();?>"></a>
						</li>
					<?php endforeach; ?>                                                                
				</ul>
			<!--##########-->
			<script type="text/javascript">
				//<![CDATA[
					$jq(document).ready(function(){
						$jq('head').append('<style type="text/css"> .cloud-zoom-big { border:<?php echo $_border_w ?>px solid <?php echo $_border_color ?> }</style>');
					});
				//]]>
			</script>
		</div>
	<?php } else { ?>
		<?php if( Mage::getStoreConfig('prozoom/prozoom_config/scroll_style')=='horizontal' ) { ?>
			<div class="more-views ma-thumbnail-container">
				<h2><?php echo $this->__('More Views') ?></h2>
					<ul class="bxslider">
					<?php foreach ($this->getGalleryImages() as $_image): ?>
						<li class="thumbnail-item">
							<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize(1200,1200); ?>" class="cloud-zoom-gallery" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" name="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize($_lightbox_w, $_lightbox_h); ?>"
												rel="useZoom: 'ma-zoom1', smallImage: '<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize(265); ?>'">
							<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($_thumbnail_w, $_thumbnail_h); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
						</li>
					<?php endforeach; ?>
					</ul>
				<?php //thumbnail for lighbox ?>
					<ul class="mt-thumb-light" style="display:none;">
						<?php foreach ($this->getGalleryImages() as $_image): ?>
							<li>
								<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize($_lightbox_w, $_lightbox_h); ?>" rel="lightbox[rotation]" title="<?php echo $_product->getName();?>"></a>
							</li>
						<?php endforeach; ?>                                                                
					</ul>
				<?php //--##########-- ?>
				<script type="text/javascript">
					//<![CDATA[
						$jq('.ma-thumbnail-container .bxslider').bxSlider({
							<?php if($_auto ) { ?>
								auto: true,
							<?php } ?>
							slideWidth: <?php echo $_thumbnail_w ?>,
							slideMargin: 5,
							minSlides: <?php if($_thumbnail_qty) echo $_thumbnail_qty; else echo '4'; ?>,
							maxSlides: <?php if($_thumbnail_qty) echo $_thumbnail_qty; else echo '4'; ?>,
							<?php if (count($this->getGalleryImages()) < 5 ) { ?>
							controls: false,
							<?php } ?>
							pager: false,
							speed: 500,
							pause: 3000
						});		
					//]]>
				</script>
			</div>
		<?php } else { ?>
			
			<div class="more-views ma-thumbnail-container">
				<h2><?php echo $this->__('More Views') ?></h2>
					<ul class="bxslider">
					<?php foreach ($this->getGalleryImages() as $_image): ?>
						<li class="thumbnail-item">
							<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize(1200,1200); ?>" class="cloud-zoom-gallery" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" name="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize($_lightbox_w, $_lightbox_h); ?>"
												rel="useZoom: 'ma-zoom1', smallImage: '<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize(380,380); ?>'" style='display:block;width:68px;height: 89px;float: none;'>
							<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($_thumbnail_w, $_thumbnail_h); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
						</li>
					<?php endforeach; ?>
					</ul>
				<?php //thumbnail for lighbox ?>
					<ul class="mt-thumb-light" style="display:none;">
						<?php foreach ($this->getGalleryImages() as $_image): ?>
							<li>
								<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize($_lightbox_w, $_lightbox_h); ?>" rel="lightbox[rotation]" title="<?php echo $_product->getName();?>"></a>
							</li>
						<?php endforeach; ?>                                                                
					</ul>
				<?php //--##########-- ?>
				<script type="text/javascript">
					//<![CDATA[
						$jq('.ma-thumbnail-container .bxslider').bxSlider({
							<?php if($_auto ) { ?>
								auto: true,
							<?php } ?>
							slideWidth: <?php echo $_thumbnail_w ?>,
							slideMargin:20,
							minSlides: <?php if($_thumbnail_qty) echo $_thumbnail_qty; else echo '4'; ?>,
							maxSlides: <?php if($_thumbnail_qty) echo $_thumbnail_qty; else echo '4'; ?>,
							<?php if (count($this->getGalleryImages()) < 5 ) { ?>
							controls: false,
							<?php } ?>
							pager: false,
							speed: 500,
							pause: 3000,
							mode: 'vertical',
							adaptiveHeight: true,
							mode: 'vertical',
						});		
					//]]>
				</script>
			</div>
		<?php } ?>
	<?php } ?>

<?php endif; ?>

<p class="product-image">
    <?php
        $_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(380,380).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
    ?>
	<!-- images for lightbox -->
	<a href="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize($_lightbox_w, $_lightbox_h); ?>" class = "ma-a-lighbox" rel="lightbox[rotation]"></a>
	<!--++++++++++++-->
	<a href="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(1200,1200); ?>" class = "cloud-zoom" id="ma-zoom1" style="position: relative; display: block;" rel="adjustX:10, adjustY:-2, zoomWidth:<?php echo $_zoom_w; ?>, zoomHeight:<?php echo $_zoom_h; ?>">
		<?php echo $_helper->productAttribute($_product, $_img, 'image'); ?>
	</a>
</p>

