<?php

	$sliderCats = get_post_meta ( $post->ID, THEME_NAME."_slider_cat", true );
	$count = get_post_meta ( $post->ID, THEME_NAME."_slider_post_count", true );
	if(!$count) $count = 5;


		$args=array(
			'category__in' => $sliderCats,
			'ignore_sticky_posts'=>1,
			'posts_per_page' => $count,
			'orderby'=> "date",
			'order' => "DESC"
		);
	$my_query = new WP_Query($args);


?>
        <!-- Slider -->
        <div class="slideshow">
        	<?php if ( $my_query->have_posts() ) : ?>
	            <div class="nivoSlider">
					<?php  while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
						<?php $image = get_post_thumb($my_query->post->ID,640,350,THEME_NAME.'_homepage_image'); ?>
						<a href="<?php the_permalink();?>">
							<img src="<?php echo $image['src'];?>" alt="<?php the_title();?>" title="#htmlcaption<?php echo $post->ID;?>"/>
						</a>
					<?php endwhile;?>
	            </div>
				<?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
					<div id="htmlcaption<?php echo $post->ID;?>" class="nivo-html-caption">
						<h3><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
		            	<ul class="entry-meta">
		            	<li class="posted-date"><?php the_time("F d, Y");?></li>
		            	<?php if ( comments_open() ) { ?>
		            		<li class="posted-comments"><a href="<?php the_permalink();?>#comments"><?php comments_number(__("0 Comment", THEME_NAME),__("1 Comment", THEME_NAME),__("% Comments", THEME_NAME)); ?></a></li>
		            	<?php } ?>
		            	</ul>
					</div>
				<?php endwhile;?>


			<?php else: ?>
				<p><?php _e('No posts where found', THEME_NAME); ?></p>
			<?php endif; ?>

        </div>
        <div class="clear"></div>
