window.fbAsyncInit = function() {
    // Don't use my app id, use your own or it won't work!
    FB.init({ appId: '162998590435195', status: true, cookie: true, xfbml: true, oauth: true });
    FB.Event.subscribe('edge.create', function(href, widget) {
        // Do something, e.g. track the click on the "Like" button here
        postToFeed();
        setLikedCookie();
        $('#fade , .popup_block').fadeOut(); //fade them both out
        $('#fade').remove();
        return false;
    });
};

function postToFeed() {

    // calling the API ...
    var obj = {
        method: 'feed',
        link: 'https://www.facebook.com/yourdatingguru',
        picture: 'http://www.bepenfriends.com/penpals/images/1top.jpg',
        name: 'Stay connected with your friends',
        caption: 'Get insightful tips on having sucessful dating',
        description: 'Join yourdatingguru for more...'
    };
    function callback(response) {
    }
    FB.ui(obj, callback);
}

(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) { return; }
    js = d.createElement(s); js.id = id;
    js.src = document.location.protocol + "//connect.facebook.net/en_US/all.js#xfbml=1&appId=162998590435195";
    fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
