<?php
if(is_dir('admin')) 
{
$i = 0; 
$dir = 'admin/';
if ($handle = opendir($dir)) {
	while (($file = readdir($handle)) !== false){
		if (!in_array($file, array('.', '..')) && !is_dir($dir.$file)) 
			$i++;
	}
}
 if($i>10)
 {
 header('location:admin/index.php');
 }
}
?>
<!doctype html>  
<html dir="ltr" lang="en-US">
	<head>
		<title>Voting Advice Application</title>
		<!-- generic demo style -->
		<link rel="stylesheet" href="./css/reset.css" />
		<link rel="stylesheet" href="./css/demo.css" />
		<!--[if lt IE 9]>
			<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
		<![endif]-->
        <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
        <script>
		function startVoting()
		{	
		   var start="1";
		    $('#loading').css('visibility','visible');	//show the rotating gif animation
			$.ajax({
				type: 'POST',
				url: 'includes/ajax/vote.php',
				data: {'startVoting': start},
				success: function(msg){
					
					$('#loading').css('visibility','hidden');
					if(msg=="1")
					{
						window.location='voting.php';
					}
					else
					{
						alert("Sorry! No Questions Available");
					}
					
				}
			});
		}
		
		</script>

		<style>
			html{
				width:100%;
				height:100%;
			}
			
			body{
				width:100%;
				height:100%;
			}
			
			#header{
				width:100%;
			}
			
			
			#container
			{
			  width:100%;
			}
			
			#footer{
				width:100%;
			}
        </style>
	</head>	
    <body>
   
		<div id="header">
			<div id="header-wrapper">
				<h1>Voting Advice Application</h1>
				<h2>An Advice Application</h2>
				<p><a href="index.php">Home</a> | <a href="statistics/index.php">Statistics</a></p>
			</div>
			<div class="gradient">&nbsp;</div>
		</div>
		
		<div id="container">
         <div id="wrapper">
			<h2 id="introduction">Introduction</h2>
			<p>Hey, yo, wow! Welcome to this cool voting advice thingy. This is just a demo, don't ever vote Doodle. Thanks.</p>
			  <p><a href="#" class="large blue button next" data-action="next" onClick="startVoting()">Start</a></p> 
              <img src="images/loaders/gif_3.gif" id="loading" alt="loading..." style="visibility:hidden;"/>
			<div class="clearfix"></div>
	     </div>
        </div> 
		
		<div id="footer">
			<div class="gradient">&nbsp;</div>
			<div id="footer-wrapper">
			<p>&copy; <a href="https://klaus-uwe.me">Klaus-Uwe Mitterer</a> 2014</p>
			</div>
		</div>

	</body>
</html>
