﻿

/*
function repentAndShare() {

    var atch = {
        href: 'http://www.johnnyhollow.com',
        description: post,
        media: [{ type: 'image', src: 'http://www.johnnyhollow.com/imagesProduction/johnnyhollowIcon.jpg', href: 'http://www.johnnyhollow.com'}]
    };

    FB.ui(
        {
            method: 'stream.publish',
            message: 'just read this post on JohnnyHollow.com ...',
            attachment: atch,
            href: 'http://www.johnnyhollow.com'
        },
        function (response) {
            if (response && response.post_id) {
                //success action
            } else {
                //failure action
            }

        }
    );
}
*/


function DisplayTheRepentPrize() {

    if ($.browser.msie) {
        window.location.href = 'http://www.johnnyhollow.com/IEFreeTrack';
    } else {
        $('#facebox .content #RepentPopupContents').hide();
        $('#facebox .content #RepentPrize').show();
    }
}

function PublishToUsersWall(){
    var atch = {
        href: 'http://www.johnnyhollow.com',
        description: post,
        media: [{ type: 'image', src: 'http://www.johnnyhollow.com/imagesProduction/johnnyhollowIcon.jpg', href: 'http://www.johnnyhollow.com'}]
    };

    FB.ui(
        {
            method: 'stream.publish',
            message: 'just read this post on JohnnyHollow.com ...',
            attachment: atch,
            href: 'http://www.johnnyhollow.com'
        },
        function (response) {
            if (response && response.post_id) {
                //success action 

            } else {
                //failure action
            }

        }
    );
}

function RepentAndRecieve(){

    FB.login(function (response) {
        if (response.session) {
            if (response.perms) {
                /*
                user is logged in and granted some permissions.
                perms is a comma separated list of granted permissions
                PublishToUsersWall(); 
                */

                FB.ui(
                    {
                        method: 'stream.share',
                        message: 'Check out this music video by Johnny Hollow ...',
                        u: 'http://www.youtube.com/watch?v=XkeJjdfqMUo',
                        t: 'This Hollow World - Official'
                    },
                        function (response) {

                            DisplayTheRepentPrize();

                            /* //////////// CUSTOM TRACKING Google Analytics Tracking //////// */

                            _gaq.push(['_trackEvent', 'VIDEO_was_SHARED_FB', 'clicked']);

                            /* //////////////// END CUSTOM TRACKING ///////////// */
                        }
                    );

            } else {
                // user is logged in, but did not grant any permissions
                alert('Sorry, the facebook post was not successful :(');
            }

        } else {
            // user is not logged in
            alert('Sorry, the facebook post was not successful :(');
        }
    }, { perms: 'publish_stream' });

}
