function fbLoginDialog()
{
	FB.login(function(response)
	{
		if ( response.authResponse )
		{
			if ( response.perms )
			{
				// user is logged in and granted some permissions.
				// perms is a comma separated list of granted permissions
//alert('user is logged in and granted some permissions.');
                    FB.init({appId: '160855423962268', status: true, cookie: true, xfbml: true, oauth: true});
                    FB.getLoginStatus(function(response) {
                        if (response.authResponse) {
                            // logged in and connected user, someone you know
                            document.getElementById('fb_li').value='y';
FB.api('/me', function(user) {
		 if(user.name != undefined) {
jsPost(); 
document.getElementById('fb_id').value=user.id;
document.getElementById('fb_name').value=user.name;
document.getElementById('fb_first_name').value=user.first_name;
document.getElementById('fb_last_name').value=user.last_name;
document.getElementById('fb_locale').value=user.locale;
document.getElementById('fb_em').value=user.email;
document.getElementById('comments_tmp').value= $('comment').value;
document.getElementById('url1_tmp').value= $('url1').value;
document.getElementById('this_url_tmp').value= $('this_url').value;
document.getElementById('fb_id_tmp').value= $('fb_id').value;
document.getElementById('fb_name_tmp').value= $('fb_name').value;
document.getElementById('fb_locale_tmp').value= $('fb_locale').value;
document.getElementById('fb_last_name_tmp').value= $('fb_last_name').value;
document.getElementById('fb_first_name_tmp').value= $('fb_first_name').value;
document.getElementById('fb_em_tmp').value= $('fb_em').value;
document.getElementById('fb_locale_tmp').value= $('fb_locale').value;
var t=setTimeout("jsPost();",50); 
var frm = document.subscribe2;
frm.submit(); 

return false;
  }
else
{
}
		 });

                        } else {
                            // no user session available, someone you dont know
                            document.getElementById('fb_li').value='n';
                        }
                    });
alert('user name = ' + user.name );              
			}
			else
			{
				// user is logged in, but did not grant any permissions
alert('user is logged in, but did not grant any permissions.');
			}
		}
		else
		{
			// user is not logged in
//alert('user is not logged in');
		}
	},{perms:'publish_stream,email,offline_access'});	
}
 
window.fbAsyncInit = function()
{
	FB.init({appId: '160855423962268', status: true, cookie: true, xfbml: true, oauth: true});
	FB.Event.subscribe('auth.login', function(response)
	{
//		alert('LOGIN - reload');
		window.location.reload();
	});
	
	FB.Event.subscribe('auth.logout', function(response)
	{
// 	               alert('LOGOUT - reload');
		window.location.reload();
	});
};

(function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }());

