<?php 

require_once('./global.php'); 

if(isset($_REQUEST['do'])) {
if($_REQUEST['do'] == 'fetch_name') {
	$race = mysql_real_escape_string($_GET['ra']);
	$gender = mysql_real_escape_string($_GET['g']);
	
	if(!$race || !$gender) {
		echo "Select a Race or Gender";
		return;
	}
	
	$name = $db->query_first("SELECT GENERATE_NAME('".$race."','".$gender."') AS name");
	echo $name['name'];
	exit;
}
}

//race area
$race_options = "";
$races = $db->query("SELECT Area as myName FROM NameArea UNION SELECT Race as myName FROM NameRace WHERE ApplyArea <> 'YES'");
while ($race = $db->fetch_array($races)) {
	$value = $title = $race['myName'];
	$race_options .= "<option value=\"$value\">$title</option>";
}

//gender
$gender_options = "";
$genders = $db->query("SELECT 'ANY' as myGender UNION SELECT DISTINCT Gender as myGender FROM NameFirst");
while ($gender = $db->fetch_array($genders)) {
	$value = $title = $gender["myGender"];
	$gender_options .= "<option value=\"$value\">$title</option>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>

<!-- Insert page title info here -->

	<title>Farland Name Generator: 4E</title>

<!-- End page title info -->

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" media="all and (max-device-width: 801px)" href="mobile4.css" />
<link rel="stylesheet" type="text/css" media="all and (min-device-width: 802px)" href="global4.css" />
<!--[if IE 8 ]>  <link rel="stylesheet" type="text/css" media="screen" href="global4ie.css" />  <html class="ie8"> <![endif]-->
	<meta name="author" content="S. Baker" />
	<meta name="description" content="This page allows you to randomly generate names from the fantasy world of Farland."/>
	<meta name="keywords" content="4e, 4th edition, name generator, D &amp; D, DnD, Dungeons &amp; Dragons; roleplaying, RPG, fantasy, maps, Tolkien, Farland"/>

        <script type="text/javascript" language="javascript" src="generatename.js"></script>
</head>

<body>
<div id="rightside">
  <div id="main">
	<div id="header"><div id="pic2"><h1 class="nocss"><a href="index~.html">The World of Farland 4E</a></h1></div></div>
	<div id="pic"><h1 class="nocss2">An Epic</h1></div>
	<div id="banner"><a href="index~.html">Roleplaying Resource</a></div>

<div id="menu"><a href="details~.html" title="Details and descriptions of the World of Farland.">Setting</a>  &nbsp; &loz; &nbsp; <a href="player~.html" title="Rules information for players.">Players</a>  &nbsp; &loz; &nbsp;<a href="nurmap~.html" title="Interactive maps of Farland.">Maps</a>  &nbsp; &loz; &nbsp;  <a href="hist~.html" title="History and Timeline of Farland.">History</a>  &nbsp; &loz; &nbsp; <a href="pan~.html" title="Gods and Demigods of Farland.">Pantheon</a> &nbsp; &loz; &nbsp; <a href="camp~.html" title="Short stories and campaign journal.">Literature</a>  &nbsp; &loz; &nbsp; <a href="new~.html" title="Recent updates to the site.">Updates</a> </div>

<div id="content">
<!-- Begin content here -->

<h1>Farland Name Generator</h1>

<p><b>Directions</b>: Use this page to generate a random <a href="comnames~.html">name</a> from any race in Farland.  Just select the race (or, if human, the area from which the human comes), and click the button.  You can select "Male" gender to get a male name, "Female" to get a female name, or "Any" to get a random name from either gender.  You must select a race.</p>
<br />
<br />

<p><b>Select a Race and Gender</b><br /> <br /> 
<select id="Race">
<option value="0">Choose
<?=$race_options?>
</select>
<br />
<br><select id="Gender">
<option value="0">Choose
<?=$gender_options?>
</select>
<br />
</p>

<div align="center">

<br /> <br />

<a href="#" onclick="generateName('Race', 'Gender', 'answer'); return false;">
<button>Generate Random Name</button>
</a>
<br />
<br />

<span width="600px;" id="answer">&nbsp;</span><br/><br />
</div>

<!-- End content here -->
	   </div>
<div id="footer"><br /><a href="index~.html" title="Back to the front page.">Home</a> &nbsp; &loz; &nbsp;<a href="links~.html" title="Fantasy and roleplaying sites of interest.">Links</a> &nbsp; &loz; &nbsp; <a href="sitemap~.html" title="Navigation aids.">Site Map</a> &nbsp; &loz; &nbsp; <a href="tools~.html" title="Adventures, downloads, and tools.">RP Tools</a> &nbsp; &loz; &nbsp; <a href="scenes~.html" title="Explanation of this website.">About</a> &nbsp; &loz; &nbsp; <a href="faq~.html" title="Frequently asked questions about Farland.">FAQ</a> &nbsp; &loz; &nbsp; <a href="http://www.d20srd.org/" title="The D20 rules online, searchable.">SRD</a> &nbsp; &loz; &nbsp;<a href="legal~.html" title="Legal information and copyright details.">Legal</a> &nbsp; &loz; &nbsp; <a href="mailto:webmaster@farlandworld.com" title="Email the webmaster or staff.">Contact</a>

<p class="copy">&copy;2008 &nbsp; S. Baker</p></div>
  </div>
</div>

</body>
</html>
