<?PHP
require('config.inc.php');

// Create connection
$conn = new mysqli($MYSQL_SERVER, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$query = "select art from geschlecht;";
$result = $conn->query($query);
$geschlecht='u';
if ($result->num_rows > 0) {
    // output data of each row
    if($row = $result->fetch_assoc()) {
	$geschlecht=$row['art'];
    }
}

?>
<!DOCTYPE html>
<html>
<head>
<link rel="icon" type="image/png" href="/favicon.png" sizes="96x96">
	<meta charset="utf-8">
    	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta property="og:image" content="https://nachwuchs.jensfz.de/images/ultraschall.png">
	<meta property="fb:app_id" content="1533749890073754"/>
	<meta property="og:url" content="https://nachwuchs.jensfz.de" />
	<meta property="og:type" content="website" />
	<meta property="og:description" content="Wird es ein Junge oder M&auml;dchen. Findet es hier herraus" />
	<meta property="og:image:width" content="400" />
	<meta property="og:image:height" content="300" />
	<meta property="og:locale" content="de_DE" />
	<meta property="og:title" content="Unser Nachwuchs" />
    	<title></title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-11188765-4"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-11188765-4');
</script>

<style>
h1 {
	text-align: center;
}

.center {
    margin: auto;
    width: 50%;
}
</style>

</head>
<body>
<h1>Mit Mausklick/Finger kann das Bild "freigerubbelt" werden</h1>
<div id="nachwuchs" class="scratchpad center"></div>
<script
  src="https://code.jquery.com/jquery-1.12.4.min.js"
  integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
  crossorigin="anonymous"></script>
<script type="text/javascript" src="./wScratchPad.min.js"></script>
<style>
        .scratchpad{
          width: 960px;
          height: 662px;
          border: solid 1px;
        }
        @media (max-width: 500px) {
          .scratchpad {
            width: 65%;
          }
        }
      </style>
<script type="text/javascript">
        $('#nachwuchs').wScratchPad({
	  size: 15,
          //bg: './images/maedchen.png',
	  //bg: './images/junge.png',
<?PHP
if($geschlecht=='j') {
?>
	  bg: './images/junge.png',
<?PHP
} elseif($geschlecht=='m') {
?>
	  bg: './images/maedchen.png',
<?PHP
} else {
?>
          bg: './images/umbekannt.png',
<?PHP
}
?>
          fg: './images/ultraschall.png',
          cursor: 'crosshair',
	  scratchMove: function(e, percent){
	  	$.ajax({
  			method: "POST",
  			url: "data.php",
  			data: { percent: percent }
		})
	  }
	});
      </script>
</body>
</html>
