<div id="module_<?php echo($module_instance_id); ?>" class="module slippry-module <?php echo($module_class); ?>">
	<ul id="slider_<?php echo $module_instance_id?>">
		<?php
		for($i=0; $i<count($full_files); $i++)
		{
			$full    = $full_files[$i];
			$img 	 = $full;
			$a_name  = "slippry_" . $module_instance_id . "_image$i";
			$link    = $default_link;
			$target  = "_self";
			$class   = "";
			$onclick = "";

			if($lightbox)
			{
				$class 	= "lightbox";
				$link 	= $full;
			}
			else
			{
				//check if this image should be linked
				for($j=0; $j<20; $j++)
				{
					if(strtolower($module->setting("image$j")) == strtolower(basename($full)))
					{
						$link = $module->setting("link$j");

						if(substr($link, 0, 4) == "http")
						{
							$target = "_blank";
						}
						else
						{
							$target = "_self";
						}

						break;
					}
				}
			}

			if($img)
			{
				if(file_exists(ABSOLUTE_PATH . $img .".json"))
				{
					$data        = json_decode(file_get_contents(ABSOLUTE_PATH . $img . ".json"));
					$alt         = htmlentities($data->alt);
					$title       = htmlentities($data->title);
					$description = htmlentities($data->description);
				}
				else
				{
					// Create a cleaned up version of the file name as a default alt/title.
					$title = str_replace("%20", " ", basename($img));
					//remove file extension
					$title = str_ireplace(array(".jpg", ".jpeg", ".gif", ".png", ".bmp", ".tiff", "/thumbnails/"), "", $title);
					//put a space before all capital letters (camel case)
					$title = preg_replace('/([A-Z][a-z0-9])/', ' $1', $title);
					//remove any thumbnail resizing (100x50) from the end of the filename
					$title = preg_replace('/(_thumb)?_?(\d+)x(\d+)/', '', $title);
					//remove @2x from the end of the filename
					$title = preg_replace('/@2x/', '', $title);
					//replace remaining underscores, dashes, and slashes with spaces
					$title = str_replace(array("_", "/", "\\"), " ", $title);
					$title = trim($title);
					$description = $title;
				}

				$size = @getimagesize(ABSOLUTE_PATH . "/" . $img);
				$img = str_replace(" ", "%20", $img);

				if($link == "" && !$lightbox)
				{
					$onclick = "onclick='return false;'";
				}
				?><li><a href="<?php echo($link); ?>" <?php echo($onclick); ?> id="<?php echo($a_name); ?>" rel="slider_<?php echo $module_instance_id?>" class="<?php echo($class); ?>" target="<?php echo($target); ?>"><img src="<?php echo($img); ?>" width="<?php echo($size[0]); ?>" height="<?php echo($size[1]); ?>" alt="<?php echo($description); ?>" /></a></li><?php
			}
		}
		?>
	</ul>
</div>

<script>
	jQuery(window).on("load", function(){
    	jQuery('#slider_<?php echo $module_instance_id?>').slippry({
			slippryWrapper: '<?php echo(addslashes($config_slippryWrapper)); ?>',
			slideWrapper: '<?php echo(addslashes($config_slideWrapper)); ?>',
			slideCrop: '<?php echo(addslashes($config_slideCrop)); ?>',
			boxClass: '<?php echo(addslashes($config_boxClass)); ?>',
			elements: '<?php echo(addslashes($config_elements)); ?>',
			activeClass: '<?php echo(addslashes($config_activeClass)); ?>',
			fillerClass: '<?php echo(addslashes($config_fillerClass)); ?>',
			loadingClass: '<?php echo(addslashes($config_loadingClass)); ?>',
			adaptiveHeight: <?php echo($config_adaptiveHeight ? 'true' : 'false'); ?>,
			start: <?php echo($config_random ? "'random'" : ($config_start ? $config_start : 1)); ?>,
			loop: <?php echo($config_loop ? 'true' : 'false'); ?>,
			captionsSrc: '<?php echo(addslashes($config_captionsSrc)); ?>',
			captions: <?php echo($config_captions !== "off" ? "'" . $config_captions . "'" : false); ?>,
			captionsEl: '<?php echo(addslashes($config_captionsEl)); ?>',
			initSingle: <?php echo($config_initSingle ? 'true' : 'false'); ?>,
			responsive: <?php echo($config_responsive ? 'true' : 'false'); ?>,
			preload: '<?php echo($config_preload ? $config_preload : ""); ?>',
			pager: <?php echo($config_pager ? 'true' : 'false'); ?>,
			pagerClass: '<?php echo(addslashes($config_pagerClass)); ?>',
			controls: <?php echo($config_controls ? 'true' : 'false'); ?>,
			controlClass: '<?php echo(addslashes($config_controlClass)); ?>',
			prevClass: '<?php echo(addslashes($config_prevClass)); ?>',
			prevText: '<?php echo(addslashes($config_prevText)); ?>',
			nextClass: '<?php echo(addslashes($config_nextClass)); ?>',
			nextText: '<?php echo(addslashes($config_nextText)); ?>',
			hideOnEnd: <?php echo($config_hideOnEnd ? 'true' : 'false'); ?>,
			transition: <?php echo($config_transition && $config_transition !== "off" ? "'" . $config_transition . "'" : false); ?>,
			kenZoom: <?php echo($config_kenZoom ? $config_kenZoom : 0); ?>,
			slideMargin: <?php echo($config_slideMargin ? $config_slideMargin : 0); ?>,
			transClass: '<?php echo(addslashes($config_transClass)); ?>',
			speed: <?php echo($config_speed ? $config_speed : 0); ?>,
			easing: '<?php echo($config_easing ? $config_easing : ""); ?>',
			continuous: <?php echo($config_continuous ? 'true' : 'false'); ?>,
			useCSS: <?php echo($config_useCSS ? 'true' : 'false'); ?>,
			auto: <?php echo($config_auto ? 'true' : 'false'); ?>,
			autoDirection: '<?php echo($config_autoDirection ? $config_autoDirection : ""); ?>',
			autoHover: <?php echo($config_autoHover ? 'true' : 'false'); ?>,
			autoHoverDelay: <?php echo($config_autoHoverDelay ? $config_autoHoverDelay : 0); ?>,
			autoDelay: <?php echo($config_autoDelay ? $config_autoDelay : 0); ?>,
			pause: <?php echo($config_pause ? $config_pause : 0); ?>,
			onSliderLoad: function(index)
			{
				<?php
				// Only include this JS if there's going to be a lightbox, otherwise it can conflict with the gallery.
				if($lightbox)
				{
					?>
					jQuery("a.lightbox").colorbox({
						'rel'			: 'slider_<?php echo $module_instance_id?>',
						'transition'	: 'elastic',
						'current'		: '{current}/{total}',
						'scalePhotos' 	: true,
						'width'			: '<?php echo($lightbox_width); ?>',
						'height'		: '<?php echo($lightbox_height); ?>',
						'maxWidth' 		: '100%',
						'maxHeight'		: '100%'
					});
					<?php
				}
				?>
				return this;
			}
		});
	});
</script>