<?php 
include('../includes/settings.php');
include('../includes/mysql_connect.php');
include('../includes/funcs.php');
session_start();
if (!$_SESSION['randomString'] || $_SESSION['randomString'] == "" )
{
	header('Location:contest_page1.php');
}
else if (!$_SESSION['insertID'] || $_SESSION['insertID'] == "")
{
	header('Location:contest_page2.php');
}
else
{
	// $randomString = $_SESSION['randomString'];
	$eligibleYN = $_SESSION['eligible'];
	$insertID = $_SESSION['insertID'];
}

if (isset($_POST['submit']))
{
	$boolValidate = true;
	$strValidation = $strValidationB = '';
	
	$sex = sanitize($_POST['sex']);

	if ($sex == '')
	{
		$boolValidate = false;
		$strValidationB .= "<h3>Please select your sex</h3>";
	}
	if ($boolValidate == true)
	{
		// do update

		$sql = "UPDATE tblKiosksParkPlace2015 set genderMF = '$sex' where intEntryID = '$insertID'";
		$result = getFromDatabase($sql);

		header('Location:thankyou.php');

	}
}


?>
<?php include('../includes/pp-header.php'); ?>
<body class="pp-top">
	<script type="text/javascript" src="../assets/scripts/check.js"></script>

	<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="ageForm" class="form" enctype="multipart/form-data" >
		<header>
			<a href='index.php' class='button home'>HOME</a>
		</header>
		<main class="container">
			<?php if ($strValidationB) echo '<div class="pinkText span10 centerContent">'.$strValidationB.'</div>'; ?>
			
			<div class="centerContent span8">
				<table>
					<tr>
						<td>
							<label class="defaultText">GENDER</label>	
							<input type="hidden" name="sex" id="sex" class="genderInput">		
						</td>
						<td>
							<a href="javascript:void(0)" id="male" class="genderButtons">
								<!-- <img src="../assets/images/male.png"> -->
							</a>
							

						</td>
						<td>
							<a href="javascript:void(0)" id="female" class="genderButtons">
								<!-- <img src="../assets/images/male.png"> -->
							</a>
							
						</td>
					</tr>
				</table>				
			</div>
		</main>
	
		<footer class="clearfix span11 centerContent">
			<div class="span5 column">
				<a href="#rules" class="fancybox" >CONTEST RULES AND REGULATIONS</a>
				<div id="rules">
					<?php include('rules.php') ?>
				</div>
			</div>
			<div class="span6 textRight column">
				<input type="submit" value="NEXT" name="submit" class="button">	
			</div>
		</footer>
	</form>
</body>
</html>


<script type="text/javascript">
$(document).ready(function()
{  

	$('.genderButtons').click(function(e)
	{
		
		var selected = $(this).attr('id');
		console.log(selected);

		$('.genderInput').val('');
		$('.genderButtons').removeClass('active');

		if (selected == 'male')
		{
			$('#male').addClass('active');
		}
		else
		{
			$('#female').addClass('active');
		}
		$('.genderInput').val(selected);
	})
});
</script>