<?php 
global $hermes_options, $slideshow_autoplay, $slideshow_speed;

if (is_home()) {
	$slideshow_autoplay = $hermes_options['hermes_gallery_autoplay'];
	$slideshow_speed = $hermes_options['hermes_gallery_autoplay_speed'];
}

$args = array(
	'order'          => 'ASC',
	'orderby'          => 'menu_order',
	'post_type'      => 'attachment',
	'post_parent'    => $hermes_options['hermes_gallery_page'],
	'post_mime_type' => 'image',
	'post_status'    => null,
	'numberposts'    => $hermes_options['hermes_gallery_page_num']
);

$attachments = get_posts($args);

$i = 0;
if (count($attachments) > 0) { ?>

<div id="hermes-gallery" class="flexslider">
	
	<div class="hermes-gallery-wrapper">
		<span class="gallery-shadow">&nbsp;</span>
	
		<ul class="hermes-slides">
	
			<?php
			foreach ($attachments as $attachment) { 
			$large_image_url = wp_get_attachment_image_src( $attachment->ID, 'thumb-hermes-slideshow');
			?>
			<li class="hermes-gallery-slide">
			
				<img src="<?php echo $large_image_url[0]; ?>" width="1400" height="400" alt="" />
				
				<?php if (!$hermes_options['hermes_booking_page']) { ?>
				
				<div class="wrapper-booking">
					<div class="wrapper wrapper-form">
						<p class="slide-title"><?php echo $attachment->post_title; ?></p>
					</div><!-- .wrapper .wrapper-form -->
				</div><!-- .wrapper-booking -->
				
				<?php } ?>
	
			</li><!-- end .hermes-gallery-slide -->
			<?php 
			} // foreach
		?>
		</ul>
		<div class="cleaner">&nbsp;</div>
	
	</div><!-- end .hermes-gallery-wrapper -->

	<?php if ($hermes_options['hermes_booking_page']) {
		get_template_part('form-booking', 'home'); // if booking page is selected in Theme Options
	} ?>

</div><!-- end #hermes-gallery -->

<script type="text/javascript">
jQuery(document).ready(function() {
	
	jQuery("#hermes-gallery").flexslider({
        selector: ".hermes-slides > .hermes-gallery-slide",
		animationLoop: true,
        initDelay: 1000,
		smoothHeight: false,
		<?php if ($slideshow_autoplay == 1) { ?>
		slideshow: true,
		slideshowSpeed: <?php echo $slideshow_speed; ?>,
		<?php } else { ?>
		slideshow: false,
		<?php } ?>
		pauseOnAction: true,
        controlNav: false,
		directionNav: true,
		useCSS: true,
		touch: false,
        animationSpeed: 500
    });	 

});
</script>
<?php 
} // if there are attachments
?>