<?php global $gp;

// Get image IDs
$gp_image_ids = array_filter( explode( ',', get_post_meta( get_the_ID(), 'gallery_slider', true ) ) );	

if ( $gp_image_ids ) { ?>

	<div class="post-format-gallery-slider-content gp-slider featured-content <?php echo sanitize_html_class( $GLOBALS['gp_image_alignment'] ); ?>" style="width: <?php echo absint( $GLOBALS['gp_image_width'] ); ?>px;"> 
		 <ul class="slides">
			<?php foreach ( $gp_image_ids as $gp_image_id ) { ?>
				<li>
					<?php $image = aq_resize( wp_get_attachment_url( $gp_image_id ), $GLOBALS['gp_image_width'], $GLOBALS['gp_image_height'], $GLOBALS['gp_hard_crop'], false, true ); ?>
					<?php if ( $gp['retina'] == 'gp-retina' ) {
						$retina = aq_resize( wp_get_attachment_url( $gp_image_id ), $GLOBALS['gp_image_width'] * 2, $GLOBALS['gp_image_height'] * 2, $GLOBALS['gp_hard_crop'], true, true );
					} else {
						$retina = '';
					} ?>
					<img src="<?php echo esc_url( $image[0] ); ?>" data-rel="<?php echo esc_url( $retina ); ?>" width="<?php echo absint( $image[1] ); ?>" height="<?php echo absint( $image[2] ); ?>" alt="<?php if ( get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true) ) { echo get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true); } else { the_title_attribute(); } ?>" class="wp-post-image" />			
				</li>
			<?php } ?>
		</ul>
	 </div>

	<?php if ( ! is_admin() ) { ?>
	
		<script>
	
			<?php if ( is_singular( 'post' ) ) { ?>
	
				jQuery( window ).load( function() {
					'use strict';
					jQuery( '.post-<?php the_ID(); ?> .gp-slider' ).flexslider( { 
						animation: 'fade',
						slideshowSpeed: 9999999,
						animationSpeed: 600,
						directionNav: true,			
						controlNav: false,			
						pauseOnAction: true, 
						pauseOnHover: false,
						prevText: '',
						nextText: '',
						smoothHeight: true
					});
				});
	
			<?php } else { ?>

				jQuery( document ).ready( function( $ ) {
					'use strict';
					$( '.post-<?php the_ID(); ?> .gp-slider' ).flexslider( { 
						animation: 'fade',
						slideshowSpeed: 9999999,
						animationSpeed: 600,
						directionNav: true,			
						controlNav: false,			
						pauseOnAction: true, 
						pauseOnHover: false,
						prevText: '',
						nextText: ''
					});
				});
			
			<?php } ?>
		
		</script>

	<?php } ?>
	
<?php } else { ?>

	<div class="post-format-gallery-content featured-content">
		<?php the_content(); ?>
	</div>

<?php } ?>