	<?php

	error_reporting(E_ALL ^ E_NOTICE);
	//ini_set('display_errors',1);
	//ini_set('display_startup_errors',1);
	//error_reporting(-1);


	if( file_exists('install.php') )
	{
		header("Location: install.php");
		exit;
	}

	$game = $_GET['p'];

	if( !file_exists( $game.'/data.xml' ) )
	{
		if( $game == "credits" )
		{
			echo '<!DOCTYPE html>
	<html>
		<head>
			<meta charset="utf-8">
			<meta name="viewport" content="width=device-width, initial-scale=1">
			
			<title>Thanks!</title>
			<link href="https://cdnjs.cloudflare.com/ajax/libs/uikit/1.2.0/css/uikit.gradient.min.css" rel="stylesheet" type="text/css">
			<link href="style.css" rel="stylesheet" type="text/css">
		</head>

		<body>
			<div class="uk-container uk-container-center">
				<div class="uk-grid">
				</div>
			</div>
			<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
			<script type="text/javascript">
				$(function() {
					$(".uk-grid").load("credits.php");
				});
			</script>
		</body>
	</html>';
			exit;		
		}
		else if( is_dir($game ) && $game != "images" && $game != "trailers" && $game != "_template" )
		{
			echo '<!DOCTYPE html>
	<html>
		<head>
			<meta charset="utf-8">
			<meta name="viewport" content="width=device-width, initial-scale=1">
			
			<title>Instructions</title>
			<link href="https://cdnjs.cloudflare.com/ajax/libs/uikit/1.2.0/css/uikit.gradient.min.css" rel="stylesheet" type="text/css">
			<link href="style.css" rel="stylesheet" type="text/css">
		</head>

		<body>
			<div class="uk-container uk-container-center">
				<div class="uk-grid">
				</div>
			</div>
			<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
			<script type="text/javascript">
				$(function() {
					$(".uk-grid").load("create.php?s=installation");

					setInterval(function() {
						$(".uk-grid").load("create.php?s=installation");
					}, 5000);
				});
			</script>
		</body>
	</html>';

			// Todo: These steps will fail if safemode is turned on
			if( !is_dir($game.'/images') ) {
				mkdir($game.'/images');
			}
			if( !is_dir($game.'/trailers') ) {
				mkdir($game.'/trailers');
			}
			if( !file_exists($game.'/_data.xml') ) {
				copy('_template/_data.xml',$game.'/_data.xml');
			}

			exit;
		}
		else
		{
			header("Location: index.php");
			exit;
		}
	}

	$press_request = TRUE;
	$monetize = 0;
	$xml = simplexml_load_file($game."/data.xml");

	foreach( $xml->children() as $child )
	{
		switch( $child->getName() )
		{
			case("title"):
				define("GAME_TITLE", $child);
				break;	
			case("release-date"):
				define("GAME_DATE", $child);
				break;
			case("website"):
				define("GAME_WEBSITE", $child);
				break;
			case("platforms"):
				$platforms = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$platforms[$i][$subchild->getName()] = $subchild;
					$i++;
				}
				break;
			case("prices"):
				$prices = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$prices[$i][$subchild->getName()] = $subchild;
					$i++;
				}
				break;
			case("description"):
				define("GAME_DESCRIPTION", $child);
				break;
			case("history"):
				define("GAME_HISTORY", $child);
				break;
			case("histories"):
				$histories = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$histories[$i][$subchild->getName()] = $subchild;
					$i++;
				}
				break;
			case("features"):
				$features = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$features[$i] = $subchild;
					$i++;
				}
				break;	
			case("trailers"):
				$trailers = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$trailers[$i][$subchild->getName()] = $subchild;
					$i++;
				}
				break;					
			case("awards"):
				$awards = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$awards[$i][$subchild->getName()] = $subchild;
					$i++;
				}
				break;					
			case("quotes"):
				$quotes = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$quotes[$i][$subchild->getName()] = $subchild;
					$i++;
				}
				break;					
			case("press-can-request-copy"):
				if( strtolower($child) == "false" ) $press_request = FALSE;
				else $press_request = TRUE;
				break;
			case("monetization-permission"):
				if( strtolower($child) == "false" ) $monetize = 1;
				else if( strtolower($child) == "ask") $monetize = 2;
				else if( strtolower($child) == "non-commercial") $monetize = 3;
				else if( strtolower($child) == "monetize") $monetize = 4;
				break;
			case("additionals"):
				$additionals = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$additionals[$i][$subchild->getName()] = $subchild;
					$i++;
				}
				break;					
			case("credits"):
				$credits = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$credits[$i][$subchild->getName()] = $subchild;
					$i++;
				}
				break;					
			case("promoter"):
				$promoterawards = array();
				$promoterquotes = array();

				$promotercode = ($child->children());
				$promotercode = $promotercode->product;
				
				$promoterxml = simplexml_load_file('http://promoterapp.com/dopresskit/'.$promotercode);
				
				foreach( $promoterxml->children() as $promoterchild )
				{
					switch( $promoterchild->children()->getName() )
					{
						case("review"):
							$i = 0;
							foreach( $promoterchild->children() as $promotersubchild )
							{
								$promoterquotes[$i][$promotersubchild->getName()] = $promotersubchild;
								$i++;
							}					
							break;
						case("award"):
							$i = 0;
							foreach( $promoterchild->children() as $promotersubchild )
							{
								$promoterawards[$i][$promotersubchild->getName()] = $promotersubchild;
								$i++;
							}					
							break;							
					}
				}
				
				break;
		}
	}

	$xml = simplexml_load_file("data.xml");

	foreach( $xml->children() as $child )
	{
		switch( $child->getName() )
		{
			case("title"):
				define("COMPANY_TITLE", $child);
				break;	
			case("based-in"):
				define("COMPANY_BASED", $child);
				break;
			case("press-contact"):
				define("COMPANY_CONTACT", $child);
				break;
			case("description"):
				define("COMPANY_DESCRIPTION", $child);
				break;
			case("analytics"):
				define("ANALYTICS", $child);
				break;
			case("contacts"):
				$contacts = array();
				$i = 0;
				foreach( $child->children() as $subchild )
				{
					$contacts[$i][$subchild->getName()] = $subchild;
					$i++;
				}
				break;					
		}
	}

	function parseLink($uri)
	{
		$parsed = trim($uri);
		if( strpos($parsed, "http://") === 0 )
			$parsed = substr($parsed, 7);
		if (strpos($parsed, "https://") === 0 )
			$parsed = substr($parsed, 8);
		if( strpos($parsed, "www.") === 0 )
			$parsed = substr($parsed, 4);
		if( strrpos($parsed, "/") == strlen($parsed) - 1)
			$parsed = substr($parsed, 0, strlen($parsed) - 1);
		if( substr($parsed,-1,1) == "/" )
			$parsed = substr($parsed, 0, strlen($parsed) - 1);
		
		return $parsed;
	}

	echo '<!DOCTYPE html>
	<html>
		<head>
			<meta charset="utf-8">
			<meta name="viewport" content="width=device-width, initial-scale=1">
			
			<title>'. COMPANY_TITLE .'</title>
			<link href="https://cdnjs.cloudflare.com/ajax/libs/uikit/1.2.0/css/uikit.gradient.min.css" rel="stylesheet" type="text/css">
			<link href="style.css" rel="stylesheet" type="text/css">
		</head>

		<body>
			<div class="uk-container uk-container-center">
				<div class="uk-grid">
					<div id="navigation" class="uk-width-medium-1-4">
						<h1 class="nav-header">'. COMPANY_TITLE .'</h1>
						<a class="nav-header" href="index.php" target="_self">press kit</a></strong>

						<ul class="uk-nav uk-nav-side">
							<li><a href="#factsheet">Factsheet</a></li>
							<li><a href="#description">Description</a></li>
							<li><a href="#history">History</a></li>
							<li><a href="#projects">Projects</a></li>
							<li><a href="#trailers">Videos</a></li>
							<li><a href="#images">Images</a></li>
							<li><a href="#logo">Logo and Icon</a></li>';
	if( $promoterawards && $awards && (count($promoterawards) + count($awards) > 0) ) echo('<li><a href="#awards">Awards & Recognition</a></li>');
	if( $promoterawards && $quotes && (count($promoterquotes) + count($quotes) > 0) ) echo('<li><a href="#quotes">Selected Articles</a></li>');
	if( $press_request == TRUE) { echo '<li><a href="#preview">Request Press Copy</a></li>'; }
	if( $monetize >= 1) { echo '<li><a href="#monetize">Monetization Permission</a></li>'; }
	echo '						<li><a href="#links">Additional Links</a></li>
							<li><a href="#about">About '. COMPANY_TITLE .'</a></li>
							<li><a href="#credits">Team</a></li>
							<li><a href="#contact">Contact</a></li>
						</ul>
					</div>
					<div id="content" class="uk-width-medium-3-4">';

	if( file_exists($game."/images/header.png") ) {
		echo '<img src="'.$game.'/images/header.png" class="header">';
	}

	echo '					<div class="uk-grid">
							<div class="uk-width-medium-2-6">
								<h2 id="factsheet">Factsheet</h2>
								<p>
									<strong>Developer:</strong><br/>
									<a href="index.php">'. COMPANY_TITLE .'</a><br/>
									Based in '. COMPANY_BASED .'
								</p>
								<p>
									<strong>Release date:</strong><br/>
									'. GAME_DATE .'
								</p>

								<p>
									<strong>Platforms:</strong><br />';

	for( $i = 0; $i < count($platforms); $i++ )
	{
		$name = $link = "";
		foreach( $platforms[$i]['platform']->children() as $child )
		{
			if( $child->getName() == "name" ) {
				$name = $child;
			} else if( $child->getName() == "link" ) {
				$link = $child;
			}
		}
		if($link == ""){
			echo ''.$name.'<br/>';
		}else{
			echo '<a href="http://'.parseLink($link).'">'.$name.'</a><br/>';
		}
	}

	echo '							</p>
								
								<p>
									<strong>Website:</strong><br/>
									<a href="http://'. parseLink(GAME_WEBSITE) .'">'. parseLink(GAME_WEBSITE) .'</a>
								</p>
								<p>
									<strong>Regular Price:</strong><br/>';

	if( count($prices) == 0 )
	{
		echo '-';
	}
	else
	{
		//echo '<table>';
		for( $i = 0; $i < count($prices); $i++ )
		{
			$currency = $value = "";

			foreach( $prices[$i]['price']->children() as $child )
			{
				if( $child->getName() == "currency" ) {
					$currency = $child;
				} else if( $child->getName() == "value" ) {
					$value = $child;
				}
			}
			echo '<tr><td>'.$currency.'</td><td>'.$value.'</td></tr>';
		}
		echo'</table>';
	}

	echo'							</p>

								
								
							</div>
							<div class="uk-width-medium-4-6">
							<h2 id="description">Description</h2>
							';
							
	//QUOTES						
	if($game == "bonza_word_puzzle"){
	echo'
										<p>
										<b>"Bonza puzzles are instantly addictive!"<br>
			- <i>Will Shortz </b>Crossword Editor, The New York Times</i><br><br>
			</p>';
	}else if($game == "bonza_planet"){

	echo'
		<p>
		<p><b>RELEASE DATE: JUNE 18, 2015</b></p>
		<b>"Bonza puzzles are instantly addictive!"<br>
	- <i>Will Shortz </b>Crossword Editor, The New York Times</i><br>


	<p>Combine word search, jigsaw and trivia to solve puzzles as you explore the world of Bonza Planet. This edition of Bonza highlights themes like Animals, Travel, Planet Earth, Humanity and Science.</p>

	<p>Every day you’ll be able to solve a free daily shuffle designed by the Bonza community.</p>

	<p>In 2015 National Geographic signed Minimega to a multi-year licensing agreement. </p>

	<p>The license expired in 2018 and the game was re-named to "Bonza Planet".</p>


	';


		
	}

	echo'<p>'. str_replace('<br />', '</p><p>', nl2br(GAME_DESCRIPTION)) .'</p> 
	<h2 id="history">History</h2>';
								

	for( $i = 0; $i < count($histories); $i++ )
	{
		$header = $text ="";

		foreach( $histories[$i]['history']->children() as $child )
		{
			if( $child->getName() == "header" ) $header = $child;
			else if( $child->getName() == "text" ) $text = $child;
		}
		echo '<strong>'.$header.'</strong>
	<p>'.str_replace('<br />', '</p><p>', nl2br($text)).'</p>';
	}




	echo '							<h2>Features</h2>
								<ul>';

	for( $i = 0; $i < count($features); $i++ )
	{
		echo '<li>'.nl2br($features[$i]).'</li>';
	}

	echo '							</ul>
							</div>
						</div>

						<hr>

						<h2 id="trailers">Videos</h2>';

	if( count($trailers) == 0 )
	{
		echo '<p>There are currently no trailers available for '.GAME_TITLE.'. Check back later for more or <a href="#contact">contact us</a> for specific requests!</p>';
	}
	else
	{
		for( $i = 0; $i < count($trailers); $i++ )
		{
			$name = $youtube = $vimeo = $mov = $mp4 = "";
			$ytfirst = -1;

			foreach( $trailers[$i]['trailer']->children() as $child )
			{
				if( $child->getName() == "name" ) {
					$name = $child;
				} else if( $child->getName() == "youtube" ) { 
					$youtube = $child; 
				
					if( $ytfirst == -1 ) { 
						$ytfirst = 1; 
					} 
				} else if( $child->getName() == "vimeo" ) {
					$vimeo = $child; if( $ytfirst == -1 ) {
						$ytfirst = 0;
					}
				} else if( $child->getName() == "mov" ) {
					$mov = $child;
				} else if( $child->getName() == "mp4" ) {
					$mp4 = $child;
				}
			}
					
			if( strlen($youtube) + strlen($vimeo) > 0 )				
			{
				echo '<p><strong>'.$name.'</strong>&nbsp;';
				$result = "";

				if( strlen( $youtube ) > 0 ) {
					$result .= '<a href="https://www.youtube.com/watch?v='.$youtube.'">YouTube</a>, ';
				}
				if( strlen( $vimeo ) > 0 ) {
					$result .= '<a href="https://www.vimeo.com/'.$vimeo.'">Vimeo</a>, ';
				}
				if( strlen( $mov ) > 0 ) {
					$result .= '<a href="'.$game.'/trailers/'.$mov.'">.mov</a>, ';
				}
				if( strlen( $mp4 ) > 0 ) {
					$result .= '<a href="'.$game.'/trailers/'.$mp4.'">.mp4</a>, ';
				}

				echo substr($result, 0, -2);

				if( $ytfirst == 1 ) 
				{
					echo '<div class="uk-responsive-width iframe-container">
			<iframe src="https://www.youtube.com/embed/'. $youtube .'?rel=0&amp;&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
	</div>';
				} elseif ( $ytfirst == 0 ) {
					echo '<div class="uk-responsive-width iframe-container">
			<iframe src="https://player.vimeo.com/video/'.$vimeo.'" frameborder="0" allowfullscreen></iframe>
	</div>';
				}
				echo '</p>';
			}				
		}
	}

	echo '					<hr>

						<h2 id="images">Images</h2>';

	if( file_exists($game."/images/images.zip") )
	{
		$filesize = filesize($game."/images/images.zip");
		if( $filesize > 1024 && $filesize < 1048576 ) {
			$filesize = (int)( $filesize / 1024 ).'KB';
		}
		if( $filesize > 1048576 ) {
			$filesize = (int)(( $filesize / 1024 ) / 1024 ).'MB';
		}

		echo '<a href="'. $game .'/images/images.zip"><div class="uk-alert">download all screenshots &amp; photos as .zip ('. $filesize .')</div></a>';
	}

	echo '<div class="uk-grid images">';
	if ($handle = opendir($game.'/images'))
	{
		$found = 0;
		/* This is the correct way to loop over the directory. */
		while (false !== ($entry = readdir($handle)))
		{
			if( substr($entry,-4) == ".png" )
			{
				if( substr($entry,0,4) != "logo" && substr($entry,0,4) != "icon" && substr($entry,0,6) != "header" )
				{	
					echo '<div class="uk-width-medium-1-2"><a href="'. $game .'/images/'. $entry .'"><img src="'. $game .'/images/'.$entry.'" alt="'.$entry.'" /></a></div>';
					$found++;
				}
			}
		}
	}
	echo '</div>';

	closedir($handle);

	if ($found == 0) {
		echo '<p class="images-text">There are currently no screenshots available for '.GAME_TITLE.'. Check back later for more or <a href="#contact">contact us</a> for specific requests!</p>';
	}
						
	echo '					<hr>

						<h2 id="logo">Logo and Icon</h2>';

	if( file_exists($game."/images/logo.zip") )
	{
		$filesize = filesize($game."/images/logo.zip");
		if( $filesize > 1024 && $filesize < 1048576 ) {
			$filesize = (int)( $filesize / 1024 ).'KB';
		}
		if( $filesize > 1048576 ) {
			$filesize = (int)(( $filesize / 1024 ) / 1024 ).'MB';
		}

		echo '<a href="'.$game.'/images/logo.zip"><div class="uk-alert">download logo files as .zip ('. $filesize .')</div></a>';
	}

	echo '<div class="uk-grid images">';

	if( file_exists($game.'/images/logo.png') ) {
		echo '<div class="uk-width-medium-1-2"><a href="'.$game.'/images/logo.png"><img src="'.$game.'/images/logo.png" alt="logo" /></a></div>';
	}

	if( file_exists($game.'/images/icon.png') ) {
		echo '<div class="uk-width-medium-1-2"><a href="'.$game.'/images/icon.png"><img src="'.$game.'/images/icon.png" alt="logo" /></a></div>';
	}

	echo '</div>';

	if( !file_exists($game.'/images/logo.png') && !file_exists($game.'/images/icon.png')) {
		echo '<p>There are currently no logos or icons available for '.GAME_TITLE.'. Check back later for more or <a href="#contact">contact us</a> for specific requests!</p>';
	}

	echo '<hr>';

	if( $promoterawards && $awards && (count( $promoterawards ) + count( $awards ) > 0) )
	{
		echo('<h2 id="awards">Awards & Recognition</h2>');
		echo('<ul>');

		if( count($promoterawards) >= 0 )
		{
			for( $i = 0; $i < count($promoterawards); $i++ )
			{
				$description = $info = "";
				foreach( $promoterawards[$i]['award']->children() as $child )
				{
					if( $child->getName() == "title" ) {
						$description = $child;
					} else if( $child->getName() == "location" ) {
						$info = $child;
					} else if( $child->getName() == "url" ) {
						$url = $child;
					} else if( $child->getName() == "year" ) {
						$year = $child;
					}
				}
				echo '<li>"'.$description.'" <cite>'.$info.'</cite></li>';
			}			
		}
		
		if( count($awards) > 0 )
		{
			for( $i = 0; $i < count($awards); $i++ )
			{
				$description = $info = "";
				foreach( $awards[$i]['award']->children() as $child )
				{
					if( $child->getName() == "description" ) {
						$description = $child;
					} else if( $child->getName() == "info" ) {
						$info = $child;
					}
				}
				echo '<li>"'.$description.'" <cite>'.$info.'</cite></li>';
			}
		}
		
		echo '</ul>';
		echo '<hr>';
	}

	if( $promoterquotes && $quotes && (count($promoterquotes) + count($quotes) > 0) )
	{
		echo '					<hr>
				
							<h2>Selected Articles</h2>
							<ul>';

		if( count($promoterquotes) >= 0 )
		{
			for( $i = 0; $i < count($promoterquotes); $i++ )
			{
				$name = $description = $website = $link = "";
				foreach( $promoterquotes[$i]['review']->children() as $child )
				{
					if( $child->getName() == "quote" ) {
						$description = $child;
					} else if( $child->getName() == "reviewer-name" ) {
						$name = $child;
					} else if( $child->getName() == "publication-name" ) {
						$website = $child;
					} else if( $child->getName() == "url" ) {
						$link = $child;
					}
				}
				echo '<li>"'.$description.'" <br/>
		<cite>- '.$name.', <a href="http://'.parseLink($link).'">'.$website.'</a></cite></li>';
			}
		}
		
		if( count($quotes) > 0 )
		{
			for( $i = 0; $i < count($quotes); $i++ )
			{
				$name = $description = $website = $link = "";
				foreach( $quotes[$i]['quote']->children() as $child )
				{
					if( $child->getName() == "description" ) {
						$description = $child;
					} else if( $child->getName() == "name" ) {
						$name = $child;
					} else if( $child->getName() == "website" ) {
						$website = $child;
					} else if( $child->getName() == "link" ) {
						$link = $child;
					}
				}
				echo '<li>"'.$description.'" <br/>
		<cite>- '.$name.', <a href="http://'.parseLink($link).'">'.$website.'</a></cite></li>';
			}
		}
		
		echo '</ul>';
		echo '<hr>';
	}


	if( $press_request == TRUE )
	{

		switch($game){
			case 'bonza_phrases':
				$gameTitle = 'Bonza Phrases';
				break;
			default:
				$gameTitle = 'Bonza Planet';
				break;
		}

			echo '<h2 id="preview">Request Press Copy</h2>';
			echo 'If you\'d like a copy of '.$gameTitle.' please <a href="mailto:'.COMPANY_CONTACT.'?subject='.$gameTitle.'"> get in touch.</a>';
			
			//echo '<a href="mailto:recipient@example.com?subject=hello> Send us and email</a> and we will send you stuff as soon as its available.';
			echo '<hr>';
	}


	if( $monetize >= 1 )
	{
		echo '<h2 id="monetize">Monetization Permission</h2>';
		if( $monetize == 1 ) echo('<p>'.COMPANY_TITLE.' does currently not allow for the contents of '.GAME_TITLE.' to be published through video broadcasting services.</p>');
		if( $monetize == 2 ) echo('<p>'.COMPANY_TITLE.' does allow the contents of this game to be published through video broadcasting services only with direct written permission from '.COMPANY_TITLE.'. Check at the bottom of this page for contact information.</p>');
		if( $monetize == 3 ) echo('<p>'.COMPANY_TITLE.' allows for the contents of '.GAME_TITLE.' to be published through video broadcasting services for non-commercial purposes only. Monetization of any video created containing assets from '.GAME_TITLE.' is not allowed.</p>');
		if( $monetize == 4 ) echo('<p>'.COMPANY_TITLE.' allows for the contents of '.GAME_TITLE.' to be published through video broadcasting services for any commercial or non-commercial purposes. Monetization of videos created containing assets from '.GAME_TITLE.' is legally & explicitly allowed by '.COMPANY_TITLE.'. This permission can be found in writing at <a href="'.'http://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'].'">http://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'].'</a>.</p>');
		echo '<hr>';
	}


	echo '					<h2 id="links">Additional Links</h2>';
			
	for( $i = 0; $i < count($additionals); $i++ )
	{
		$title = $description = $link = "";
		foreach( $additionals[$i]['additional']->children() as $child )
		{
			if( $child->getName() == "title" ) {
				$title = $child;
			} else if( $child->getName() == "description" ) {
				$description = $child;
			} else if( $child->getName() == "link" ) {
				$link = $child;
			}
		}

		if( strpos(parseLink($link),'/') !== 0 ) {
			$linkTitle = substr(parseLink($link),0,strpos(parseLink($link),'/'));
		} else { $linkTitle = $link; }
		
		echo '<p>
		<strong>'.$title.'</strong><br/>
		'.$description.' <a href="http://'.parseLink($link).'" alt="'.parseLink($link).'">'.$linkTitle.'</a>.
	</p>';
	}

	echo '					<hr>

						<h2 id="about">About '. COMPANY_TITLE .'</h2>
						<p>
							<strong>Description</strong><br/>
							'. COMPANY_DESCRIPTION .'
						</p>

						<p>
							<strong>More information</strong><br/>
							The press kit for '. COMPANY_TITLE .' is available <a href="index.php">here</a>.
						</p>
						
						<hr>

						<div class="uk-grid">
							<div class="uk-width-medium-1-2">
								<h2 id="credits">'. GAME_TITLE .' Credits</h2>';

	for( $i = 0; $i < count($credits); $i++ )
	{
		$previous = $website = $person = $role = "";
		foreach( $credits[$i]['credit']->children() as $child )
		{
			if( $child->getName() == "person" ) {
				$person = $child;
			} else if( $child->getName() == "previous" ) {
				$previous = $child;
			} else if( $child->getName() == "website" ) {
				$website = $child;
			} else if( $child->getName() == "role" ) {
				$role = $child;
			}
		}

		echo '<p>';
					
		if( strlen($website) == 0 )
		{
			echo '<strong>'.$person.'</strong><br/>'.$role;
		}
		else
		{
			echo '<strong>'.$person.'</strong><br/><a href="http://'.parseLink($website).'">'.$role.'</a>';
		}

		echo '</p>';
	}

	echo '						</div>
							<div class="uk-width-medium-1-2">
								<h2 id="contact">Contact</h2>';

	for( $i = 0; $i < count($contacts); $i++ )
	{
		$link = $mail = $name = "";
		foreach( $contacts[$i]['contact']->children() as $child )
		{
			if( $child->getName() == "name" ) {
				$name = $child;
			} else if( $child->getName() == "link" ) {
				$link = $child;
			} else if( $child->getName() == "mail" ) {
				$mail = $child;
			}
		}

		echo '<p>';

		if( strlen($link) == 0 && strlen($mail) > 0 ) {
			echo '<strong>'.$name.'</strong><br/><a href="mailto:'.$mail.'">'.$mail.'</a>';
		}
		if( strlen($link) > 0 && strlen($mail) == 0 ) {
			echo '<strong>'.$name.'</strong><br/><a href="http://'.parseLink($link).'">'.parseLink($link).'</a>';
		}

		echo '</p>';
	}

	echo '						</div>
						</div>

						<hr>

						<p><a href="http://dopresskit.com/">presskit()</a> by Rami Ismail (<a href="http://www.vlambeer.com/">Vlambeer</a>) - also thanks to <a href="sheet.php?p=credits">these fine folks</a></p>
					</div>
				</div>
			</div>

			<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
			<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.js"></script>		
			<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/masonry/3.1.2/masonry.pkgd.min.js"></script>
			<script type="text/javascript">
				$( document ).ready(function() {
					var container = $(\'.images\');

					container.imagesLoaded( function() {
						container.masonry({
							itemSelector: \'.uk-width-medium-1-2\',
						});
					});
				});
			</script>
			<script type="text/javascript" src="validation.js"></script>';
	if ( defined("ANALYTICS") && strlen(ANALYTICS) > 10 )
	{
		echo '<script type="text/javascript">
		var _gaq = _gaq || [];
		_gaq.push([\'_setAccount\', \'' . ANALYTICS . '\']);
		_gaq.push([\'_trackPageview\']);

		(function() {
			var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
			ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
			var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
		})();
	</script>';
	}
	echo'	</body>
	</html>';

	?>
