!function(e){"use strict";e.fn.essbis=function(t){function s(){e(".essbis").length&&e(".essbis").each(function(){var t=e(this),s=t.find(".essbis-media-wrapper"),i=t.find("img"),o=i.height(),r=i.width(),l=t.find(".essbis-share-box").innerHeight();""!=a.avoid_class?t.addClass(n.generateImageClasses(i.attr("class"))):t.addClass(i.attr("class")),s.css({"max-height":o}),s.css({height:l+50}),s.width(r-80)})}var a=e.extend({selector:"img",dontshow:".dontshow",minWidth:200,minHeight:200,align:{x:"left",y:"top"},offset:{x:0,y:0},orientation:"vertical",style:"flat-small",sharer:"",is_mobile:!1,always_show:!1,pinterest_alt:!1,primary_menu:["facebook","twitter","google","linkedin","pinterest"],avoid_class:""},t),n={existInArray:function(e,t){for(var s=!1,a=0;a<e.length;a++)e[a]==t&&(s=!0);return s},generateImageClasses:function(e){for(var t=a.avoid_class.split(","),s=e.split(" "),i=[],o=0;o<s.length;o++)n.existInArray(t,s[o])||i.push(s[o]);return i.join(" ")},applyClassesFromSharableImage:function(e){if(""==a.avoid_class)return e.attr("class")||"";for(var t=e.attr("class")||"",s=a.avoid_class.split(","),i=t.split(" "),o=[],r=0;r<i.length;r++)n.existInArray(s,i[r])||o.push(i[r]);return o.join(" ")},applyStylesOfShareBar:function(e,t,s){var n,i,o="";["padding-"+a.align.y,"padding-"+a.align.x];if(a.offset.y>0&&(o+="padding-top:"+a.offset.y+"px;"),a.offset.x>0&&(o+="padding-left:"+a.offset.x+"px;"),"right"==a.align.x&&(o+="right:0px;left:auto;"),"center-x"==a.align.x){var r=a.style,l=36;"flat"==r&&(l=48),"box"==r&&(l=24),l*=a.primary_menu.length,n=(t-40-l)/2,i="left",o+=i+":"+n+"px;"}return o},generateShareButtons:function(){for(var e="",t=0;t<a.primary_menu.length;t++){var s=a.primary_menu[t];e+='<span class="essbis-btn essbis-'+s+'-btn" data-network="'+s+'" rel="nofollow">&nbsp;</span>'}return e},shareBox:function(t,s){var i=e(t);return""!==a.dontshow&&i.is(a.dontshow)?!1:i.width()<a.minWidth||i.height()<a.minHeight?!1:i.closest(".essbis").length>0?!1:(i.addClass("essbis-sharable"),i.wrap('<div class="essbis '+(s?" essbis-hover-display":"")+" essbis-display-"+a.orientation+" essbis-template-"+a.style+" "+n.applyClassesFromSharableImage(i)+'"></div>'),void i.after('<div class="essbis-media-wrapper"><div class="essbis-share-box" style="'+n.applyStylesOfShareBar(i,i.width(),i.height())+'">'+n.generateShareButtons()+"</div></div>"))},windowSize:function(e){switch(e){case"twitter":return"height=300,width=800";default:return"height=500,width=800"}},replaceChars:function(e){return e.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,"")},shareData:function(t,s){var i={},o=e(t).closest(".essbis").find(".essbis-sharable");if(i.w_size=n.windowSize(s),i.media=o.data("media")?o.data("media"):o[0].src,i.hash="",i.title=o.data("title")?o.data("title"):o.attr("title")?o.attr("title"):a.title?a.title:document.title,i.summary=o.data("summary")?o.data("summary"):o.attr("alt")?o.attr("alt"):a.summary?a.summary:"",i.local=location.href.replace(/\?img.*$/,"").replace(/\&img.*$/,"").replace(/#.*$/,""),i.schar=-1!=i.local.indexOf("?")?"&":"?",i.link=i.local+i.hash,i.page=a.sharer?a.sharer+"&url="+encodeURIComponent(i.link)+"&img="+i.media.replace("http://","")+"&title="+encodeURIComponent(n.replaceChars(i.title))+"&desc="+encodeURIComponent(n.replaceChars(i.summary))+i.hash:i.local+i.schar+"img="+i.media.replace("http://","")+"&title="+encodeURIComponent(n.replaceChars(i.title))+"&desc="+encodeURIComponent(n.replaceChars(i.summary))+i.hash,i.page2=a.sharer?a.sharer+"&url="+encodeURIComponent(i.link)+"&img="+i.media.replace("http://","")+"&title="+n.replaceChars(i.title)+"&desc="+n.replaceChars(i.summary)+i.hash:i.local+i.schar+"img="+i.media.replace("http://","")+"&title="+n.replaceChars(i.title)+"&desc="+n.replaceChars(i.summary)+i.hash,"undefined"!=typeof essbssu_settings&&a.sharer){var r=essb_self_shorturl("",i.page);""!=r&&(i.page=r);var l=essb_self_shorturl("",i.page2);""!=l&&(i.page2=l)}n.share(s,i)},handleStats:function(e){if("undefined"!=typeof essb_settings&&essb_settings.essb3_stats){var t=essb_settings.post_id||"",s=!1,a="onmedia",n="onmedia";/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(s=!0);var i=!1,o="icon";"undefined"!=typeof essb_settings&&jQuery.post(essb_settings.ajax_url,{action:"essb_stat_log",post_id:t,service:e,template:a,mobile:s,position:n,button:o,counter:i,nonce:essb_settings.essb3_nonce},function(e){},"json")}},share:function(e,t){var s="",i=e;switch(e){case"facebook":s+="http://www.facebook.com/sharer.php?s=100",s+="&p[url]="+encodeURIComponent(t.page);break;case"google":s+="https://plus.google.com/share?",s+="url="+encodeURIComponent(t.page);break;case"linkedin":s+="http://www.linkedin.com/shareArticle?mini=true",s+="&url="+encodeURIComponent(t.page2);break;case"vkontakte":s+="http://vk.com/share.php?",s+="url="+encodeURIComponent(t.link),s+="&title="+encodeURIComponent(t.title),s+="&description="+encodeURIComponent(t.summary),s+="&image="+encodeURIComponent(t.media),s+="&noparse=true",i="vk";break;case"odnoklassniki":s+="http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1",s+="&st.comments="+encodeURIComponent(t.title),s+="&st._surl="+encodeURIComponent(t.page),i="ok";break;case"twitter":var o=a.sharer?t.page:t.link;s+="http://twitter.com/share?",s+="text="+encodeURIComponent(t.title),s+="&url="+encodeURIComponent(o),s+="&counturl="+encodeURIComponent(t.link);break;case"pinterest":var r=t.title;a.pinterest_alt&&""!=t.summary&&(r=t.summary),s+="http://pinterest.com/pin/create/button/?",s+="url="+encodeURIComponent(t.link),s+="&media="+encodeURIComponent(t.media),s+="&description="+encodeURIComponent(r);break;case"tumblr":s+="http://www.tumblr.com/share/photo?",s+="source="+encodeURIComponent(t.media),s+="&caption="+encodeURIComponent(t.summary),s+="&click_thru="+encodeURIComponent(t.link);break;case"reddit":s+="http://reddit.com/submit?",s+="url="+encodeURIComponent(t.link),s+="&title="+encodeURIComponent(t.title),s+="&text="+encodeURIComponent(t.summary);break;case"digg":s+="http://digg.com/submit?phase=2&",s+="url="+encodeURIComponent(t.link),s+="&title="+encodeURIComponent(t.title),s+="&bodytext="+encodeURIComponent(t.summary);break;case"delicious":s+="http://delicious.com/post?",s+="url="+encodeURIComponent(t.link),s+="&title="+encodeURIComponent(t.title)}n.handleStats(i),n.openPopup(s,t.w_size)},openPopup:function(e,t){window.open(e,"essbis_share_window",t+",status=0,toolbar=0,menubar=0,location=1,scrollbars=1")}};a.is_mobile?this.each(function(){n.shareBox(this,!1)}):this.each(function(){n.shareBox(this,!a.always_show)}),e("body").on("click",".essbis-btn",function(t){t.preventDefault(),t.stopPropagation();var s=e(this).data("network");return n.shareData(this,s),!1}),e(window).resize(function(){s()}),s()}}(jQuery);