<?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> 
<html lang="en" xml:lang="en">

<!-- Insert page title info here -->

	<title>Random Name Generator: 3E</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="mobile3.css" />
<link rel="stylesheet" type="text/css" media="all and (min-device-width: 802px)" href="global3.css" />
<!--[if IE 8 ]>  <link rel="stylesheet" type="text/css" media="screen" href="global3ie.css" />  <html class="ie8"> <![endif]-->
	<meta name="author" content="S. Baker" />
	<meta name="description" content="This page details a calendar of the fantasy world of Farland."/>
	<meta name="keywords" content="3E, 3rd edition, 8170 calendar, D &amp; D, DnD, Dungeons &amp; Dragons; roleplaying, RPG, fantasy, maps, Tolkien, Farland"/>


</head>

<body>
<div id="rightside">
  <div id="main">
	<div id="header"><div id="pic2"><h1 class="nocss"><a href="index3.html">The World of Farland 3.5E</a></h1></div></div>
	<div id="pic"><h1 class="nocss2">An Epic</h1></div>
	<div id="banner"><a href="index3.html">Roleplaying Resource</a></div>
	
<div id="menu"><a href="details3.html" title="Details and descriptions of the World of Farland.">Setting</a>  &nbsp; &loz; &nbsp; <a href="player3.html" title="Rules information for players.">Players</a>  &nbsp; &loz; &nbsp;<a href="nurmap3.html" title="Interactive maps of Farland.">Maps</a>  &nbsp; &loz; &nbsp;  <a href="hist3.html" title="History and Timeline of Farland.">History</a>  &nbsp; &loz; &nbsp; <a href="pan3.html" title="Gods and Demigods of Farland.">Pantheon</a> &nbsp; &loz; &nbsp; <a href="camp3.html" title="Short stories and campaign journal.">Literature</a>  &nbsp; &loz; &nbsp; <a href="new3.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="index3.html" title="Back to the front page.">Home</a> &nbsp; &loz; &nbsp;<a href="links3.html" title="Fantasy and roleplaying sites of interest.">Links</a> &nbsp; &loz; &nbsp; <a href="sitemap3.html" title="Navigation aids.">Site Map</a> &nbsp; &loz; &nbsp; <a href="tools3.html" title="Adventures, downloads, and tools.">RP Tools</a> &nbsp; &loz; &nbsp; <a href="scenes3.html" title="Explanation of this website.">About</a> &nbsp; &loz; &nbsp; <a href="faq3.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="legal3.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 id="search"><!-- Google Search Box Begins  -->
<!-- Google code for Search -->
<script>
  (function() {
    var cx = '012880969025040634953:vo7uqfvra6a';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
        '//www.google.com/cse/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
</script>
<style type="text/css">
.gsc-control-cse {
padding: 0px;
background: transparent;
border: 0px;
width:250px;
font-family: Georgia, "Times New Roman",sans-serif;
 }
input.gsc-search-button:hover {
 background-color:#721d0a;
}
</style>
<gcse:search></gcse:search>

<!-- Google Search Box Ends -->
        </div>
</div>


</body>
</html>