<?php global $modules, $images, $images_files, $id, $images_dir, $system_data, $template_data, $page_info; ?>

<?php if($module_settings["images"]["gallery description visible"] == 1) { ?>
	<div class="images-gallery-description" id="images-gallery-description-<?php echo $id; ?>">
		<?php echo $module_settings["images"]["gallery description"]; ?>
		<?php if(!empty($module_settings["images"]["gallery link text"])) { ?><a class="gallery-link" href="<?php echo $page_info->href . '/images'; ?>"><?php echo $module_settings["images"]["gallery link text"]; ?></a><?php } ?>
	</div>
<?php } ?>

<?php if($module_settings["images"]["gallery description visible"] == 0 && $module_settings["images"]["open image"] != 'disabled') { ?>
    <div class="images-fullview" id="images-fullview-<?php echo $id; ?>">
    	<div style="display: none" class="images-title" id="images-title-<?php echo $id; ?>"><!-- dynamic content --></div>

        <div style="display: none; font-family: Arial" class="images-controls" id="images-controls-<?php echo $id; ?>">
        	<span class="number"><ins id="images-number-<?php echo $id; ?>">0</ins> / <?php echo count($images); ?></span>
    		<span class="status" id="images-status-<?php echo $id; ?>"></span>
    		<a class="backward" id="images-backward-<?php echo $id; ?>"><span>◄</span></a>
    		<a class="forward" id="images-forward-<?php echo $id; ?>"><span>►</span></a>
    		<?php if($module_settings["images"]["slideshow"] == 1) { ?><a class="slideshow" id="images-slideshow-<?php echo $id; ?>"><span>❙❙</span></a><?php } ?>
    		<a class="close" id="images-close-<?php echo $id; ?>"><span>×</span></a>
    	</div><br>
    
    	<table class="images-fullview-table"><tr><td style="background-color: <?php echo $module_settings["images"]["thumbnail background"]; ?>" id="images-img-<?php echo $id; ?>"><!-- dynamic content --></td></tr></table>
    		
    	<div style="display: none" class="images-description" id="images-description-<?php echo $id; ?>"><!-- dynamic content --></div>
    </div>
<?php } ?>

