    window.fbAsyncInit = function() {
		FB.init({
			appId      : '178184232273535', // App ID
			status     : true, // check login status
			cookie     : true, // enable cookies to allow the server to access the session
			oauth      : true, // enable OAuth 2.0
			xfbml      : true  // parse XFBML
		});
		// Additional initialization code here
		FB.Event.subscribe('auth.login', function (response) {
			getAccessToken();
		});
		/*
		*/

		FB.getLoginStatus(function(response) {
			if (response.authResponse) {
				// logged in and connected user, someone you know
				//alert("logged in");
				haveAccessToken();

			} else {
				// no user session available, someone you dont know
				//alert("not logged in");
			}
		});
		
    };
    
    (function(d){
		var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
		js = d.createElement('script'); js.id = id; js.async = true;
		js.src = "//connect.facebook.net/en_US/all.js";
		d.getElementsByTagName('head')[0].appendChild(js);
    }(document));
    
	function getAccessToken(){
		var at = window.location.hash.substring(1);
		if( at.length > 0 ){
			//alert("inside getAccessToken: token exists "+window.location.hash.substring(1));
			haveAccessToken();
		}else{
			//alert("inside getAccessToken: get token");
			var path = 'https://www.facebook.com/dialog/oauth?';
			var queryParams = ['client_id=' + '178184232273535','redirect_uri=' + window.location,'response_type=token'];
			var query = queryParams.join('&');
			var url = path + query;
			window.location.href = url;
			
		}
	}
	
	function haveAccessToken(){
		var accessToken = window.location.hash.substring(1);
		//alert("inside accessToken: "+accessToken);
		if(accessToken.length >0 ){
			var path = "https://graph.facebook.com/me?";
			var queryParams = [accessToken, 'callback=displayUser'];
			var query = queryParams.join('&');
			var url = path + query;
			// use jsonp to call the graph
			var script = document.createElement('script');
			script.src = url;
			document.body.appendChild(script);        
		}
	}
    
	
	var myUser = null;

