<!--Begin Slider-->	
<?php if($theme_slider_cats) {
	
	global $gp_settings;
	
	// Score Type
	$score_type = $theme_slider_score_type;

	// Slide Order	
	if($theme_slider_orderby == "Custom Order") {
		$slider_orderby = "menu_order";	
		$slider_order = "ASC";
	} elseif($theme_slider_orderby == "Site Score") {	
		$gd_sort = "review";	
		$gd_order = "DESC";	
	} elseif($theme_slider_orderby == "User Score") {	
		$gd_sort = "rating";	
		$gd_order = "DESC";	
	} else { 
		$slider_orderby = "date";
		$slider_order = "DESC";
	}
	
	$args=array(
	'post_type' => array('post'),
	'order' => $slider_order,
	'orderby' => $slider_orderby,
	'gdsr_sort' => $gd_sort,
	'gdsr_order' => $gd_order,
	'posts_per_page' => $theme_slides,
	'tax_query' =>
	array('relation' => 'OR',
		array('taxonomy' => 'slide_categories', 'terms' => explode(',', $theme_slider_cats), 'field' => 'id'),
		array('taxonomy' => 'category', 'terms' => explode(',', $theme_slider_cats), 'field' => 'id'))			
	);
	
	query_posts($args); if (have_posts()) : $slide_counter = 0; ?>
	
		<!--Begin Slider Wrapper-->
		<div id="slider-wrapper">
							
			<div id="slider-nav">
				<div id="slide-prev"></div>
				<?php if($theme_slider_scroll == "0") { ?><div id="slide-move-outer"><div id="slide-move-inner"></div></div><?php } ?>
				<div id="slide-next"></div>
			</div>
					
			<!--Begin Slides-->		
			<div id="slider">
			
				<?php while (have_posts()) : the_post(); $slide_counter++; include('loop-data.php');
					
				?>
				
					<!--Begin Slide-->
					<div class="slide<?php if($slide_counter == 1) { ?> slide-large<?php } else { ?> slide-small<?php } ?>">
			
						<?php if($slide_counter == 1) { // Large Slide ?>
						
							<?php $image = vt_resize(get_post_thumbnail_id(), '', 9999, 9999, true); ?>

							<?php if(get_post_type() != "post" && (get_post_meta($post->ID, 'ghostpool_slide_url', true) OR get_post_meta($post->ID, 'ghostpool_slide_link_type', true) != "Page")) { ?>							
								<a href="<?php if(get_post_meta($post->ID, 'ghostpool_slide_link_type', true) == "Lightbox Video") { ?>file=<?php echo get_post_meta($post->ID, 'ghostpool_slide_url', true); } elseif(get_post_meta($post->ID, 'ghostpool_slide_link_type', true) == "Lightbox Image") { if(get_post_meta($post->ID, 'ghostpool_slide_url', true)) { echo get_post_meta($post->ID, 'ghostpool_slide_url', true); } else { echo $image[url]; }} else { if(get_post_meta($post->ID, 'ghostpool_slide_url', true)) { echo get_post_meta($post->ID, 'ghostpool_slide_url', true); } else { the_permalink(); }} ?>" title="<?php the_title(); ?>"<?php if(get_post_meta($post->ID, 'ghostpool_slide_link_type', true) != "Page") { ?> rel="prettyPhoto"<?php } ?>>								
							<?php } elseif(get_post_type() != "slide") { ?>							
								<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">							
							<?php } ?>
							
								<?php if(has_post_thumbnail()) { ?>
							
									<?php $image = vt_resize(get_post_thumbnail_id(), '', 350, 270, true); ?>
									<img src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" 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 { echo get_the_title(); } ?>" />
								
								<?php } ?>
								
								<div class="slide-caption<?php if(($gp_settings['post_type'] == "Review" OR get_post_type() == "slide") && ($score_type == "No Scores" OR ($gp_settings['gp_gdsr']->review <= 0 && $gp_settings['user_voting'] == "Users cannot vote"))) { ?> hidden<?php } ?>">
								
									<h2><?php the_title(); ?></h2>

									<!--Begin Scores-->
									<?php if(($gp_settings['post_type'] == "Review" OR get_post_type() == "slide") && $score_type != "No Scores") { ?>
									
										<div class="post-scores">
										
											<!--Begin Site Score-->	
											<?php if(defined('STARRATING_INSTALLED') && $score_type != "User Score" && $gp_settings['gp_gdsr']->review > 0) { ?>
												<div class="site-score"<?php echo $site_score_color; ?>>
													<?php echo $gp_settings['gp_gdsr']->review; ?>
												</div>
											<?php } ?>
											<!--End Site Score-->	
									
											<!--Begin User Score-->			
											<?php if(defined('STARRATING_INSTALLED') && $score_type != "Site Score" && $gp_settings['user_voting'] != "Users cannot vote") { ?>
												<div class="user-score"<?php echo $user_score_color; ?>>
													<?php echo $gp_settings['gp_gdsr']->rating; ?>
												</div>
											<?php } ?>
											<!--End User Score-->
										
										</div>
									
									<?php } ?>
									<!--End Scores-->

								</div>
							
							<?php if(get_post_meta($post->ID, 'ghostpool_slide_url', true) OR  get_post_meta($post->ID, 'ghostpool_slide_link_type', true) != "Page" OR get_post_type() != "slide") { ?></a><?php } ?>
							
						<?php } else { // Small Slides ?>			
						
							<?php if(has_post_thumbnail()) { ?>

								<?php $image = vt_resize(get_post_thumbnail_id(), '', 9999, 9999, true); ?>

								<?php if(get_post_type() != "post" && (get_post_meta($post->ID, 'ghostpool_slide_url', true) OR get_post_meta($post->ID, 'ghostpool_slide_link_type', true) != "Page")) { ?>
									<a href="<?php if(get_post_meta($post->ID, 'ghostpool_slide_link_type', true) == "Lightbox Video") { ?>file=<?php echo get_post_meta($post->ID, 'ghostpool_slide_url', true); } elseif(get_post_meta($post->ID, 'ghostpool_slide_link_type', true) == "Lightbox Image") { if(get_post_meta($post->ID, 'ghostpool_slide_url', true)) { echo get_post_meta($post->ID, 'ghostpool_slide_url', true); } else { echo $image[url]; }} else { if(get_post_meta($post->ID, 'ghostpool_slide_url', true)) { echo get_post_meta($post->ID, 'ghostpool_slide_url', true); } else { the_permalink(); }} ?>" title="<?php the_title(); ?>"<?php if(get_post_meta($post->ID, 'ghostpool_slide_link_type', true) != "Page") { ?> rel="prettyPhoto"<?php } ?>>									
								<?php } elseif(get_post_type() != "slide") { ?>							
									<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">								
								<?php } ?>
							
									<?php $image = vt_resize(get_post_thumbnail_id(), '', 160, 120, true); ?>
									<img src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" 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 { echo get_the_title(); } ?>" />
								
								<?php if(get_post_meta($post->ID, 'ghostpool_slide_url', true) OR  get_post_meta($post->ID, 'ghostpool_slide_link_type', true) != "Page" OR get_post_type() != "slide") { ?></a><?php } ?>
							
							<?php } ?>
																				
							<div class="slide-caption<?php if(($gp_settings['post_type'] == "Review" OR get_post_type() == "slide") && ($score_type == "No Scores" OR ($gp_settings['gp_gdsr']->review <= 0 && $gp_settings['user_voting'] == "Users cannot vote"))) { ?> hidden<?php } ?>">
								
								<?php $image = vt_resize(get_post_thumbnail_id(), '', 9999, 9999, true); ?>

								<?php if(get_post_type() != "post" && (get_post_meta($post->ID, 'ghostpool_slide_url', true) OR get_post_meta($post->ID, 'ghostpool_slide_link_type', true) != "Page")) { ?>
									<a href="<?php if(get_post_meta($post->ID, 'ghostpool_slide_link_type', true) == "Lightbox Video") { ?>file=<?php echo get_post_meta($post->ID, 'ghostpool_slide_url', true); } elseif(get_post_meta($post->ID, 'ghostpool_slide_link_type', true) == "Lightbox Image") { if(get_post_meta($post->ID, 'ghostpool_slide_url', true)) { echo get_post_meta($post->ID, 'ghostpool_slide_url', true); } else { echo $image[url]; }} else { if(get_post_meta($post->ID, 'ghostpool_slide_url', true)) { echo get_post_meta($post->ID, 'ghostpool_slide_url', true); } else { the_permalink(); }} ?>" title="<?php the_title(); ?>"<?php if(get_post_meta($post->ID, 'ghostpool_slide_link_type', true) != "Page") { ?> rel="prettyPhoto"<?php } ?>>									
								<?php } elseif(get_post_type() != "slide") { ?>							
									<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">								
								<?php } ?>
								
									<h2><?php the_title(); ?></h2>
								
								<?php if(get_post_meta($post->ID, 'ghostpool_slide_url', true) OR  get_post_meta($post->ID, 'ghostpool_slide_link_type', true) != "Page" OR get_post_type() != "slide") { ?></a><?php } ?>
								
								<!--Begin Scores-->
								<?php if(($gp_settings['post_type'] == "Review" OR get_post_type() == "slide") && $score_type != "No Scores") { ?>
								
									<div class="post-scores">
									
										<!--Begin Site Score-->	
										<?php if(defined('STARRATING_INSTALLED') && $score_type != "User Score" && $gp_settings['gp_gdsr']->review > 0) { ?>
											<div class="site-score"<?php echo $site_score_color; ?>>
												<?php echo $gp_settings['gp_gdsr']->review; ?>
											</div>
										<?php } ?>
										<!--End Site Score-->	
								
										<!--Begin User Score-->			
										<?php if(defined('STARRATING_INSTALLED') && $score_type != "Site Score" && $gp_settings['user_voting'] != "Users cannot vote") { ?>
											<div class="user-score"<?php echo $user_score_color; ?>>
												<?php echo $gp_settings['gp_gdsr']->rating; ?>
											</div>
										<?php } ?>
										<!--End User Score-->
									
									</div>
								
								<?php } ?>
								<!--End Scores-->
								
							</div>
						
						<?php } ?>
				
					</div>
					<!--End Slide-->
					
				<?php endwhile; ?>		
		
			</div>
			<!--End Slides-->
											
			<div id="slider-inner-bg">&nbsp;</div>
	
		</div>
		<!--End Slider Wrapper-->
	
	<?php endif; wp_reset_query(); ?>
	
	<script>
	jQuery(document).ready(function(){
		jQuery("#slider").carouFredSel({
			width: 950,
			height: 270,
			auto: <?php if($theme_slider_scroll == "1") { ?>false<?php } else { ?>true<?php } ?>,
			prev: "#slide-prev",
			next: "#slide-next",
			scroll: {
				duration: <?php echo $theme_slider_scroll_speed; ?>,
				pauseDuration: 9999,
				pauseOnHover: true
			}
		}).trigger("play");
		
		// Toggle Slider Controls
		jQuery("#slide-move-outer").toggle(
			function(){
				jQuery('#slider').trigger('pause'); 
				jQuery("#slide-move-inner").replaceWith('<div id="slide-move-inner" class="play"></div>');
			},
			function () {
				jQuery('#slider').trigger('play'); 
				jQuery("#slide-move-inner").replaceWith('<div id="slide-move-inner" class="pause"></div>');
			}
		);	
			
	});
	</script>

<?php } else { ?>

	<div id="slider-wrapper">
	
		<div class="error">
			<?php _e('Your can display both slides (custom post type) and posts in the slider. To do this first assign your slides to one or more <a href="../wp-admin/edit-tags.php?taxonomy=slide_categories&post_type=slide">slider categories</a> and your chosen posts to one or more <a href="../wp-admin/edit-tags.php?taxonomy=category">post categories</a>. Now go to <em><a href="../wp-admin/themes.php?page=theme-options.php#2">Appearance -> Theme Options -> Slider Settings</a></em> and in the <em>Slider Category IDs</em> text field add your slider category IDs and/or post category IDs.', 'gp_lang'); ?>
		</div>
	
	</div>						

<?php } ?>
<!--End Slider-->