// jQuery plugin to render social network sharing links in your web page.
(function ($) {
    $.sharerender = {
        defaults: {
            title: encodeURIComponent(document.title), // document title will be used as default title for sharing,
            url: encodeURIComponent(location), // the href url will be used as default,
            shownetworks: ["facebook", "twitter", "linkedin"], // this network will be rendered by default.
            more: true,
            excludenetworks: null,
            layout: "standard",
            moretext: 'More',
            sharetext: 'Share this',
            native: false,
            linkonly: false, //buttons will be generate with no class, no decoration. you will do it your self.
            twittermessage: "Current Reading", //twitter accepts messages and it is not good to use a title for it. spaces should be replaced by +.
            facebooklanguage: "en_US", //facebook native render language. they can only be one language per page. the format is the same like windows 
            // but instead of dash(-), use underscore (_) : fr_FR, ..etc. check windows
            twitterlanguage: "en", // only short langugage, like en, de,fr
            facebookappid: "", //if you want to receive event when use click like button in native mode, you will need to registry your domain with facebook and have
            // a valid app id from there. enter here your app ID.
            boxpositionclass: "",
            googleplusonesize: "", // standard will be used
            googleplusonelanguage: ""  //English US will be used by default.
        },
        socialSiteAttributes: ["title", "text", "message", "language", "counturl", "size"], //custom attributes for each social site.
        scriptsToRunOnReady: new Array(),
        addscriptobject: function (path, id, callback, jobj, settings, content) {
            var script;
            var scriptFunctions = null;
            var scriptsToRunOnReady = $.sharerender.scriptsToRunOnReady;

            for (var i = 0; i < scriptsToRunOnReady.length; i++) {
                if (scriptsToRunOnReady[i].id == id) {
                    scriptFunctions = scriptsToRunOnReady[i];
                    break;
                }
            }

            if (scriptFunctions == null) {
                scriptFunctions = {}
                scriptFunctions.id = id;
                scriptFunctions.functions = new Array();
                scriptsToRunOnReady[scriptsToRunOnReady.length] = scriptFunctions;
            }


            if (document.getElementById(id) == null) {
                script = document.createElement("script");
                script.type = "text/javascript";
                var fn = {};
                fn.run = callback;
                fn.arg1 = jobj;
                fn.arg2 = settings;
                scriptFunctions.functions[scriptFunctions.functions.length] = fn;

                if (script.readyState) { //IE
                    script.onreadystatechange = function () {
                        if (script.readyState == "loaded" || script.readState == "complete") {
                            script.setAttribute("scriptloadcompleted", 1);
                            script.onreadystatechange = null;
                            var scriptId = script.getAttribute("id");
                            var scriptsToRunOnReady = $.sharerender.scriptsToRunOnReady;
                            var scriptFunctions = null;
                            for (var i = 0; i < scriptsToRunOnReady.length; i++) {
                                if (scriptsToRunOnReady[i].id == scriptId) {
                                    scriptFunctions = scriptsToRunOnReady[i];
                                    break;
                                }
                            }
                            if (scriptFunctions != null) {
                                for (var j = 0; j < scriptFunctions.functions.length; j++) {
                                    var fn = scriptFunctions.functions[j];
                                    if (fn.run != null) {
                                        fn.run(fn.arg1, fn.arg2);
                                    }
                                }
                            }
                        }
                    };
                }
                else { //all others
                    script.onload = function () {
                        script.setAttribute("scriptloadcompleted", "1");
                        script.onreadystatechange = null;
                        var scriptId = script.getAttribute("id");
                        var scriptsToRunOnReady = $.sharerender.scriptsToRunOnReady;
                        var scriptFunctions = null;
                        for (var i = 0; i < scriptsToRunOnReady.length; i++) {
                            if (scriptsToRunOnReady[i].id == scriptId) {
                                scriptFunctions = scriptsToRunOnReady[i];
                                break;
                            }
                        }
                        if (scriptFunctions != null) {
                            for (var j = 0; j < scriptFunctions.functions.length; j++) {
                                var fn = scriptFunctions.functions[j];
                                if (fn.run != null) {
                                    fn.run(fn.arg1, fn.arg2);
                                }
                            }
                        }
                    }
                }

                script.src = path;
                if (content != undefined) {
                    script.text = content;
                }
                script.setAttribute("id", id);
                document.body.appendChild(script);
            }
            else {
                script = document.getElementById(id);
                if (script.getAttribute("scriptloadcompleted") == "1") {
                    if (callback != null) {
                        callback(jobj, settings);
                    }
                }
                else {
                    var fn = {};
                    fn.run = callback;
                    fn.arg1 = jobj;
                    fn.arg2 = settings;
                    scriptFunctions.functions[scriptFunctions.functions.length] = fn;
                }

            }

        },

        eventSubscriptions: new Object(),
        subscribe: function (eventname, fn) {
            $.sharerender.eventSubscriptions[eventname] = fn;
        },

        lastBoxId: 0,
        //private function, don't call.
        raiseevent: function (eventname, arg) {
            var fn = $.sharerender.eventSubscriptions[eventname];
            if (fn != undefined && fn != null) {
                fn(arg);
            }
        },
        //internal function. don't use them.
        renderboxinternal: function (settings, ignoreshowNetworks, jContainer, jInvoker) {
            var socialname;
            var socialSite;

            $.sharerender.lastBoxId += 1;

            var jboxId = "jquery-sharerender-box-" + $.sharerender.lastBoxId;
            var jbox = $("<div></div>").addClass("jquery-sharerender-box").attr("id", jboxId);
            var jboxinner = $("<div></div>").addClass("jquery-sharerender-box-inner");
            var jboxcontent = $('<div></div>').addClass("jquery-sharerender-box-content");
            var url;

            jboxinner.append($('<div class="jquery-sharerender-box-head"><span class="jquery-sharerender-box-head-title">Select a service</span><span class="jquery-sharerender-box-head-space"></span><a jboxId ="{jboxId}" href="#" class="jquery-sharerender-box-close">X</a></div>'.replace("{jboxId}", jboxId)));

            if (settings.boxpositionclass != "") {
                jbox.addClass(settings.boxpositionclass)
                jbox.attr("data-haspositionclass", true);
            }

            var canRender = true;
            //var found = false;

            var socialSites = $.sharerender.socialSites;

            for (var j = 0; j < socialSites.length; j++) {

                canRender = true;
                //found = false;

                socialSite = socialSites[j];
                socialname = socialSite.name.toLowerCase();

                if (socialSite.permanentexclude != undefined) {
                    canRender = !socialSite.permanentexclude;
                }

                if (canRender && !ignoreshowNetworks && settings.shownetworks != null) {
                    for (var i = 0; i < settings.shownetworks.length; i++) {
                        if (jQuery.trim(settings.shownetworks[i].toLowerCase()) == socialname) {
                            canRender = false;
                            break;
                        }
                    }
                }

                if (canRender && settings.excludenetworks != null) {
                    for (var i = 0; i < settings.excludenetworks.length; i++) {
                        if (jQuery.trim(settings.excludenetworks[i].toLowerCase()) == socialname) {
                            canRender = false;
                            break;
                        }
                    }
                }


                if (canRender) {

                    var properties = $.sharerender.buildcommonproperties(socialSite, settings);
                    var jdivItem = $("<div></div>").addClass("jquery-sharerender-box-content-item");
                    jdivItem.append($("<span><span>").addClass("jquery-sharerender-span-link-16").addClass(socialSite.class16).html(socialSite.friendname));
                    jdivItem.hover(function () { $(this).addClass("jquery-sharerender-box-content-item-hover"); }, function () { $(this).removeClass("jquery-sharerender-box-content-item-hover"); });

                    jdivItem.attr("data-sharelink", properties.sharelink);
                    jdivItem.attr("data-title", settings.title);
                    jdivItem.attr("data-url", settings.url);
                    jdivItem.attr("data-network", socialSite.name);
                    jdivItem.click(function () {
                        var sharelink = $(this).attr("data-sharelink");
                        var sharetitle = $(this).attr("data-title");
                        var shareurl = $(this).attr("data-url");
                        var sharenetwork = $(this).attr("data-network");
                        window.open(sharelink, "_blank", "width=700,height=700,resizable=yes,scrollbars=yes");
                        $.sharerender.raiseevent("onshare", { sharelink: sharelink, sharetitle: sharetitle, shareurl: shareurl, sharenetwork: sharenetwork });
                        return false;
                    });
                    jboxcontent.append(jdivItem);
                }
            }


            jboxcontent.append($("<div style='clear: both;'></div>"));
            jboxinner.append(jboxcontent);
            jbox.append(jboxinner);
            jContainer.append(jbox);
            jbox.find("a.jquery-sharerender-box-close").click(function () { $("#" + $(this).attr("jboxId")).hide().removeClass("hover").removeClass("hover2"); return false; });

            jInvoker.attr("jboxId", jboxId);
            jInvoker.click(function () { return false });
            jInvoker.hover(function () {

                var vtop = $(this).offset().top + 16;
                var vleft = $(this).offset().left + 16;
                var jbox = $("#" + $(this).attr("jboxId"));
                var haspositionclass = jbox.attr("data-haspositionclass");
                if (haspositionclass == "true") {
                    jbox.show().addClass("hover");
                }
                else {
                    jbox.show().offset({ top: vtop, left: vleft }).addClass("hover");
                }

            },
            function () {
                var jbox = $("#" + $(this).attr("jboxId"));
                jbox.removeClass("hover");
                if (!jbox.delay(200).hasClass("hover2")) {
                    jbox.hide();
                }
            }
            );


            jbox.mouseenter(function () {
                $(this).addClass("hover2");
            }).mouseleave(function () {
                $(this).remove("hover2").delay(200);
                if (!$(this).hasClass("hover")) {
                    $(this).hide();
                }

            });
        },
        buildcommonproperties: function (socialSite, settings) {
            var atitlet = "{socialSite}title";
            var aTextt = "{socialSite}text";
            var amessaget = "{socialSite}message";
            var alangt = "{socialSite}language";
            var aurlcountt = "{socialSite}counturl";
            var aTextAtt = aTextt.replace("{socialSite}", socialSite.name.replace("-", ""));
            var aTitleAtt = atitlet.replace("{socialSite}", socialSite.name.replace("-", ""));
            var aMessageAtt = amessaget.replace("{socialSite}", socialSite.name.replace("-", ""));
            var alangAtt = alangt.replace("{socialSite}", socialSite.name.replace("-", ""));
            var acounturlAtt = aurlcountt.replace("{socialSite}", socialSite.name.replace("-", ""));

            var aText;
            var aTitle;
            var aMessage;
            var alang;
            var acounturl;

            if (settings[aTextAtt] != undefined) {
                aText = settings[aTextAtt];
            }
            else {
                aText = socialSite.friendname;
            }

            if (settings[aTitleAtt] != undefined) {
                aTitle = settings[aTitleAtt];
            }
            else {
                aTitle = socialSite.anchortitle;
            }

            if (settings[aMessageAtt] != undefined) {
                aMessage = settings[aMessageAtt];
            }
            else {
                aMessage = "";
            }

            if (settings[alangAtt] != undefined) {
                alang = settings[alangAtt];
            }
            else {
                alang = "";
            }

            if (settings[acounturlAtt] != undefined) {
                acounturl = settings[acounturlAtt];
            }
            else {
                acounturl = "";
            }
            var sharelink = socialSite.urltemplate.replace("{url}", encodeURIComponent(settings.url)).replace("{title}", encodeURIComponent(settings.title)).replace("{message}", encodeURIComponent(aMessage)).replace("{lang}", alang).replace("{counturl}", encodeURIComponent(acounturl));
            var properties = {};
            properties.text = aText;
            properties.title = aTitle;
            properties.message = aMessage;
            properties.lang = alang;
            properties.counturl = acounturl;
            properties.sharelink = sharelink;
            return properties;
        },
        //internal functions. don't call them
        renderstandard: function (settings) {
            var socialname;
            var socialSite;


            var jdiv;


            jdiv = $('<div></div>').addClass('jquery-sharerender-standard');

            var socialSites = $.sharerender.socialSites;


            for (var i = 0; i < settings.shownetworks.length; i++) {
                socialname = jQuery.trim(settings.shownetworks[i].toLowerCase());
                socialSite = null;


                for (var j = 0; j < socialSites.length; j++) {
                    if (socialSites[j].name.toLowerCase() == socialname) {
                        socialSite = socialSites[j];
                        break;
                    }

                }

                if (socialSite != null) {

                    var properties = $.sharerender.buildcommonproperties(socialSite, settings);

                    if (!settings.native && properties.sharelink != "") {
                        var ja = $("<a></a>").attr("title", properties.title).attr("href", "#");
                        var sharelink = properties.sharelink;

                        ja.attr("data-sharelink", sharelink);
                        ja.attr("data-title", settings.title);
                        ja.attr("data-url", settings.url);
                        ja.attr("data-network", socialSite.name);
                        ja.click(function () {
                            var sharelink = $(this).attr("data-sharelink");
                            var sharetitle = $(this).attr("data-title");
                            var shareurl = $(this).attr("data-url");
                            var sharenetwork = $(this).attr("data-network");
                            window.open(sharelink, "_blank", "width=700,height=700,resizable=yes,scrollbars=yes");
                            $.sharerender.raiseevent("onshare", { sharelink: sharelink, sharetitle: sharetitle, shareurl: shareurl, sharenetwork: sharenetwork });
                            return false;
                        });

                        if (!settings.linkonly) {
                            ja.append($("<span></span>").addClass("jquery-sharerender-span-link-32").addClass(socialSite.class32));
                            jdiv.append(ja);
                        }
                        else {
                            ja.append(properties.text);
                            this.append(ja);
                        }
                    }
                    else {
                        if (!settings.linkonly) {
                            var jspan = $("<span></span>").addClass("jquery-sharerender-span-native");
                            socialSite.rendernative(settings, jspan);
                            jdiv.append(jspan);
                            jdiv.append($("<spand>&nbsp;&nbsp;<span>"));
                        }
                        else {
                            socialSite.rendernative(settings, this);
                        }
                    }
                }
            }

            if (!settings.linkonly) {
                if (settings.more == true) {
                    if (!settings.native) {
                        var jam = $("<a></a>").attr("title", "More services").attr("href", "#");
                        var jamspan = $("<span></span>").html(settings.moretext).addClass("jquery-sharerender-span-link-32").addClass("jquery-sharerender-more");
                        jam.append(jamspan);
                        jdiv.append(jam);
                        $.sharerender.renderboxinternal(settings, false, jdiv, jamspan);
                    }
                    else {
                        var jam = $("<a></a>").attr("title", "More services").attr("href", "#");
                        var jamspan = $("<span></span>").html(settings.moretext).addClass("jquery-sharerender-span-native");
                        jam.append(jamspan);
                        $.sharerender.renderboxinternal(settings, false, jdiv, jamspan);
                    }
                }
                this.append(jdiv);
            }
        },

        //internal function. don't use them
        renderbox: function (settings) {
            this.empty();

            var jam = $("<a></a>").attr("title", "Services").attr("href", "#").addClass("jquery-sharerender-share");
            jam.append($("<span></span>").html(settings.sharetext));
            this.append(jam);
            $.sharerender.renderboxinternal(settings, true, this, jam);
        },

        //ONLY PUBLIC METHOD. can be called but use the declarative option as much as possible. see help.
        render: function (user_settings) {

            // Merge user settings with default
            var settings
            if (user_settings) {
                settings = $.extend({}, $.sharerender.defaults, user_settings);
            }
            else {
                settings = $.sharerender.defaults;
            }
            switch (settings.layout.toLowerCase()) {
                case "box":
                    $.sharerender.renderbox.call(this, settings);
                    break;
                default:
                    $.sharerender.renderstandard.call(this, settings);
            }

        },
        // The list of social networks . it can be extended easily.
        socialSites: [{
            name: "facebook-send",
            friendname: "facebook",
            class32: "jquery-sharerender-facebook-32",
            class16: "jquery-sharerender-facebook-16",
            anchortitle: "Share with facebook",
            permanentexclude: true,
            urltemplate: "http://www.facebook.com/sharer.php?u={url}&t={title}",
            rendernative: function (socialSettings, jObj) {
                var fbjs = 'http://connect.facebook.net/{lang}/all.js#xfbml=1';
                var fbBt = '<fb:send href="{url}"></fb:send>';
                var fbB = fbBt.replace('{url}', socialSettings.url);
                var jfB = $(fbB);
                jObj.append(jfB);
                fbjs = fbjs.replace("{lang}", socialSettings.facebooklanguage);

                $.sharerender.addscriptobject(fbjs, "facebook-framework-js", function (jObj, socialSettings) {
                    FB.XFBML.parse(jObj.get(0));
                    FB.init({
                        appId: socialSettings.facebookappid,
                        status: true, // check login status
                        cookie: true, // enable cookies to allow the server to access the session
                        xfbml: true  // parse XFBML
                    });

                    FB.Event.subscribe('edge.create', function (response) {
                        $.sharerender.raiseevent('onshare', { sharelink: "", sharetitle: socialSettings.title, shareurl: socialSettings.url, sharenetwork: "facebook-send" });
                    });
                }, jObj, socialSettings);
            }
        },
        {
            name: "facebook-like",
            friendname: "facebook",
            class32: "jquery-sharerender-facebook-32",
            class16: "jquery-sharerender-facebook-16",
            anchortitle: "Share with facebook",
            permanentexclude: true,
            urltemplate: "http://www.facebook.com/sharer.php?u={url}&t={title}",
            rendernative: function (socialSettings, jObj) {
                var fbjs = 'http://connect.facebook.net/{lang}/all.js#xfbml=1';
                var fbBt = '<fb:like href="{url}" send="false" layout="button_count" width="100" show_faces="false" font=""></fb:like>';
                var fbB = fbBt.replace('{url}', socialSettings.url);
                var jfB = $(fbB);
                jObj.append(jfB);

                fbjs = fbjs.replace("{lang}", socialSettings.facebooklanguage);

                $.sharerender.addscriptobject(fbjs, "facebook-framework-js", function (jObj, socialSettings) {
                    FB.XFBML.parse(jObj.get(0));
                    FB.init({
                        appId: socialSettings.facebookappid,
                        status: true, // check login status
                        cookie: true, // enable cookies to allow the server to access the session
                        xfbml: true  // parse XFBML
                    });

                    FB.Event.subscribe('edge.create', function (response) {
                        $.sharerender.raiseevent('onshare', { sharelink: "", sharetitle: socialSettings.title, shareurl: socialSettings.url, sharenetwork: "facebook-like" });
                    });


                }, jObj, socialSettings);
            }
        },
        {
            name: "facebook",
            friendname: "facebook",
            class32: "jquery-sharerender-facebook-32",
            class16: "jquery-sharerender-facebook-16",
            anchortitle: "Share with facebook",
            urltemplate: "http://www.facebook.com/sharer.php?u={url}&t={title}",
            rendernative: function (socialSettings, jObj) {
                var fbjs = 'http://connect.facebook.net/{lang}/all.js#xfbml=1';
                var fbBt = '<fb:like href="{url}" send="true" layout="button_count" width="100" show_faces="false" font=""></fb:like>';
                var fbB = fbBt.replace('{url}', socialSettings.url);
                var jfB = $(fbB);
                jObj.append(jfB);

                fbjs = fbjs.replace("{lang}", socialSettings.facebooklanguage);

                $.sharerender.addscriptobject(fbjs, "facebook-framework-js", function (jObj, socialSettings) {
                    FB.XFBML.parse(jObj.get(0));
                    FB.init({
                        appId: socialSettings.facebookappid,
                        status: true, // check login status
                        cookie: true, // enable cookies to allow the server to access the session
                        xfbml: true  // parse XFBML
                    });

                    FB.Event.subscribe('edge.create', function (response) {
                        $.sharerender.raiseevent('onshare', { sharelink: "", sharetitle: socialSettings.title, shareurl: socialSettings.url, sharenetwork: "facebook" });
                    });


                }, jObj, socialSettings);
            }
        },
      {
          name: 'twitter',
          friendname: 'twitter',
          class32: "jquery-sharerender-twitter-32",
          class16: "jquery-sharerender-twitter-16",
          anchortitle: "Tweet This",
          urltemplate: "http://twitter.com/share?url={url}&text={message}&lang={lang}&counturl={counturl}", // "http://twitter.com/home?status={message}+{url}"
          rendernative: function (socialSettings, jObj) {
              var ttjs = 'http://platform.twitter.com/widgets.js';
              var ttbtt = '<a href="http://twitter.com/share" class="twitter-share-button" data-url="{url}" data-text="{message}" data-count="none" data-lang="{lang}" data-counturl="{counturl}">{text}</a>';
              var ttbt = ttbtt.replace('{url}', socialSettings.url);
              ttbt = ttbt.replace('{message}', socialSettings.twittermessage);
              ttbt = ttbt.replace("{lang}", socialSettings.twitterlanguage);


              if (socialSettings.twittertext) {
                  ttbt = ttbt.replace('{text}', socialSettings.twittertext);
              }
              else {
                  ttbt = ttbt.replace("{text}", "tweet");
              }
              var jres = $(ttbt)
              jObj.append(ttbt);
              $.sharerender.addscriptobject(ttjs, "twitter-framework-js", function (jObj, socialSettings) {
                  jObj.find('a.twitter-share-button').each(function () {
                      var tweet_button = new twttr.TweetButton($(this).get(0));
                      tweet_button.render();
                  });
              }, jObj, socialSettings);
          }
      },
      {
          name: 'linkedin',
          friendname: 'linkedin',
          class32: "jquery-sharerender-inshare-32",
          class16: "jquery-sharerender-inshare-16",
          anchortitle: "InShare This",
          urltemplate: "http://www.linkedin.com/shareArticle?mini=true&url={url}&title={title}",
          rendernative: function (socialSettings, jObj) {
              var lijs = 'http://platform.linkedin.com/in.js'
              var script = document.createElement("script");
              script.type = "in/share";
              script.setAttribute("data-url", socialSettings.url);
              script.setAttribute("data-title", socialSettings.title);
              jObj.get(0).appendChild(script);

              $.sharerender.addscriptobject(lijs, "linkedin-framework-js", function (jObj, socialSettings) {
              }, jObj, socialSettings);
          }
      }
      ,
      {
          // Google buzz
          name: 'google-buzz',
          friendname: 'google buzz',
          class32: "jquery-sharerender-google-buzz-32",
          class16: "jquery-sharerender-google-buzz-16",
          anchortitle: "Buzz This",
          urltemplate: "http://www.google.com/buzz/post?message={message}&url={url}",
          rendernative: function (socialSettings, jObj) {
              var gjs = 'http://www.google.com/buzz/api/button.js'
              var gbtt = '<a title="{title}" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="small-button" data-url="{url}" data-message="{message}"></a>'
              var gbt = gbtt.replace("{url}", socialSettings.url);
              var aTitle = "Post to Google Buzz";
              var message = "";
              if (socialSettings.googlebuzztitle) {
                  aTitle = socialSettings.googlebuzztitle;
              }

              if (socialSettings.googlebuzzmessage) {
                  message = socialSettings.googlebuzzmessage;
              }

              //gbt = gbt.replace("{title}", socialSettings.title);
              gbt = gbt.replace("{title}", aTitle);
              gbt = gbt.replace("{message}", message);

              jObj.append(gbt);
              $.sharerender.addscriptobject(gjs, "google-framework-js", function () {

              }, jObj, socialSettings);

          }
      },
       {
           // Google bookmark
           name: 'google-bookmark',
           friendname: 'google bookmark',
           class32: "jquery-sharerender-google-32",
           class16: "jquery-sharerender-google-16",
           anchortitle: "Add to google bookmark",
           urltemplate: "http://google.com/bookmarks/mark?op=edit&bkmk={url}&title={title}",
           rendernative: function (socialSettings, jObj) {
           }
       }
      ,
        //google plusone
      {
      name: 'google-plusone',
      friendname: 'google +1',
      class32: '',
      class16: '',
      anchortitle: '+1 this',
      permanentexclude: true,
      urltemplate: '',
      rendernative: function (socialSettings, jObj) {
          var gplusonejs = 'http://apis.google.com/js/plusone.js';
          var gplusonebtt = '<g:plusone count="false" href="{url}" size="{size}"></g:plusone>';
          var gplusonebt = gplusonebtt.replace("{url}", socialSettings.url);

          gplusonebt = gplusonebt.replace("{size}", socialSettings.googleplusonesize);
          var scriptcontent = "{parsetags: 'explicit'";

          if (socialSettings.googleplusonelanguage != "") {
              scriptcontent = scriptcontent + "   lang: '" + socialSettings.googleplusonelanguage + "'";
          }
          scriptcontent = scriptcontent + "}";
          jObj.append(gplusonebt);

          $.sharerender.addscriptobject(gplusonejs, "google-plusone-js", function (jObj, socialSettings) {
              gapi.plusone.go(jObj.get(0));
          }, jObj, socialSettings, scriptcontent);

          //          <script type="text/javascript" src="http://apis.google.com/js/plusone.js">
          //                {lang: 'fr', parsetags: 'explicit'}
          //          </script>


      }

  },
        // delicious
      {
      name: 'delicious',
      friendname: 'delicious',
      class32: "jquery-sharerender-delicious-32",
      class16: "jquery-sharerender-delicious-16",
      anchortitle: "Delicious bookmark",
      urltemplate: "http://del.icio.us/post?url={url}&title={title}",
      rendernative: function (socialSettings, jObj) {

      }
  },

        // Digg
      {
      name: 'digg',
      friendname: 'digg',
      class32: "jquery-sharerender-digg-32",
      class16: "jquery-sharerender-digg-16",
      anchortitle: "Digg This",
      urltemplate: "http://digg.com/submit?phase=2&url={url}&title={title}",
      rendernative: function (socialSettings, jObj) {

      }
  }]
    };

    $.fn.sharerender = $.sharerender.render;

    $(function () {
        $(".jquery-sharerender").each(function () {
            var user_settings = {};
            if ($(this).attr("data-title") != undefined) {
                if ($(this).attr("data-title").length > 0) {
                    user_settings['title'] = $(this).attr("data-title");
                }
            }

            if ($(this).attr("data-url") != undefined) {
                if ($(this).attr("data-url").length > 0) {
                    user_settings['url'] = $(this).attr("data-url");
                }
            }

            if ($(this).attr("data-shownetworks") != undefined) {
                if ($(this).attr("data-shownetworks").length > 0) {
                    user_settings['shownetworks'] = $(this).attr("data-shownetworks").split(",");
                }
            }

            if ($(this).attr("data-excludenetworks") != undefined) {
                if ($(this).attr("data-excludenetworks").length > 0) {
                    user_settings['excludenetworks'] = $(this).attr("data-excludenetworks").split(",");
                }
            }

            if ($(this).attr("data-more") != undefined) {
                if ($(this).attr("data-more").length > 0) {
                    if ($(this).attr("data-more") == "false") {
                        user_settings['more'] = false;
                    }
                    else {
                        user_settings['more'] = true;
                    }
                }
            }

            if ($(this).attr("data-layout") != undefined) {
                if ($(this).attr("data-layout").length > 0) {
                    user_settings['layout'] = $(this).attr("data-layout");
                }
            }

            if ($(this).attr("data-moretext") != undefined) {
                if ($(this).attr("data-moretext").length > 0) {
                    user_settings['moretext'] = $(this).attr("data-moretext");
                }
            }

            if ($(this).attr("data-sharetext") != undefined) {
                if ($(this).attr("data-sharetext").length > 0) {
                    user_settings['sharetext'] = $(this).attr("data-sharetext");
                }
            }

            if ($(this).attr("data-native") != undefined) {
                if ($(this).attr("data-native").length > 0) {
                    if ($(this).attr("data-native") == "true") {
                        user_settings['native'] = true;
                    }
                    else {
                        user_settings['native'] = false;
                    }

                }
            }

            if ($(this).attr("data-boxpositionclass") != undefined) {
                if ($(this).attr("data-boxpositionclass").length > 0) {
                    user_settings['boxpositionclass'] = $(this).attr("data-boxpositionclass");
                }
            }

            if ($(this).attr("data-linkonly") != undefined) {
                if ($(this).attr("data-linkonly").length > 0) {
                    if ($(this).attr("data-linkonly") == "true") {
                        user_settings['linkonly'] = true;
                    }
                    else {
                        user_settings['linkonly'] = false;
                    }

                }
            }
            var socialSites = $.sharerender.socialSites;

            var socialSiteAttributes = $.sharerender.socialSiteAttributes;
            var attrnametemplate = "data-{socialSite}-{attr}";
            var propertynametemplate = "{socialSite}{attr}";

            for (var j = 0; j < socialSites.length; j++) {
                var socialSite = $.sharerender.socialSites[j];
                for (var i = 0; i < socialSiteAttributes.length; i++) {
                    var attn = socialSiteAttributes[i];
                    var attName = attrnametemplate.replace("{socialSite}", socialSite.name).replace("{attr}", attn);
                    var propertyname = propertynametemplate.replace("{socialSite}", socialSite.name).replace("{attr}", attn).replace("-", "");

                    if ($(this).attr(attName) != undefined) {
                        if ($(this).attr(attName).length > 0) {
                            user_settings[propertyname] = $(this).attr(attName);
                        }
                    }
                }

                if ($(this).hasClass(socialSite.name)) {
                    user_settings['more'] = false;
                    user_settings['layout'] = "standard";
                    user_settings['shownetworks'] = [socialSite.name];
                    user_settings['linkonly'] = true;
                }

            }

            $(this).sharerender(user_settings);
        });
    });
}
)(jQuery);

