<?php 

global $gp_settings;
  
// Video URL
$url = $post->post_content;

// Video Type	
$vimeo = strpos($url,"vimeo.com");
$yt1 = strpos($url,"youtube.com");
$yt2 = strpos($url,"youtu.be");


if ( ($vimeo) OR ($yt1) OR ($yt2) ) {

?>

	<div class="video">
	
		<?php if($vimeo) { // Vimeo
		
		// Vimeo Clip ID
		if(preg_match('/www.vimeo/', get_post_meta($post->ID, 'ghostpool_video', true))) {							
			$vimeoid = trim(get_post_meta($post->ID, 'ghostpool_video', true),'http://www.vimeo.com/');
		} else {							
			$vimeoid = trim(get_post_meta($post->ID, 'ghostpool_video', true),'http://vimeo.com/');
		}
		
		?>

			<iframe src="http://player.vimeo.com/video/<?php echo $vimeoid; ?>?byline=0&amp;portrait=0&amp;autoplay=<?php if(get_post_meta($post->ID, 'ghostpool_autostart_video', true)) { ?>1<?php } else { ?>0<?php } ?>" width="<?php echo get_post_meta($post->ID, 'ghostpool_video_width', true); ?>" height="<?php echo get_post_meta($post->ID, 'ghostpool_video_height', true); ?>" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
		
		<?php } else { // JW Player ?>
	
			<?php if(($gp_settings['iPhone'] OR $gp_settings['iPad']) && (!$yt1 && !$yt2)) { ?>
			
				<video id="video-<?php echo $the_ID; ?>" controls="controls" width="<?php echo get_post_meta($post->ID, 'ghostpool_video_width', true); ?>" height="<?php echo get_post_meta($post->ID, 'ghostpool_video_height', true); ?>" poster="<?php $image = vt_resize('', $image, get_post_meta($post->ID, 'ghostpool_video_width', true), get_post_meta($post->ID, 'ghostpool_video_height', true), true); echo $image[url]; ?>">
					<source src="<?php echo $url; ?>" type="video/mp4" />
					<source src="<?php echo $url; ?>" type="video/webm" />
					<source src="<?php echo $html5_1; ?>" type="video/mp4" />
					<source src="<?php echo $html5_1; ?>" type="video/webm" />
					<source src="<?php echo $html5_2; ?>" type="video/mp4" />
				</video>
			
			<?php } else { ?>	
						
				<div id="video-<?php the_ID(); ?>"></div>
				
			<?php } ?>

			<script>
				jwplayer("video-<?php the_ID(); ?>").setup({
					<?php if(has_post_thumbnail()) { $image = vt_resize(get_post_thumbnail_id(), '', get_post_meta($post->ID, 'ghostpool_video_width', true), get_post_meta($post->ID, 'ghostpool_video_height', true)); ?>image: "<?php echo $image[url]; ?>",<?php } ?>
					icons: "true",
					autostart: "<?php if(get_post_meta($post->ID, 'ghostpool_autostart_video', true)) { ?>true<?php } else { ?>false<?php } ?>",
					stretching: "fill",
					controlbar: "<?php if(get_post_meta($post->ID, 'ghostpool_video_controls', true) == 'Over') { ?>over<?php } elseif(get_post_meta($post->ID, 'ghostpool_video_controls', true) == 'Bottom') { ?>bottom<?php } else { ?>none<?php } ?>",
					skin: "<?php echo get_template_directory_uri() ; ?>/lib/scripts/mediaplayer/fs39/fs39.xml",
					height: <?php echo get_post_meta($post->ID, 'ghostpool_video_height', true); ?>,
					width: <?php echo get_post_meta($post->ID, 'ghostpool_video_width', true); ?>,
					wmode: "transparent",
					screencolor: "000000",
					modes:
						[
						<?php if($gp_settings['MSIE'] OR get_post_meta($post->ID, 'ghostpool_video_priority', true) == "Flash") { ?>
							{type: "flash", src: "<?php echo get_template_directory_uri(); ?>/lib/scripts/mediaplayer/player.swf", config: {file: "<?php echo $url; ?>"}},					
							{type: "html5", config: {file: "<?php echo $url; ?>"<?php if(($gp_settings['iPhone'] OR $gp_settings['iPad']) && ($yt1 OR $yt2)) {} else { ?>, file: "<?php echo $html5_1; ?>", file: "<?php echo $html5_2; ?>"<?php } ?>}}
						<?php } else { ?>
							{type: "html5", config: {file: "<?php echo $url; ?>"<?php if(($gp_settings['iPhone'] OR $gp_settings['iPad']) && ($yt1 OR $yt2)) {} else { ?>, file: "<?php echo $html5_1; ?>", file: "<?php echo $html5_2; ?>"<?php } ?>}},	
							{type: "flash", src: "<?php echo get_template_directory_uri(); ?>/lib/scripts/mediaplayer/player.swf", config: {file: "<?php echo get_template_directory_uri(); ?>/lib/scripts/mediaplayer/player.swf"}}
						<?php } ?>
						],
					plugins: {}
				});
			</script>
	
		<?php } ?>
		
	</div>	

<?php } ?>