var share_total = 0; var share_counter = 0; function trim(str, chars) { return ltrim(rtrim(str, chars), chars); } function ltrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); } function rtrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); } function openWindow($url){ var leftvar = (screen.width-700)/2; var topvar = (screen.height-450)/2; $url = trim($url, '/'); viewer = window.open($url, '', 'menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=700,height=450,left='+leftvar+',top='+topvar ); viewer.document.body.style.padding = 0; viewer.document.body.style.margin = 0; viewer.focus(); return false; } function share_click(social_type){ jQuery.post('', {act: 'social_click', social: social_type}); } jQuery(document).ready(function(){ // клик на мэйле jQuery('#share-mmr').click(function(){ //jQuery(this).unbind('click').filter('a').removeAttr('href'); //jQuery('#share-mmr-btn img').attr('src', '/img/social/mmr-disabled.png'); share_click('0'); return openWindow('http://connect.mail.ru/share'); }); // клик на одноклассниках jQuery('#share-ok').click(function(){ //jQuery(this).unbind('click').filter('a').removeAttr('href'); //jQuery('#share-ok-btn img').attr('src', '/img/social/ok-disabled.png'); share_click('1'); return openWindow('http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=0&st._surl='+encodeURI(window.location.href)); }); // клик на вконтакте jQuery('#share-vk').click(function(){ //jQuery(this).unbind('click').filter('a').removeAttr('href'); //jQuery('#share-vk-btn img').attr('src', '/img/social/vk-disabled.png'); share_click('2'); return openWindow('http://vkontakte.ru/share.php?url='+encodeURI(window.location.href)); }); // клик на фэйсбуке jQuery('#share-fb').click(function(){ //jQuery(this).unbind('click').filter('a').removeAttr('href'); //jQuery('#share-fb-btn img').attr('src', '/img/social/fb-disabled.png'); share_click('3'); return openWindow('http://www.facebook.com/sharer.php?u='+encodeURI(window.location.href)); }); // клик на фэйсбуке jQuery('#share-tw').click(function(){ //jQuery(this).unbind('click').filter('a').removeAttr('href'); //jQuery('#share-tw-btn img').attr('src', '/img/social/tw-disabled.png'); share_click('4'); return openWindow('http://twitter.com/share?url='+encodeURI(window.location.href)); }); });