 function invite_friend(url) { 
           
                FB.getLoginStatus(function (h) {
                    if (h.authResponse) {
                       inviteUserFromFacebook(url);
                    }
					else{
						 FB.login();
					}
				 })
 }
function inviteUserFromFacebook(url) {
            var d = [$(".post_friend_link"), $("#friend_list_holder"), $(".publishToStream"), $(".publishToStatus")],
                e, c = this;
            d[2].unbind("click");
            d[3].unbind("click");
           
				
                d[0].unbind("click").addClass("nonClickable");
                $(".friendpost").addClass("selected");
                d[1].html('<div class="select_friend"><div class="ajax-loader" style="padding-left:10px"><img style="position: relative; top: 3px;" src="'+GLOBAL_ROOT_PATH+'/public/default/frontend/standard/images/fbloader.gif"/> '+lblLoadingfriendlist+'...</div></div>');
                var f = '<div class="select_friend"><label>'+lblFindfriends+' : </label> <input type="text" class="fb_find_friends"/><a class="clear_fb_search" href="javascript:void(0)" style="display: none;">&nbsp; ' + lblClearSearch+'</a></div><div><ul class="friend_list">';
                FB.api("me/friends", {
                    fields: "picture,name"
                }, function (j) {
                    j = j.data;
                    e = j.length;
                    j.sort(sortJsonObj("name", 1, "string"));					
                    for (var g = 0; g < e; g++) {
                        f += '<li id="fb_friendid_' + j[g].id + '"><img class="profile_thumb" alt="' + j[g].name.toLowerCase() + '" id="' + j[g].picture['data'].url + '" width="50" height="50"><label>' + j[g].name + "</label></li>"
                    }
                    f += '</ul><div id="empty_list">'+lblNofriendFound+'</div></div>';
                    d[1].html(f);
                    var h = $(".friend_list");
                    showVisiblePics(h);
                    h.bind("scroll", function () {
                         showVisiblePics(h);
                    });
                    h.children("li").click(function () {
                        var k = $(this).attr("id").substr(12);
                        var i = $(this).children("label").html();
                        postTofriend(k,url);
                    });
                    if (e > 2500) {
                        $(".select_friend").hide()
                    } else {
                        $(".fb_find_friends").bind("keyup", function () {
                            var k = $.trim($(this).val().toLowerCase());
                            if (k != "") {
                                $(".clear_fb_search").show()
                            } else {
                                $(".clear_fb_search").hide()
                            }
                            var i = h.children("li").hide().children("img[alt*='" + k + "']");
                            if (i.length > 0) {
                                i.parent().show();
                                $("#empty_list").hide()
                            } else {
                                $("#empty_list").show()
                            }
                            showVisiblePics(h);
                        });
                        $(".clear_fb_search").click(function () {
                            $(".fb_find_friends").val("").trigger("keyup")
                        })
						if(e > 0){
						 $("#empty_list").hide();}
                    }
                })                     
           
        }
		 function sortJsonObj(f, d, c) {
            var e;
            if (c == "string") {
                e = function (g) {
                    return g.toUpperCase()
                }
            } else {
                if (c == "integer") {
                    e = parseInt
                }
            }
            return function (g, h) {
                g = g[f];
                h = h[f];
                if (typeof (e) != "undefined") {
                    g = e(g);
                    h = e(h)
                }
                return (g < h) ? d * -1 : ((g > h) ? d * 1 : 0)
            }
        }
		function showVisiblePics(d) {
            var c;
            clearTimeout(c);
            c = setTimeout(function () {
                var e = 50,
                    f = d.scrollTop(),
                    g = d.height() + e;					
                d.find("li[class!=loaded]:visible").each(function () {
                    var h = f + $(this).position().top;	
                   // if (h >= (f - e) && h <= (f + g)) {
						
                        var j = $(this).children("img.profile_thumb");
                        j.attr("src", j.attr("id")).removeAttr("id");
                        $(this).addClass("loaded")
                   // }
                })
            }, 50)
        }
		function postTofriend(FRIEND_ID,url) {
        
			 var publish = {
          method: 'feed',
          link: url, 
		  to: FRIEND_ID,
		actions : {
        name : 'View Product',
        link : url
        }
        };
 function callback(response) {		
       
     if (response && response['post_id']) {
       alert(lblPostPublished);
     } else {
       alert(lblPostNotPublished);
     }
   
        }
            FB.ui(publish,callback);
            return false;
      }