/**
 * This file is to use for the social media.
 * Facebook and Google plus
 */

(function ($) {
    "user strict";

    $(document).ready(function () {

        //Facebook
        var facebook_app_id = (facebook.app_id); //From wp_localize_script in functions file.

        window.fbAsyncInit = function () {
            FB.init({
                appId: facebook_app_id,
                xfbml: true,
                version: 'v2.5'
            });
        };

        (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 = "https://connect.facebook.net/en_US/sdk.js";
            fjs.parentNode.insertBefore(js, fjs);
        } (document, 'script', 'facebook-jssdk'));

        //Google Plus
        window.___gcfg = {
            lang: 'en-US',
            parsetags: 'explicit'
        };
        function renderShare() {
            gapi.plus.go(); // Render all the buttons
        }
        (function () {
            var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
            po.src = 'https://apis.google.com/js/plusone.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
        })();
        function getParamBag(url) {
            return {
                action: "share",
                href: url
            };
        }
    });

})( jQuery );