<?php $home_gallery_count =  $smof_data['home_gallery_count'];?>
<section class="homeGallery">
<div class="homeTitle"><h2><i class="icon-doc"></i><?php _e('Latest Galleries','lioit') ?></h2></div>
<div class="homeGalleryContent">
	<?php query_posts(array('post_type' =>'gallery' , 'showposts' => $home_gallery_count)); ?>
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <?php $terms_l = get_the_terms ($post->id, 'gallery_sorting'); ?>
      <?php $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'features-thumb'); ?>
	<div class="smallGalleryitem">
          <?php
								$slide_sh = get_post_meta($post->ID, 'lioit_slideshow_gallery', true);
								?>
								<?php if ($slide_sh == true) { ?>
								
								
								<script type="text/javascript">
								jQuery(document).ready(function($) {
						
										//inner slideshow
									$('.postSlideshow-<?php the_ID(); ?>').cycle({
									timeout:0,
									speed: 'normal',
									pager:  '.slidePager-<?php the_ID(); ?>',
									next:'.slide_next-<?php the_ID(); ?>',
									prev:'.slide_prev-<?php the_ID(); ?>',
									before: resize_slideshow
									});
						
						function resize_slideshow(curr, next, opts, fwd){
								//get the height of the current slide
								var $ht = $(this).height();
								//set the container's height to that of the current slide
								$(this).parent().animate({
								height : $ht
										 });
						}
						$('.postSlideshow-<?php the_ID(); ?>').click(function() {
							$('.postSlideshow-<?php the_ID(); ?>').cycle('next');
						});
						
								});
							</script>
								<div class="postSlideshow postSlideshow-<?php the_ID(); ?>">
										<?php
										global $wpdb, $post;
										
										$meta = get_post_meta($post->ID, 'lioit_slideshow_gallery', false);
										if (!is_array($meta)) $meta = (array) $meta;
										if (!empty($meta)) {
										$meta = implode(',', $meta);
										$images = $wpdb->get_col("
										SELECT ID FROM $wpdb->posts
										WHERE post_type = 'attachment'
										AND ID in ($meta)
										ORDER BY menu_order ASC
										");
										foreach ($images as $att) {
										// get image's source based on size, can be 'thumbnail', 'medium', 'large', 'full' or registed post thumbnails sizes
										$src = wp_get_attachment_image_src($att, 'full');
										$src = $src[0];
										?>
								<img src="<?php echo $src; ?>" alt=""  >
									<?php  }
										} ?>
										
								</div> <!--End Slideshow-->
                             
								<?php } ?>
                                <div class="smallGalleryitemtitle">
      
                                  <h6><a href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title(); ?>" class="postlink"><?php the_title(); ?></a></h6>
                                  <aside><i class="icon-folder-open"></i><?php _e('in','lioit') ?> <?php $tax = get_the_term_list( $post->ID, 'gallery_sorting', '', ', ', '' ); echo $tax; ?></aside>
                                </div>
                </div>
        <!--End  Slideshow item-->
         <?php endwhile; ?>
      <?php endif; ?>
      </div><!--End homeGalleryContent-->
</section><!--End Home Gallery-->