
(function($){

var settings;
$.fn.social = function(settings) {
  settings = $.extend({
    imgSprite: '/include/images/social.gif',
    imgMargin: 3,
    bgStyle:"#eeeeee",
    fontSize:"9pt",
    text: 'Максимальное количество символов: '
  }, settings);

  var thisElem = $(this);
  var socialArr = new Array('soc-sG', 'soc-sB', 'soc-sF', 'soc-sT', 'soc-sY', 'soc-sM', 'soc-sL', 'soc-sO');
  var socialArrNames = new Array('Google', 'Google Живая лента', 'Facebook', 'Twitter', 'Яндекс', 'Mой мир', 'Живой журнал', 'Одноклассники');
  var wrap = $('<div/>').css({width:(socialArr.length*(16+settings.imgMargin))-(16+settings.imgMargin)+'px',height:'16px',display:'inline',position:'relative'});
  thisElem.append(wrap);
  
  for (var i=0;i<socialArr.length; i++) {
    socialArr[i] = $('<a target="_blank" id="'+socialArr[i]+'" title="Добавить в '+socialArrNames[i]+'"/>').css({float:'left',marginRight:settings.imgMargin+'px',width:'16px',height:'16px',display:'block',backgroundImage:'url('+settings.imgSprite+')', backgroundRepeat:'no-repeat', backgroundPosition:'-'+(i*16)+'px 0'})
    .attr('href', '');
    if(i!=1) wrap.append(socialArr[i]);
  }
  
  $('#soc-sG').attr('href', 'http://www.google.com/bookmarks/mark?op=add&bkmk='+escape(document.URL)+'&title='+encodeURIComponent(document.title));
  //$('#soc-sB').attr('href', 'http://www.google.com/buzz/post?data-locale=ru&url='+encodeURIComponent(document.URL));
  $('#soc-sF').attr('href', 'http://www.facebook.com/sharer.php?u='+escape(document.URL)+'&t='+encodeURIComponent(document.title));
  $('#soc-sT').attr('href', 'http://twitter.com/home?status='+escape(document.URL)+' '+encodeURIComponent(document.title));
  $('#soc-sY').attr('href', 'http://my.ya.ru/posts_add_link.xml?title='+encodeURIComponent(document.title)+'&URL='+escape(document.URL));
  $('#soc-sM').attr('href', 'http://connect.mail.ru/share?share_url='+escape(document.URL));
  $('#soc-sL').attr('href', 'http://www.livejournal.com/update.bml?subject='+encodeURIComponent(document.title)+'&event='+escape(document.URL));
  $('#soc-sO').attr('href', document.URL).click(function(){ ODKL.Share(this); return false; });

};
})(jQuery);
