﻿function facebook_login_get_permission() {
    FB.login(
		function(response) {
			if (response.session) {
				InitiateAsyncRequestHead('true');
			} else {
				InitiateAsyncRequestHead('false');
			}
		}, {
			perms: "email,user_birthday,user_location,publish_stream"
    });
}
function ask_for_permissions(permissions) {
	 FB.login(
    function(response) {
        if (response.session) {
            InitiateAsyncRequest('true');
        } else {
            InitiateAsyncRequest('false');
        }
    }, {
        perms: permissions
    });
}

function streamPublish(message_title, message_caption, message_description, message_link, hrefTitle, hrefLink, userPrompt, image_src, CallBackfunction){
	FB.ui(
         {
             method: 'stream.publish',
             message: message_title,
             display: 'dialog',
             attachment: {
                 name: message_title,
                 caption: message_caption,
                 description: (
                    message_description
                   ),
                 href: message_link,
                 media: [{ 'type': 'image', 'href':  hrefLink, 'src':  image_src}] 
             },
             action_links: [
                   { text: hrefTitle, href: hrefLink }
                 ],
                   user_message_prompt: userPrompt
         },
               function(response) {
                   if (response && response.post_id) {
                       alert('Post published successfully.');
                   } else {
                      // alert('Post was not published.');
                   }
               }
             );
}


function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}
