<?php
ini_set( "display_errors", "Off");

require_once './FlCommon.php';

define("XML", "FlArenaXml.php");

$status = 1;
$flCommon = new FlCommon();

try {
	if (!empty($_GET["aid"])){
		$arena_id = $_GET["aid"];

		$opts = array(
				'http' => array(
						'method' => "GET",
						'header' => "Referer: ".$_SERVER["HTTP_REFERER"]."\r\n".
						"Access-key: ".ACCESS_KEY."\r\n"
				)
		);
		$context = stream_context_create($opts);

		$xmlstr = file_get_contents(URL.XML.'?aid='.$arena_id, false, $context);

		$flarena = new SimpleXMLElement($xmlstr);

		$status = $flarena->{'status'};

		$arenaData = $flarena->{'arena'};

		$arena_id = $arenaData->{'arena-id'};
		$ground_nm = $arenaData->{'ground-nm'};
		$postcode = $arenaData->{'postcode'};
		$address = $arenaData->{'address'};
		$tel1 = strval($arenaData->{'tel1'});
		$tel2 = strval($arenaData->{'tel2'});
		$tel3 = strval($arenaData->{'tel3'});
		$fax1 = strval($arenaData->{'fax1'});
		$fax2 = strval($arenaData->{'fax2'});
		$fax3 = strval($arenaData->{'fax3'});
		$mail_address = strval($arenaData->{'mail-address'});
		$url = strval($arenaData->{'url'});
		$ground_sht_nm = $arenaData->{'ground-sht-nm'};
		$parking_lot = $arenaData->{'parking-lot'};
		$coordinats = strval($arenaData->{'coordinats'});
		$station1 = strval($arenaData->{'station1'});
		$station2 = strval($arenaData->{'station2'});
		$station3 = strval($arenaData->{'station3'});
		$access1 = strval($arenaData->{'access1'});
		$access2 = strval($arenaData->{'access2'});
		$access3 = strval($arenaData->{'access3'});
		
		$tel = "";
		if (!empty($tel1) && !empty($tel2) && !empty($tel3)) {
			$tel = $tel1."-".$tel2."-".$tel3;
		}
		
	}
} catch (Exception $e) {
	$status = 1;
}

?>
<?php if ($status == 0): ?>
		<div class="set TableBox">
			<table>
				<tr>
					<th>住所</th>
					<td>
						<?=$address?>
					</td>
				</tr>
				<tr>
					<th>電話番号</th>
					<td>
						<?=$tel?>
					</td>
				</tr>
				<!-- <tr>
					<th>駐車場台数</th>
					<td>
	<?php if (intval($parking_lot) > 0): ?>
						<?=$parking_lot?>台
	<?php endif; ?>
					</td>
				</tr> -->
				<tr>
					<th>アクセス</th>
					<td>
						<?=$access1?>
	<?php if (!empty($access2)): ?>
						<br><?=$access2?>
	<?php endif; ?>
	<?php if (!empty($access3)): ?>
						<br><?=$access3?>
	<?php endif; ?>
					</td>
				</tr>
	<?php if (!empty($coordinats)): ?>
				<tr>
					<th>地図</th>
					<td>
						<div id="google_map" style="width: 520px; height: 500px"></div>
					</td>
				</tr>
	<?php endif; ?>
				<tr>
					<th>Webサイト</th>
					<td>
	<?php if (!empty($url)): ?>
						<a target="_blank" href="<?=$url?>"><?=$url?></a>
	<?php endif; ?>
					</td>
				</tr>
			</table>
		</div>
		<input type="hidden" id="ground_nm" value="<?=$ground_nm?>">
		<input type="hidden" id="cord" value="<?=$coordinats?>" />
<?php else: ?>
	<p>アリーナ情報はございません。</p>
<?php endif; ?>
