function update_user_box() {


  var user_box = document.getElementById("user");

  // add in some XFBML. note that we set useyou=false so it doesn't display "you";
  
//  To extend permission <fb:prompt-permission perms='email'>Send Login details</fb:prompt-permission><br>
 user_box.innerHTML ="<table width='50%' ><tr><td ><fb:name uid='loggedinuser' useyou='false'></fb:name><br><a href='#' onclick='FB.Connect.logout(function() { refresh_page(); })'>Logout of Facebook</a></td><td><fb:profile-pic uid='loggedinuser' facebook-logo='true' ></fb:profile-pic></td></tr></table>";
   

  // because this is XFBML, we need to tell Facebook to re-process the document 
  FB.XFBML.Host.parseDomTree();
}



     
	
	
	
	
	function update_box() { 
	

	var api_key = '2aabf45402979b3a559661bce1cdb40b';
var channel_path = 'xd_receiver.htm';

FB_RequireFeatures(["Api"], function(){
    // Create an ApiClient object, passing app's API key and 
    // a site relative URL to xd_receiver.htm
    FB.Facebook.init(api_key, channel_path);
    
    var api = FB.Facebook.apiClient;
	
	    api.requireLogin(function(exception){
   
		FB.Connect.showPermissionDialog("email",function (status){
				    
					var resp = {};
					
					
					
					if(status){
						
                   pub();
				      
				    }
					else{
						
					pub();
					
					}
					
					
					});
			


         api.friends_get(new Array(), function(result, exception){
              FB.FBDebug.dump(result, 'friendsResult from non-batch execution ');
         });
    });
});
	
	
	}
		
	
	
	
	
	
	
	
	
	 
	 
	 function pub() { 
	
var api_key = '2aabf45402979b3a559661bce1cdb40b';
var channel_path = 'xd_receiver.htm';

FB_RequireFeatures(["Api"], function(){
    // Create an ApiClient object, passing app's API key and 
    // a site relative URL to xd_receiver.htm
    FB.Facebook.init(api_key, channel_path);
    
    var api = FB.Facebook.apiClient;
	
	    api.requireLogin(function(exception){
   
		FB.Connect.showPermissionDialog("publish_stream",function (status){
				    
					var resp = {};
					
					if(status){
						
                    
					window.location="/facebook.php?m=y";
					
				      
				    }
					else{
						
					window.location="/facebook.php?m=y";
					
					
					}
					
					
					});
			


         api.friends_get(new Array(), function(result, exception){
              FB.FBDebug.dump(result, 'friendsResult from non-batch execution ');
         });
    });
});
	
	
	}
	
	
	
	

	
	 
	 
	 
	 function facebook_onload(already_logged_into_facebook) {
  // user state is either: has a session, or does not.
  // if the state has changed, detect that and reload.
  FB.ensureInit(function() {
      FB.Facebook.get_sessionState().waitUntilReady(function(session) {
          var is_now_logged_into_facebook = session ? true : false;

          // if the new state is the same as the old (i.e., nothing changed)
          // then do nothing
          /*if (is_now_logged_into_facebook == already_logged_into_facebook) {
			  
			  alert("yes");
            return;
          }*/

          if(is_now_logged_into_facebook==true){
		  //update_user_box();
		  update_user_box();
		  //window.location="/facebook.php";
		  }
		  
		  
		  // otherwise, refresh to pick up the state change
          //refresh_page();
        });
    });
}


	 
	  
	 function flogout() {
		 
		 alert("Now loggingout from facebook");
		 
  FB.init("2aabf45402979b3a559661bce1cdb40b", "/fjs/xd_receiver.htm");
   FB.Connect.logout(function() { refresh_page(); });
};

	  

function refresh_page() {
  window.location = 'http://www.ekaty.com/member_login.php';
}
