﻿//function facebook_login_get_permission() {
//	/*if (confirm('This link will take you to a Web site to which this Privacy Policy does not apply. We encourage you to read the Privacy Policy of every Web site you visit.')){*/
//		
//    FB.login(
//    function(response) {
//		if (response.session) {
//			InitiateAsyncRequestHead('true');
//        } else {
//            InitiateAsyncRequestHead('false');
//        }
//    }, {
//        perms: "email,user_birthday,user_location,user_photos,publish_stream"
//    });
///*}*/
//}

function facebook_login_get_permission() {
    if (confirm('This link will take you to a Web site to which this Privacy Policy does not apply. We encourage you to read the Privacy Policy of every Web site you visit.')) {

        FB.login(
    function(response) {
        if (response.session) {
            InitiateAsyncRequestHead('true');
        } else {
            InitiateAsyncRequestHead('false');
        }
    }, {
        perms: "email,user_birthday,user_location,user_photos,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 facebook_login_get_permission() {
	FB.Connect.requireSession(function(){
		FB.Connect.get_status().waitUntilReady(function(status){									   
			FB.Connect.showPermissionDialog("email,publish_stream", function(accepted){
				if(accepted){
				    InitiateAsyncRequestHead('true');
				}else{
					InitiateAsyncRequestHead('false');
					}
				});
		});
	});
}
function ask_for_permissions(permissions) {
	FB.Connect.requireSession(function(){
	    FB.Connect.showPermissionDialog(permissions, InitiateAsyncRequest);
    });
}

function streamPublish(message_title, message_caption, message_description, message_link, hrefTitle, hrefLink, userPrompt, image_src, CallBackfunction) {
    var action_links = [{ 'text': hrefTitle, 'href': hrefLink}];
    var attachment = { 'name': message_title, 
                       'href': message_link, 'caption': message_caption, 'description': message_description,
                       'media': [{ 'type': 'image', 'src': image_src, 'href': message_link}]
                   };
    FB.Connect.streamPublish('', attachment, action_links,null,userPrompt,CallBackfunction);

}
*/

function fbs_click() {
	/*if (confirm('This link will take you to a Web site to which this Privacy Policy does not apply. We encourage you to read the Privacy Policy of every Web site you visit.')){*/
	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;
	/*}*/
}
function sharestory(u,t) {
	/*if (confirm('This link will take you to a Web site to which this Privacy Policy does not apply. We encourage you to read the Privacy Policy of every Web site you visit.')){*/
	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;
	/*}*/
}
function twitter_click() {
	/*if (confirm('This link will take you to a Web site to which this Privacy Policy does not apply. We encourage you to read the Privacy Policy of every Web site you visit.')){*/
	u=location.href;
	t="El Raha ®"
	window.open('http://twitter.com/home?status='+encodeURIComponent(t) + ' ' + encodeURIComponent(u),'sharertwitter','toolbar=0,status=0,width=626,height=436');
	return false;
/*	}*/
}
