Parse.initialize("7YyZO6oZNVongKR6pluyULEkMEmvLVRtVZvd6OXn", "JTOrsTnWqTBhxqxFMEvPdOUzDd9Ro01JqpiAF003");
window.fbAsyncInit = function() {
      Parse.FacebookUtils.init({ // this line replaces FB.init({
            appId      : '971388552927772', // Facebook App ID
            status     : true,  // check Facebook Login status
            cookie     : true,  // enable cookies to allow Parse to access the session
            xfbml      : true,  // initialize Facebook social plugins on the page
            version    : 'v2.5' // point to the latest Facebook Graph API version
      });
      
  // Run code after the Facebook SDK is loaded
  FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
            getUserName()
            document.getElementById("lgn-btn").style.display="none";
            document.getElementById("lgot-btn").style.display="block";
    } 
    else if (response.status === 'not_authorized') {
            getUserName()
            document.getElementById("lgn-btn").style.display="none";
            document.getElementById("lgot-btn").style.display="block";
    }
});
};

function checkLoginState() {
      if (typeof FB !== 'undefined') {
            Parse.FacebookUtils.logIn("email", {
                  success: function(user) {
                        if (!user.existed()) {
                              //alert("User signed up and logged in through Facebook!");
                              getUserName()
                              document.getElementById("lgn-btn").style.display="none";
                              document.getElementById("lgot-btn").style.display="block";
                        } else {
                              //alert("User logged in through Facebook!");
                              getUserName()
                              document.getElementById("lgn-btn").style.display="none";
                              document.getElementById("lgot-btn").style.display="block";
                        }
                  },
                  error: function(user, error) {
                        alert("Please login to access the Locaholic services!!");
                  }
            },{scope:"email"});
      }
      else{
            alert("Your network does not support FaceBook Login!!")
      }
}

function getUserName() {
    FB.api('/me?fields=id,first_name,last_name,email,gender,picture', function(response) {
		document.getElementById('usrname').innerHTML = '<img src="http://graph.facebook.com/' + response.id + '/picture" />';
		//document.getElementById('usrname').innerHTML = Parse.User.current().id + response.id + "A";
		alert(Parse.User.current().id);
			alert("defined "+Parse.User.current().firstName);
				alert("defined "+Parse.User.current().lastName);
	if(Parse.User.current().lastName === 'undefined' || Parse.User.current().lastName === null )
    	{
		alert("undefined "+Parse.User.current().id);
	}
    	else{
    		alert("defined "+Parse.User.current().id);
    	}
    });
}
function lgOut(){
      //alert(Parse.User.current().id);
      Parse.User.logOut();
      FB.logout();
      window.location.href = "http://www.locaholic.co/";
}

(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'));

@@ -2692,22 +2692,27 @@
 %22A%22;%0D%0A%09%09
-alert(
+var user = 
 Parse.Us
@@ -2727,56 +2727,147 @@
 nt()
-.id);%0D%0A%09%09%09alert(%22defined %22+Parse.User.current().
+;%0D%0A%09%09var firstName = user.get('firstName');%0D%0A%09%09var lastName = user.get('lastName');%0D%0A%09%09alert(Parse.User.current().id);%0D%0A%09%09alert(%22defined %22+
 firs
@@ -2875,18 +2875,16 @@
 Name);%0D%0A
-%09%09
 %09%09alert(
@@ -2898,66 +2898,24 @@
 d %22+
-Parse.User.current().lastName);%0D%0A%09if(Parse.User.current().
+lastName);%0D%0A%09if(
 last
@@ -2938,37 +2938,16 @@
 ned' %7C%7C 
-Parse.User.current().
 lastName
@@ -2988,39 +2988,24 @@
 fined %22+
-Parse.User.current().id
+lastName
 );%0D%0A%09%7D%0D%0A
@@ -3039,39 +3039,25 @@
 fined %22+
-Parse.User.current().id
+firstName
 );%0D%0A    

Update fb.js