<?php
/*
 *
 Template Name: Slideshow
 *
 * This template is used to display images in a slideshow.
 *
 */ 
 get_header(); ?>

<!-- #content -->
<div id="content" class="slideshow-page">
	
	<!-- .row -->
	<div class="row slideshow">

        <div <?php post_class('content'); ?> id="page-<?php the_ID(); ?>">
    
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            
            <div id="slideshow">
            
            	<div class="flexslider loading" data-speed="<?php echo of_get_option('transition_interval'); ?>">
            	
            		<ul class="slides">
            		
            			<?php $data = array(
    				    	'post_parent'		=> $id,
    				    	'post_type' 		=> 'attachment',
    				    	'post_mime_type' 	=> 'image',
    				    	'order'         	=> 'ASC',
    				    	'orderby'	 		=> 'menu_order',
    				        'numberposts' 		=> -1
            			); ?>
            			
            			<?php 
            			$images = get_posts($data);
            			foreach( $images as $image ) { 
         					$imageurl = wp_get_attachment_url($image->ID);
            				echo '<li><img src="'.$imageurl.'" /></li>' . "\n";
            			} ?>

            		</ul>
            		
            	</div>
            	
            </div>
            
            <div class="article">
            	<h1><?php the_title(); ?></h1>
	            <?php the_content(__("Read More", 'organicthemes')); ?>
	            <div class="clear"></div>
	            <p><?php edit_post_link(__("(Edit)", 'organicthemes'), '', ''); ?></p> 
	        </div>
            
            <?php endwhile; else: ?>
            
            <p><?php _e("Sorry, no posts matched your criteria.", 'organicthemes'); ?></p>
			
			<?php endif; ?>
            
        </div>
        
    <!-- END .row -->
    </div>

<!-- END #content -->
</div>

<?php get_footer(); ?>