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 ="<div style='float:left;padding-top:8px; vertical-align:bottom' class='txt_gray_short'><fb:name uid='loggedinuser' useyou='false'></fb:name>.  <br><span onClick='myPopup()' style='cursor:pointer' >Invite Friends</span><br><span style='cursor:pointer' onclick='FB.Connect.logout(function() { refresh_page(); })'>Logout of Facebook</span></div><div style='float:left;padding-left:5px;vertical-align:bottom '><fb:profile-pic uid='loggedinuser' facebook-logo='true'></fb:profile-pic></div>";
   

  // because this is XFBML, we need to tell Facebook to re-process the document 
  FB.XFBML.Host.parseDomTree();
}


     
	
	 
	function update_box() { 
	
	var api_key = '1e66f985153e491d48039f7dc0e0633d';
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;
	
	///alert("dsad"+api.get_session().uid);
    // require user to login 
    api.requireLogin(function(exception){
        //FB.FBDebug.logLevel=1;
        //FB.FBDebug.dump("Current user id is " + api.get_session().uid);
        // Get friends list 
        
		
		//alert(api.get_session().uid);
		FB.Connect.showPermissionDialog("email",function (status){
				    
					var resp = {};
					
					if(status){
						
						window.location="facebook.html?uid="+api.get_session().uid;
				       /* allowed = status.split(',');
				        
						for(i=0; i<allowed.length; i++){
				            resp[allowed[i]] = true;
				        }*/
				    }
					else
					{
						window.location="facebook.html?uid="+api.get_session().uid;	
					}
					
					});
				    // update us so we dont prompt for it anymore
				  /*  $.post('/user/update_facebook_extended_access', resp, function(resp, _status){
						// now lets check login stuff
						api.check_login();
				    },'json');*/
					
					
					
		
       
	   
	   
	   


         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();
		  
		  // otherwise, refresh to pick up the state change
          //refresh_page();
        });
    });
}
	 
	   function myPopup() {
window.open( "invite.php", "myWindow", 
"status = 1, height = 700, width = 800, resizable = 0" )
}

function refresh_page() {
  window.location = 'http://www.deptheye.com/';
}
