FB.init({
  appId  : '177757328911271',
  status : true, // check login status
  cookie : true, // enable cookies to allow the server to access the session
  xfbml  : true  // parse XFBML
});

FB.getLoginStatus(function(response) {
  if(response.session==null){
  	if($.cookie('fblogin')=='1'){
  		window.location='/include/logout.php';
	  }
  }
});

function fb_initConnect(){
	FB.getLoginStatus(function(response) {
  	if(response.session){
			FB.api('/me', function(response) {
			  var firstname=escape(response.first_name);
			  var lastname=escape(response.last_name);
			  var email=escape(response.email);
			  var gender=escape(response.gender);
			  var fbUid=response.id;
			  window.location='/include/loginFacebook.php?firstname='+firstname+'&lastname='+lastname+'&email='+email+'&gender='+gender+'&fbUid='+fbUid;
			});
		}
	});
}
