KBB.modules.social=function(){var n,t;return{init:function(){n=this;$(".social[id]").each(this.socialBar.init)},gigyaConfig:{moreEnabledProviders:"linkedIn,digg,reddit,stumbleupon,delicious,tumblr",showEmailButton:!1},socialBar:function(){return{init:function(){var i=$(this),r={},o=i.data("social-buttons"),f=i.data("social-icons-only"),u=i.data("social-show-counts"),s=i.data("social-cid"),h=i.data("social-link")||i.attr("href"),c=i.data("social-title")||i.attr("title"),l=i.data("social-media-url")||i.data("social-image")||i.attr("src"),a=i.data("social-media-type"),v=i.data("social-description"),e=i.data("social-lazy-show");typeof gigya!="undefined"&&(t=gigya.services.socialize);typeof o!="undefined"&&(r.shareButtons=n.socialBar.getCustomButtons(o));typeof f!="undefined"&&(r.iconsOnly=f);typeof u!="undefined"&&(r.showCounts=u==!0?"right":u);typeof h!="undefined"&&(r.link=h);typeof c!="undefined"&&(r.title=c);typeof l!="undefined"&&(r.image=l);typeof a!="undefined"&&(r.mediaType=a);typeof v!="undefined"&&(r.description=v);typeof s!="undefined"&&(r.cid=KBB.helpers.parseTokens(s).toLowerCase(),r.onSendDone=n.socialBar.createOnSendDoneHandler(r.cid,i),r.onShareButtonClicked=n.socialBar.createOnShareButtonClickedHandler(r.cid,i));typeof f!="undefined"&&f||typeof u!="undefined"&&u!=="right"||i.addClass("right-count");typeof e!="undefined"&&(r.onLoad=function(){(e==!0?i:$("#"+e)).show()});i.social(r)},getCustomButtons:function(n){for(var r=n.split(","),u=[],i,t=0;t<r.length;t++)i={provider:r[t]},r[t].toLowerCase()==="share"&&(i.iconImgUp="https://cdns.gigya.com/gs/i/sharebar/icons/share3.png"),r[t].toLowerCase()==="twitter-tweet"&&(i.related="KelleyBlueBook",i.via="KelleyBlueBook"),u.push(i);return u},createOnShareButtonClickedHandler:function(n,t){return function(i){i.shareItem&&i.shareItem.provider&&PartnerLink(i.shareItem.provider,n,"",t)}},createOnSendDoneHandler:function(n,t){return function(r){if(r.providers){var u=r.providers.split(",");for(i=0;i<u.length;i++)PartnerLink(u[i],n+"_confirm","",t)}}}}}(),Providers:{Facebook:"facebook",Twitter:"twitter",Google:"google"},GetCounts:function(n){t&&t.getProviderShareCounts(this.gigyaConfig,{callback:function(t){if(n&&t&&t.errorCode===0&&t.shareCounts)for(var i in t.shareCounts)if(i==n){t=t.shareCounts[i];break}KBB.events.fire("Social.OnGetCountsComplete",t)}})},OnGetCountsComplete:function(n){KBB.events.on("Social.OnGetCountsComplete",n)}}}(),function(n){function t(t,i){if(this.defaults={containerID:t.id,shareButtons:"facebook-like,google-plusone,twitter-tweet,share",iconsOnly:!1,showCounts:"right",cid:"",link:"",title:"",image:"",mediaType:"image",description:"",onSendDone:null,onShareButtonClicked:null},this.opts=n.extend({},this.defaults,i),this.$el=n(t),this._gig=gigya.services.socialize,this._isUserActionDefined=this.opts.link||this.opts.title||this.opts.description||this.opts.image,this.opts.userAction=this._isUserActionDefined?new this._gig.UserAction:KBB.social.openGraphUserAction,!this.opts.userAction){KBB.log("No UserAction defined for Social plugin, please provide at least a link, title, description and/or image. Or, render a KBB.social.openGraphUserAction using Html.RenderGigyaUserAction().");return}this._isUserActionDefined&&(this.opts.link=this.opts.link||self.location,this.opts.title=this.opts.title||document.title,this.opts.userAction.addActionLink(this.opts.title,this.opts.link),this.opts.userAction.setLinkBack(this.opts.link),this.opts.userAction.setTitle(this.opts.title),this.opts.description&&this.opts.userAction.setDescription(this.opts.description),this.opts.image&&this.opts.userAction.addMediaItem({type:this.opts.mediaType,src:this.opts.image,href:this.opts.link}));(this.opts.iconsOnly||this.opts.iconsOnly=="true")&&(typeof i.shareButtons=="undefined"&&(this.opts.shareButtons="facebook,google-plusone,twitter,share"),typeof i.showCounts=="undefined"&&(this.opts.showCounts="none"));typeof i.showCounts!="undefined"&&(this.opts.showCounts=i.showCounts?i.showCounts:"none")}t.prototype={init:function(){var n=this;n.opts.containerID||KBB.log("Social element needs an id");n._gig.showShareBarUI(KBB.modules.social.gigyaConfig,n.opts)}};n.fn.social=function(i){this.length&&this.each(function(){if(typeof gigya!="undefined"){var r=new t(this,i);r.init();n(this).data("social",r)}})}}(jQuery)