<!DOCTYPE html>
	<html>
	<head>
		<title>Pontos Turísticos</title>
		<link type="text/css" rel="stylesheet" href="estilo/style.css" />
	</head>
	<body>
<script>


  // This function is called when someone finishes with the Login
  // Button.  See the onlogin handler attached to it in the sample
  // code below.
  function checkLoginState(x) {
    FB.login(function(response) {
		if (response.authResponse) {
            // usuario aceitou o app
			testAPI();
        }
    }, {
        scope: 'email, publish_actions,user_photos'
    });

  }

  window.fbAsyncInit = function()
  {
	  FB.init({
		appId      : '131307234176194',
		cookie     : true,  // enable cookies to allow the server to access
							// the session
		xfbml      : true,  // parse social plugins on this page
		version    : 'v2.2' // use version 2.2
	  });

  // Now that we've initialized the JavaScript SDK, we call
  // FB.getLoginStatus().  This function gets the state of the
  // person visiting this page and can return one of three states to
  // the callback you provide.  They can be:
  //
  // 1. Logged into your app ('connected')
  // 2. Logged into Facebook, but not your app ('not_authorized')
  // 3. Not logged into Facebook and can't tell if they are logged into
  //    your app or not.
  //
  // These three cases are handled in the callback function.

	  FB.getLoginStatus(function(response) {
		statusChangeCallback(response);
	  });

  };
  // Load the SDK asynchronously
  (function(d, s, id)
  {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
  }
  (document, 'script', 'facebook-jssdk'));

  // Here we run a very simple test of the Graph API after login is
  // successful.  See statusChangeCallback() for when this call is made.
  function testAPI() {

    console.log('Welcome!  Fetching your information.... ');
  FB.api('/me',{fields:'email,gender'},function(response) {
      console.log('Bem-vindo, ' + response.name);
	  document.getElementById('email').innerHTML = 'e-Mail =  ' +
        response.email;
		document.getElementById('sexo').innerHTML = 'Sexo = ' +
        response.gender;
		document.getElementById('id').innerHTML = 'ID = ' +
        response.id;
		document.getElementById('foto').innerHTML = '<img src="http://graph.facebook.com/' + response.id + '/picture" />';

    });
  }
	function logout()
	{
		FB.logout(function(response) {
				// Person is now logged out
		});
		document.getElementById('email').innerHTML = "";
		document.getElementById('sexo').innerHTML = "";
		document.getElementById('id').innerHTML = "";
		document.getElementById('foto').innerHTML ="";

	}
</script>

	<div id="geral">
	<header>
	</header>
	<nav>
			<?php	
			echo "<div id='menucentro'>";
				echo "<div id='menudireita'>";
					echo "<ul>";
						echo "<div id='in'>";
							echo "<li><a href='index.php?controle=mapaControle&metodo=mostrarPontos'>Mostrar Pontos Turísticos</a></li>&nbsp;&nbsp;";

							// verifica se foi logado
							if(!isset($_SESSION["login"]) == "interno")
							{
								echo "<li><a href='index.php?controle=usuarioControle&metodo=login'>Entrar</a></li>&nbsp;&nbsp;";
								echo "<li><a href='?controle=cadastroControle&metodo=cadastro'>Cadastre-se</a></li>&nbsp;&nbsp;";
							} else {
								echo "<li><a href='index.php?controle=mapaControle&metodo=listarPontos'>Listar Pontos Turísticos</a></li>&nbsp;&nbsp;";
								echo "<li><a href='index.php?controle=mapaControle&metodo=tracarRota'>Rota</a></li>&nbsp;&nbsp;";								
								echo "<li><a href='index.php?controle=usuarioControle&metodo=logout'>Sair</a></li>";
							}
						echo "</div>";
					echo "</ul>";
			echo "</div>";
			?>
		</div>
	</nav>
</div>
