(function( $ ) {
  $(document).ready(function() { 
  
	function e(s){s = s.replace(/\r\n/g,"\n");
	var u="";
	for(var n=0;n<s.length;n++){var c = s.charCodeAt(n);
	if(c<128){u+=String.fromCharCode(c);
	}else if((c>127)&&(c<2048)){
	u+=String.fromCharCode((c>>6)|192);
	u+=String.fromCharCode((c&63)|128);
	}else{
	u+=String.fromCharCode((c>>12)|224);
	u+=String.fromCharCode(((c>>6)&63)|128);
	u+=String.fromCharCode((c&63)|128);
	}}return u;
	}
	var url=encodeURIComponent(document.location);
	var title=escape(e(document.title));
	var host =  window.location.hostname;
	
	var facebook = 'http://www.facebook.com/sharer.php?u='+url;
	var twit = 'http://twitter.com/home?status='+title+'%20'+url;
	var digg = 'http://digg.com/submit?phase=2&url='+url+'&amp;title='+title;
	var stumbleupon = 'http://stumbleupon.com/submit?url='+url+'&amp;title='+title;
	var buzz = 'http://www.google.com/reader/link?url='+url+'&amp;title='+title+'&amp;srcURL='+host;
	var delicious  = 'http://del.icio.us/post?url='+url+'&amp;title='+title;
	var svejo  = 'http://svejo.net/submit/?url='+url;
	var linkvai  = 'http://linkvai.com/pligg/submit.php?url='+url;
	var rel  = 'http://relacia.com/node/add/drigg/?url='+url+'&amp;title='+title;
	var trohi  = 'http://trohi.com/?q=node/add/drigg&url='+url+'&amp;title='+title;
	var zdr  = 'http://zdravei.net/node/add/drigg/?url='+document.location;
	var bgseo  = 'http://bgseo.net/submit/?url='+url;
	var lubimi  = 'http://lubimi.com/bookmarks.php/user?action=add&address='+url+'&amp;title='+title;
	var webbg  = 'http://web-bg.com/submit.php?url='+url;
	var edno23  = 'http://www.edno23.com/pf:open?loadlink='+url;
	var populqrno  = 'http://populqrno.com/submit/?url='+url;
	var elada  = 'http://elada.info/submit?url='+url+'&amp;title='+title;
	var gotini  = 'http://www.gotini.bg/node/add/drigg?url='+url+'&amp;title='+title;
	var bghot  = 'http://www.bghot.net/submit/?url='+url+'&amp;title='+title;
	var novoto  = 'http://novoto.net/node/add/drigg?url='+url+'&amp;title='+title;
	var spodeli  = 'http://spodeli.biz/add/?url='+url;
	var diggbg  = 'http://diggbg.com/index.php/news/add2/?url='+url+'&amp;title='+title;
	var vajni  = 'http://vajni.net/submit?url='+url+'&amp;title='+title;
	var bgbox  = 'http://bgbox.info/node/add/drigg?url='+url+'&amp;title='+title;
	var cenbg  = 'http://cenbg.com/submit.php?url='+url;
 
    var tbar = '<div id="socializethis"><span>Сподели в...<br/><a href="#min" id="minimize" title="Ieieiece?ae" style="margin-left:3px;width:19px;height:17px;"><img src="./images/minimize.png" border="0"/></a><a href="#close" id="close" title="Caoai?e" style="margin-left:3px;width:19px;height:17px;"><img src="./images/close.png" border="0"/></a></span><div id="sicons">';
    tbar += '<img src="./images/share-sep.gif" width="6" height="32" border="0" style="float:left;margin:3px 8px 3px 3px;"/>';
    tbar += '<a href="'+facebook+'" id="facebook" title="Сподели в Facebook" target="_blank"><img src="./images/facebook.png"  alt="Сподели в Facebook" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+twit+'" id="twit" title="Сподели в Twitter" target="_blank"><img src="./images/twitter.png"  alt="Сподели в Twitter" width="32" height="32"  border="0"/></a>';
	tbar += '<a href="'+svejo+'" id="svejo" title="Сподели в Svejo.net" target="_blank"><img src="./images/svejo.png"  alt="Сподели в Svejo.net" width="32" height="32"  border="0"/></a>';
	tbar += '<a href="'+zdr+'" id="zdr" title="Сподели в Zdravei.net" target="_blank"><img src="./images/zdr.png" alt="Сподели в Zdravei.net" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+delicious+'" id="delicious" title="Сподели в Del.icio.us" target="_blank"><img src="./images/delicious.png"  alt="Сподели в Delicious" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+buzz+'" id="buzz" title="Сподели в Buzz" target="_blank"><img src="./images/google-buzz.png"  alt="Сподели в Buzz" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+digg+'" id="digg" title="Сподели в Digg" target="_blank"><img src="./images/digg.png"  alt="Сподели в Digg" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+stumbleupon+'" id="stumbleupon" title="Сподели в Stumbleupon" target="_blank"><img src="./images/stumbleupon.png"  alt="Сподели в Stumbleupon" width="32" height="32"  border="0"/></a>';
    tbar += '<img src="./images/share-sep.gif" width="6" height="32" border="0" style="float:left;margin:3px 8px 3px 8px;"/>';
	
    tbar += '<a href="'+linkvai+'" id="linkvai" title="Сподели в Linkvai.com" target="_blank"><img src="./images/linkvai.png"  alt="Сподели в Linkvai.com" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+rel+'" id="rel" title="Сподели в Relacia.com" target="_blank"><img src="./images/rel.png" alt="Сподели в Relacia.com" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+trohi+'" id="trohi" title="Сподели в Trohi.com" target="_blank"><img src="./images/trohi.png" alt="Сподели в Trohi.com" width="32" height="32"  border="0"/></a>';
    
    tbar += '<a href="'+bgseo+'" id="bgseo" title="Сподели в BGseo.net" target="_blank"><img src="./images/bgseo.png" alt="Сподели в BGseo.net" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+lubimi+'" id="lubimi" title="Сподели в Lubimi.com" target="_blank"><img src="./images/lubimi.png" alt="Сподели в Lubimi.com" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+webbg+'" id="webbg" title="Сподели в Webbg.com" target="_blank"><img src="./images/webbg.png" alt="Сподели в Webbg.com" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+edno23+'" id="edno23" title="Сподели в Edno23.com" target="_blank"><img src="./images/edno23.png" alt="Сподели в Edno23.com" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+populqrno+'" id="populqrno" title="Сподели в Populqrno.com" target="_blank"><img src="./images/populqrno.png" alt="Сподели в Populqrno.com" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+elada+'" id="elada" title="Сподели в Elada.info" target="_blank"><img src="./images/elada.png" alt="Сподели в Elada.info" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+gotini+'" id="gotini" title="Сподели в Gotini.bg" target="_blank"><img src="./images/gotini.png" alt="Сподели в Gotini.bg" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+bghot+'" id="bghot" title="Сподели в BgHot.net" target="_blank"><img src="./images/bghot.png" alt="Сподели в BgHot.net" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+novoto+'" id="novoto" title="Сподели в Novoto.net" target="_blank"><img src="./images/novoto.png" alt="Сподели в Novoto.net" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+spodeli+'" id="spodeli" title="Сподели в Spodeli.biz" target="_blank"><img src="./images/spodeli.png" alt="Сподели в Spodeli.biz" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+diggbg+'" id="diggbg" title="Сподели в Diggbg.com" target="_blank"><img src="./images/digbg.png" alt="Сподели в Diggbg.com" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+vajni+'" id="vajni" title="Сподели в Vajni.net" target="_blank"><img src="./images/vajni.png" alt="Сподели в Vajni.net" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+bgbox+'" id="bgbox" title="Сподели в BGbox.info" target="_blank"><img src="./images/bgbox.png" alt="Сподели в BGbox.info" width="32" height="32"  border="0"/></a>';
    tbar += '<a href="'+cenbg+'" id="cenbg" title="Сподели в Cenbg.com" target="_blank"><img src="./images/cenbg.png" alt="Сподели в Cenbg.com" width="32" height="32"  border="0"/></a>';
    tbar += '<img src="./images/share-sep.gif" width="6" height="32" border="0" style="float:left;margin:3px 8px 3px 8px;"/>';
	
    // Add the share tool bar.
    $('body').append(tbar); 
    $('#socializethis').css({opacity: .5}); 
    // hover.
    $('#socializethis').hover(function(){
      $(this).stop(true, false).animate({height:'35px', width:'1036px', opacity: 1}, 300);
      $('#socializethis img').css('display', 'inline');
	 // hover images
	  $('#sicons a img').hover(function(){
      $(this).stop(true, true).css({height:'34px', width:'34px', margin:'-2px 0 0 -1px'}, 100);},function(){
      $(this).stop(true, true).css({height:'32px', width:'32px', margin:'0'}, 100); 
      });
	  },function(){
      $(this).stop(true, false).delay(1000).animate({height:'15px', width:'310px', opacity: .5}, 300);   
    });
    // Click minimize
    $('#socializethis #minimize').click(function() { 
      minshare(); 
      $.cookie('minshare', '1');  
    }); 
    if($.cookie('minshare') == 1){
      minshare();
    }
    function minshare(){
      $('#socializethis').stop(true, false).css({height:'15px', width: '60px', opacity: .5}); 
      $('#socializethis img').css('display', 'none');	  
	  $('#socializethis').hover(function(){
      $(this).stop(true, false).animate({height:'35px', width:'1036px', opacity: 1}, 300);
      $('#socializethis img').css('display', 'inline')},function(){
      $(this).stop(true, false).delay(1000).animate({height:'15px', width:'60px', opacity: .5}, 300);
      $('#socializethis img').css('display', 'inline');
    }); 	  
	return false;
    } 	
	// Click close
    $('#socializethis #close').click(function() { 
      closeshare(); 
      $.cookie('closeshare', '1');  
    }); 
    if($.cookie('closeshare') == 1){
      closeshare();
    }
    function closeshare(){
      $('#socializethis').stop(true, false).css('display', 'none');  
	  $('#socializethis').hover(function(){
      $(this).stop(true, false).css('display', 'none');
      },function(){
      $(this).stop(true, false).css('display', 'none');
    }); 	  
	return false;
    }  
  });
})(jQuery);
