<?php 
include("kana.php");

if(isset($_GET['in']) && isset($_GET['action']))
{
	$in = $_GET['in'];
	
	if($_GET['action'] == "to_hira")
	{
		$out = Kana::to_hiragana($in);
	}
	else if($_GET['action'] == "to_kata")
	{
		$out = Kana::to_katakana($in);
	}
	else if($_GET['action'] == "from_kana")
	{
		$out = Kana::from_kana($in);
	}
}
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Romaji/Kana transliteration</title>
	</head>
	<body>
		<form action="" method="get">
			<dl>
				<dt><label for="in">Romaji</label></dt>
				<dd><textarea rows="10" cols="80" name="in" id="in"></textarea></dd>
			</dl>
			<dl>
				<dt><label for="action">Action</label></dt>
				<dd>
					<select name="action" id="action">
						<option value="to_hira">To Hiragana</option>
						<option value="to_kata">To Katakana</option>
						<option value="from_kana">From Kana</option>
					</select>
				</dd>
			</dl>
			<button type="submit">Transliterate</button>
		</form>
		<p id="out">
			<?= (isset($out)) ? $out : "" ?>
		</p>
	</body>
</html>