function loginFB(extra)
{
    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
                    document.location = 'http://cinefish.bg/fb/fbc.php';
            } else {
                document.location = 'http://cinefish.bg/fb/fbc.php';
            }
          } else {
            // user is not logged in
          }
    }, {scope:'email'});
}

function logout()
{
//	FB.logout(function(response) {
//	  // user is now logged out
//	  document.location = 'http://epicdeals.beu.bg/fb/fbo.php';
//	});
	$(".fb-login").load("/ajax/logout.php");
}
function feed(name, link, pic, caption, desc)
{
   FB.ui(
   {
     method: 'feed',
     name: name,
     link: link,
     picture: pic,
     caption: caption,
     description: desc
   },
   function(response) {
     if (response && response.post_id) {
       //alert('Post was published.');
     } else {
       //alert('Post was not published.');
     }
   }
   );
   
}
function tweet(text, url, via)
{
	$("#offers").focus();
	var winW = 600;
	var winH = 200;
	width = (window.screen.width/2)-(winW/2)-10;
	height = (window.screen.height/2);
	var link = 'http://twitter.com/share/?text='+str_replace(["%", '+', '!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "$", ",", "/", "?",  "#", "[", "]", ' '],['%25','%2B', '%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%24', '%2C', '%2F', '%3F',  '%23', '%5B', '%5D', '+'], text)+'&url='+url+'&via='+via;
	window.open(link, 'popup','width='+winW+',height='+winH+', left='+width+',top='+height)
}


