<!--Begin Slider Wrapper-->
<div class="slider-wrapper">

	<!--Begin Slider-->
	<div id="slider">
	
		<?php $args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $post->ID, 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC'); 
				
		$attachments = get_children($args);
				
		foreach ($attachments as $attachment) { 
		
		if(get_post_meta($attachment->ID, '_ghostpool_slide_image_width', true)) { $slide_image_width = get_post_meta($attachment->ID, '_ghostpool_slide_image_width', true); } else { $slide_image_width = "578"; }
		
		if(get_post_meta($attachment->ID, '_ghostpool_slide_image_height', true)) { $slide_image_height = get_post_meta($attachment->ID, '_ghostpool_slide_image_height', true); } else { $slide_image_height = "0"; }
				
		?>
	
			<!--Begin Slide-->
			<div class="slide" style="width: <?php echo $slide_image_width; ?>px;">

				<?php if($attachment->post_excerpt) { ?>
					<div class="slide-caption">
						<?php echo($attachment->post_excerpt); ?>
					</div>
				<?php } ?>
				
				<?php if(get_post_meta($attachment->ID, '_ghostpool_slide_video', true) OR get_post_meta($attachment->ID, '_ghostpool_webm_mp4_slide_video', true) OR get_post_meta($attachment->ID, '_ghostpool_ogg_slide_video', true)) { ?>
	
					<div class="slide-video" style="width: <?php echo $slide_image_width; ?>px; height: <?php echo $slide_image_height; ?>px;">
					
						<?php
	
						// Detect MSIE
						$MSIE = (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') !== FALSE);
					
						// Detect Vimeo
						$vimeo = strpos(get_post_meta($attachment->ID, '_ghostpool_slide_video', true),"vimeo.com");
		
						if($vimeo == true) { // Vimeo
								
						// Vimeo Clip ID
						if(preg_match('/www.vimeo/', get_post_meta($attachment->ID, '_ghostpool_slide_video', true))) {							
							$vimeoid = trim(get_post_meta($attachment->ID, '_ghostpool_slide_video', true),'http://www.vimeo.com/');
						} else {							
							$vimeoid = trim(get_post_meta($attachment->ID, '_ghostpool_slide_video', true),'http://vimeo.com/');
						}
															
						?>
							
							<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="<?php echo $slide_image_width; ?>" height="<?php echo $slide_image_height; ?>">
								<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vimeoid; ?>&amp;autoplay=0" />
								<param name="wmode" value="transparent" />
								<param name="allowfullscreen" value="true" />
								<param name="allowscriptacess" value="always" />
								<!--[if !IE]>-->                
								<object type="application/x-shockwave-flash" data="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vimeoid; ?>&amp;autoplay=0" width="<?php echo $slide_image_width; ?>" height="<?php echo $slide_image_height; ?>">
								<param name="wmode" value="transparent" />
								<param name="allowfullscreen" value="true" />
								<param name="allowscriptacess" value="always" />				
								<!--<![endif]-->
									<iframe src="http://player.vimeo.com/video/<?php echo $vimeoid; ?>?byline=0&amp;portrait=0&amp;autoplay=0" width="<?php echo $slide_image_width; ?>" height="<?php echo $slide_image_height; ?>" frameborder="0"></iframe>
								<!--[if !IE]>-->
								</object>
								<!--<![endif]-->
							</object>
						
						<?php } else { // JW Player ?>
						
							<?php if((strpos(get_post_meta($attachment->ID, '_ghostpool_slide_video', true),"youtube.com") OR strpos(get_post_meta($attachment->ID, '_ghostpool_slide_video', true),"youtu.be")) && get_post_meta($post->ID, 'ghostpool_slide_video_priority', true) == "Flash") { ?>
							
								<div id="video-<?php echo $attachment->ID; ?>"></div>

							<?php } else { ?>
							
								<video id="video-<?php echo $attachment->ID; ?>" width="<?php echo $slide_image_width; ?>" height="<?php echo $slide_image_height; ?>" controls="controls" preload>
								
									<?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false OR strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false) { ?>
										<source src="<?php echo get_post_meta($attachment->ID, '_ghostpool_webm_mp4_slide_video', true); ?>" type="video/mp4" />
										<source src="<?php echo get_post_meta($attachment->ID, '_ghostpool_webm_mp4_slide_video', true); ?>" type="video/webm" />
									<?php } else { ?>	
										<source src="<?php echo get_post_meta($attachment->ID, '_ghostpool_ogg_slide_video', true); ?>" type="video/ogg" />
									<?php } ?>
									
								</video>
							
							<?php } ?>
							
							<script>
								jwplayer("video-<?php echo $attachment->ID; ?>").setup({
									<?php if($MSIE OR get_post_meta($post->ID, 'ghostpool_slide_video_priority', true) == "Flash") { ?>file: "<?php echo get_post_meta($attachment->ID, '_ghostpool_slide_video', true); ?>",<?php } ?>
									image: "<?php if($theme_timthumb == '0') { ?><?php echo get_template_directory_uri() ?>/lib/scripts/timthumb.php?src=<?php } ?><?php echo wp_get_attachment_url($attachment->ID); ?><?php if($theme_timthumb == '0') { ?>&h=<?php echo $slide_image_height; ?>&w=<?php echo $slide_image_width; ?>&zc=1<?php } ?>",
									icons: "true",
									autostart: "false",
									controlbar: "<?php if(get_post_meta($post->ID, 'ghostpool_slide_video_controls', true) == 'Over') { ?>over<?php } elseif(get_post_meta($post->ID, 'ghostpool_slide_video_controls', true) == 'Bottom') { ?>bottom<?php } else { ?>none<?php } ?>",
									screencolor: "black",	
									height: <?php echo $slide_image_height; ?>,
									width: <?php echo $slide_image_width; ?>,
									skin: "<?php echo get_template_directory_uri(); ?>/lib/scripts/mediaplayer/fs39/fs39.xml",
									flashplayer: "<?php echo get_template_directory_uri(); ?>/lib/scripts/mediaplayer/player.swf"									
								});
							</script>
						
						<?php } ?>

					</div>

				<?php } else { ?>
							
					<img src="<?php if($theme_timthumb == "0") { ?><?php echo get_template_directory_uri(); ?>/lib/scripts/timthumb.php?src=<?php } ?><?php echo wp_get_attachment_url($attachment->ID); ?><?php if($theme_timthumb == "0") { ?>&amp;h=<?php echo $slide_image_height; ?>&amp;w=<?php echo $slide_image_width; ?>&amp;zc=1&amp;a=c<?php } ?>" style="width: <?php echo $slide_image_width; ?>px;" alt="" />
				
				<?php } ?>			

			</div>
			<!--End Slide-->        

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

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

	<!--Begin Slider Nav-->	
	<div id="slider-nav">

		<?php foreach ($attachments as $attachment) { ?>
			
			<div class="slider-button"></div>
			
		<?php } ?>
		
	</div>
	<!--End Slider Nav-->
	
</div>

<div class="clear"></div>
<!--End Slider Wrapper-->
			
<script>
jQuery(window).load(function() {
	
	jQuery("#slider") 
	.cycle({ 
		fx: "fade",
		timeout: 0,
		speed: 400,
		cleartype: true,
		cleartypeNoBg: true,
		pager: "#slider-nav",
		pagerAnchorBuilder: function(idx, slide) {return "#slider-nav .slider-button:eq(" + idx + ")";},
		before: onBefore
	});

	// Dynamic Height for Slider
	function onBefore(curr, next, opts, fwd) {
		var index = opts.currSlide;
		var jQueryht = jQuery(this).height();
		jQuery(this).parent().animate({height: jQueryht});
	}

});
</script>