<?php if($module_settings["images"]["gallery description visible"] == 0 && isset($images)) { ?>
    <div class="images-thumbnails" id="images-thumbnails-<?php echo $id; ?>">
    	<table style="background-color: <?php echo $module_settings["images"]["thumbnail background"]; ?>" class="images-thumbnails-table">
    		<?php $i = 0; foreach($images as $image) { ?>
    			<?php if($i == 0) { ?><tr><?php } $i++; ?>
    				<td style="width: <?php echo $module_settings["images"]["thumbnail mode"] == 'variable width' ? $image['thumb width'] : $module_settings["images"]["thumbnail size"]; ?>px; height: <?php echo $module_settings["images"]["thumbnail mode"] == 'variable height' ? $image['thumb height'] : $module_settings["images"]["thumbnail size"]; ?>px">
    					<?php if($module_settings["images"]["open image"] != 'disabled') { ?><a <?php echo $module_settings["images"]["open image attribute"]; ?> href="<?php echo $image['path']; ?>"><?php } ?>
    					<img src="<?php echo $image['img src']; ?>" alt="<?php echo $image['basename']; ?>" width="<?php echo $image['thumb width']; ?>" height="<?php echo $image['thumb height']; ?>">
    					<?php if($module_settings["images"]["open image"] != 'disabled') { ?></a><?php } ?>
    				</td>
    			<?php if($images_files[count($images_files) - 1] == $image['basename'] && $module_settings["images"]["images per row"] < count($images)) for($j = 0; $j < $module_settings["images"]["images per row"] - $i; $j++) { ?><td style="width: <?php echo $module_settings["images"]["thumbnail size"]; ?>px; height: <?php echo $module_settings["images"]["thumbnail size"]; ?>px" class="empty"> </td><?php } ?>
    			<?php if($i == $module_settings["images"]["images per row"] || $images_files[count($images_files) - 1] == $image['basename']) { $i = 0; ?></tr><?php } ?>
    		<?php } ?>
    	</table>
    </div>
    
    <?php if($module_settings["images"]["open image"] != 'disabled') { ?>
    	<!-- JS ACTIONS -->
    	<script type="text/javascript">
    		// Global data
    		var pagemapImages = [];
    		
    		<?php $i = 1; $last_image = ''; ?>
    		<?php if(isset($images)) foreach($images as $image) { ?>
    			pagemapImages['<?php echo $image['basename']; ?>'] = {
    				'basename' : '<?php echo $image['basename']; ?>',
    				'width' : '<?php echo trim($image['width']); ?>',
    				'height' : '<?php echo trim($image['height']); ?>',
    				'number' : <?php echo $i; ?>,
    				'last image' : '<?php echo $image['last image']; ?>',
    				'next image' : '<?php echo $image['next image']; ?>'
    			};
    			<?php $i++; $last_image = $image['basename']; ?>
    		<?php } ?>
    			
    		eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8 e=f(a){8 b;3(4.9){b=(a==\'5\')?4.9:4.g}c 3(1.2&&1.2.6){b=(a==\'5\')?1.2.6:1.2.d}c 3(1.7){b=(a==\'5\')?1.7.6:1.7.d}h(b<0)?0:b};',18,18,'|document|documentElement|if|self|width|clientWidth|body|var|innerWidth|||else|clientHeight|innerSize|function|innerHeight|return'.split('|'),0,{}));
    		
    		var templateSyntax = '<?php echo $template_data['syntax']; ?>';
    		var imagesPath = '<?php echo $images_dir; ?>';
    		var modulePath = '<?php echo get_module_path('images'); ?>';
    		var popupPath = '<?php echo is_file(get_module_path('images') . 'popup.php') ? get_module_path('images') : $system_data['folder']['modules'] . 'images/'; ?>popup.php';
    
    		var imagesID = '<?php echo $id; ?>';
    		var openImage = '<?php echo $module_settings["images"]["open image"]; ?>';
    		var showImageProperties = <?php echo $module_settings["images"]["image properties"]; ?>;
    		var firstImage = '<?php echo $images_files[0]; ?>';
    
    		var maxWidth = parseInt(<?php echo $module_settings["images"]["image fullscreen"] == 1 ? 'innerSize("width")' : $module_settings["images"]["image width"]; ?>);
    		var maxHeight = parseInt(<?php echo $module_settings["images"]["image fullscreen"] == 1 ? 'innerSize("height")' : $module_settings["images"]["image height"]; ?>);
    		
    		var popupWidth = <?php echo $module_settings["images"]["popup width"]; ?>;
    		var popupHeight = <?php echo $module_settings["images"]["popup height"]; ?>;
    		
    		var startWithFullImage = <?php echo $module_settings["images"]["page start full"]; ?>;
    		var showControls = <?php echo $module_settings["images"]["page show controls"]; ?>;
    		var showImages = <?php echo $module_settings["images"]["page show images"]; ?>;
    		var slideshow = <?php echo $module_settings["images"]["slideshow"]; ?>;
    		var slideshow_pause_start = <?php echo $module_settings["images"]["slideshow pause start"]; ?>;
    		var slideshow_loop = <?php echo $module_settings["images"]["slideshow loop"]; ?>;
    		var slideshowSeconds = <?php echo $module_settings["images"]["slideshow seconds"]; ?>;
    		
        	var onImageLoading = function() { /* custom function for on image loading */ };
        	var onImageLoaded = function() { /* custom function for on image loaded */ };
    	</script>

    	<script type="text/javascript" src="<?php echo $system_data['folder']['modules']; ?>images/sources/actions.js">
    	</script>
    <?php } ?>
<?php } ?>
