<?php
	$pagetitle = "Videos";
	$pagetype = "videocats";
	$pageid = $_GET["cat"];
	include("header.phtml.en");
?>
	<body>
<?php
	include("menu.phtml.en");
	if (isset($_POST['go'])) {
		echo '<script>window.location.hash = "'.$_POST["page"].'"</script>';
	}
	$vids_error = $sqlerrormsg;
	$req = mysqli_query($base,'SELECT * FROM videocats where id="'.$_GET["cat"].'"') or die($vids_error);
	$local_videocat = mysqli_fetch_array($req);
	$req = mysqli_query($base,'SELECT * FROM videomakers where id="'.$local_videocat["author"].'"') or die($vids_error);
	$local_videomaker = mysqli_fetch_array($req);
	echo("<div id=\"contenu\">\n");
	echo("<h2>");
	if ($local_videocat["id"] != $local_videocat["author"]) lien($local_videocat["author"], $local_videomaker["title_en"]); else echo $local_videomaker["title_en"];
	echo("</h2>\n");
	echo("<p>".$local_videocat["desc_en"]."</p>\n");
	echo("<h3>".$local_videocat["title_en"]."</h3>\n");
	$req = mysqli_query($base,'SELECT * FROM videos where cat="'.$_GET["cat"].'" ORDER BY rank asc') or die($vids_error);
	$videos = mysqli_fetch_array($req);
?>
	<div id="video">
		<video controls>
			<source src="videos/<?php echo $videos["id"]?>.mp4" type="video/mp4">
			<source src="videos/<?php echo $videos["id"]?>.webm" type="video/webm">
			<div id="videofallback">
				<div id="ytapiplayer">You need Flash Player 9+ to view this video.</div><script>initFlashVid('http://www.youtube.com/watch?v=<?php echo $videos["youtube"]?>');</script> 
			</div>
		</video>
	</div>
	<div id="playlist">
		<p>Select a video:
		<ul>
		<?php
		$subpages = array();
		$cur = 0;
		mysqli_data_seek($req,0);
		while ($videos = mysqli_fetch_array($req))
		{
			array_push($subpages, $videos['id']);
			?>
			<li><a href="#<?php echo $videos['id']?>"><?php echo $videos['menu_en']?></a>
				<div class="description">
					<p class="intitule"><a class="youtube" title="Watch on YouTube" href="http://www.youtube.com/watch?v=<?php echo $videos['youtube']?>" target="_blank"></a><?php echo $videos['title_en']?>
					<p class="date"><?php echo ucfirst(strftime( "%B %d %Y" , strtotime( $videos['date'] ) ))?>
					<p class="credits">Music by <?php echo $videos['composer']?><br>
					<?php
					if ($videos['arranger'] != "") echo "Arrangement by ".$videos['arranger']."<br>\n";
					if ($videos['editing'] != "") echo "Video editing by ".$videos['editing'];
					echo $videos['desc_en']."\n";
					if ($videos['tab']) echo("<p>".$local_videomaker["tabs_msg_en"]."</p>\n");
					?>
				</div>
		<?php
			$cur++;
		}
		?>
		</ul>
		<p><a id="toflash" href="javascript:toflash()">Flash version</a> <a id="tohtml" href="javascript:tohtml()">HTML version</a>
	</div>
	<div id="comments" style="display: none;">
		<?php
			echo("<h4>Comment on this video</h4>");
			$page = "vid_";
			include("comments.phtml.en");
		?>
	</div>
	<?php if ($local_videocat["id"] == "duos" && $local_videocat["menu_en"] == "") { ?>
		<h3>Audio extracts</h3>
		<p>Some audio recordings, by Robinhood and Jumpman:
		<div class="audio1">
			<p><audio controls>
				<source src="musics/epona.m4a" type="audio/mp4">
				<source src="musics/epona.ogg" type="audio/ogg">
			<object type="application/x-shockwave-flash" data="dewplayer.swf?mp3=musics/epona.mp3" width="200" height="20">
			<param name="movie" value="dewplayer.swf?mp3=epona.mp3" />
			</object>
			</audio><br>
			Zelda — Epona’s Song</p>
		</div>
		<div class="audio2">
			<p><audio controls>
				<source src="musics/cocorico.m4a" type="audio/mp4">
				<source src="musics/cocorico.ogg" type="audio/ogg">
				<object type="application/x-shockwave-flash" data="dewplayer.swf?mp3=musics/cocorico.mp3" width="200" height="20">
			<param name="movie" value="dewplayer.swf?mp3=cocorico.mp3" />
			</object>
			</audio><br>Zelda — Kakariko Village</p>
		</div>
	<?php } ?>
</div>
<script src="vpl.js"></script>
<script>setTimeout("loadPage()",0)</script>
<script>
	var videoElt = document.getElementsByTagName("video")[0];
	if((typeof videoElt.play) == "function")
	{
	 piwikTracker.setCustomVariable(1, "VideoType", videoElt.currentSrc.slice(-4), "visit")
	}
	else
	{
	 piwikTracker.setCustomVariable(1, "VideoType", "flash", "visit")
	}
</script>
		<?php //include("stats.php");
		mysqli_close($base);?>
	</body>
</html>