/**
* jQuery declaration
*/
(function($)
{
	$.fbCheckUser = function(type)
	{
		$.post("index.php?option=com_account&task=checkFacebook", function(data){

			if(data.flag)
				window.location.reload();
			else
			{
				if(type == 'login' || type == 'register')
					openFaceboxPopup('index.php?option=com_account&view='+type+'&tmpl=popup&fb=0', 'green');
				else
					window.location.reload();
			}
		 }, "json");
	};
 
})(jQuery)

/**
* facebook declaration
*/
fbLogin = function(myPerms, type) {
	FB.login(function(response) {
		if (response.authResponse) {
			jQuery.fbCheckUser(type);
		} else {
		//Vous avez annuler
		}
	}, {scope:myPerms});
}

fbLogout = function(url) {
	FB.logout(function(response) {
		window.location = url;
	})
}
