<?php
	//grab multiple values for same key
	$videos = get_post_meta($post->ID, "video", false);
	$iphones = get_post_meta($post->ID, "iphone", false);
	$videothumbs = get_post_meta($post->ID, "video-thumb", false);

	//check sidebar and set appropriate dimensions
	if (get_option('gpp_sidebar') =='true' || !get_option('gpp_sidebar')) {
		$videowidth = 590; $videoheight = 352;
	}else{
		$videowidth = 950; $videoheight = 554;
	}
	
	if ($videos!="") { // if video custom field exists
	for ( $video = 0; $video < count($videos); $video++) {
?>

<div id="flashcontent-<?php the_ID(); ?>-<?php echo $video; ?>">
	<?php
		if (get_option('gpp_iphone') =='false')
		{
		echo '<div class=\"box\"><p>Please install the free <a href=\"http://www.adobe.com/products/flashplayer/\">Adobe Flash Player</a> to view this content.</p></div>';
		}
	?>
</div>

<script type="text/javascript">
	var flashvars = {};
	flashvars.imagePath = "<?php echo $videothumbs[$video]; ?>";
	flashvars.videoPath = "<?php echo $videos[$video]; ?>";
	flashvars.autoStart = "false";
	flashvars.autoHide = "false";
	flashvars.autoHideTime = "5";
	flashvars.hideLogo = "true";
	flashvars.volAudio = "60";
	flashvars.newWidth = "<?php echo $videowidth; ?>";
	flashvars.newHeight = "<?php echo $videoheight; ?>";
	flashvars.disableMiddleButton = "false";
	flashvars.playSounds = "true";
	flashvars.soundBarColor = "0x0066FF";
	flashvars.barColor = "0x0066FF";
	flashvars.barShadowColor = "0x91BBFB";
	flashvars.subbarColor = "0xffffff";
	
	var params = {};
	params.wmode = "transparent";
	params.allowFullScreen = "true";

	var attributes = {};
	
	swfobject.embedSWF("<?php bloginfo('template_directory'); ?>/apps/flash/flvPlayer.swf", "flashcontent-<?php the_ID(); ?>-<?php echo $video; ?>", "<?php echo $videowidth; ?>", "<?php echo $videoheight; ?>", "9", "<?php bloginfo('template_directory'); ?>/apps/flash/expressInstall.swf", flashvars, params, attributes);
			
</script>

		<?php if (get_option('gpp_iphone') =='true' && ($iphones!="")) {
		?>
		
		<script type="text/javascript" language="javascript">
<!--
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)))
{
     document.getElementById("flashcontent-<?php the_ID(); ?>-<?php echo $video; ?>").innerHTML = "<div class=\"play\"><a href=\"<?php echo $iphones[$video]; ?>\"><img src=\"<?php echo $videothumbs[$video]; ?>\" /><span></span></a></div>";
}
-->
	</script>
	
	<?php } ?>

<hr/>
<div class="clear"></div>
<?php } } ?>