(function( $ ) {
  $(document).ready(function() { 

 

    var url = window.location.href;
    var host =  window.location.hostname;
    var title = $('title').text();
    title = escape(title); //clean up unusual characters
 
    var twit = 'http://twitter.com/home?status='+title+'%20'+url;
    var facebook = 'http://www.facebook.com/sharer.php?u='+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 hyves  = 'http://www.hyves-share.nl/button/tip/?tipcategoryid=12&rating=5&title='+title+'&body=Tip:'+url;
	var linkedin = 'http://www.linkedin.com/shareArticle?mini=true&url='+url+'&title='+title; //+'&summary={articleSummary}&source={articleSource}
 
    var tbar = '<div id="socializethis"><span>Share<br /><a href="#min" id="minimize" title="Minimize"> <img src="/images/min.png" /> </a></span><div id="sicons">';
    tbar += '<a href="#" onclick="window.open(\''+twit+'\', \'Share\', \'width=640,height=480,location=yes,scrollbars=no\'); return false"  id="twit" title="Share on twitter"><img src="/images/twitter.png"  alt="Share on Twitter" width="32" height="32" /></a>';
    tbar += '<a href="#" onclick="window.open(\''+facebook+'\', \'Share\', \'width=640,height=480,location=yes,scrollbars=no\'); return false"" title="Share on Facebook" ><img src="/images/facebook.png"  alt="Share on facebook" width="32" height="32" /></a>';
    tbar += '<a href="#" onclick="window.open(\''+hyves+'\', \'Share\', \'width=640,height=480,location=yes,scrollbars=no\'); return false"  id="stumbleupon" title="Share on hyves"><img src="/images/hyves.png"  alt="Share on hyves" width="32" height="32" /></a>';
    tbar += '<a href="#" onclick="window.open(\''+linkedin+'\', \'Share\', \'width=640,height=480,location=yes,scrollbars=no\'); return false"  id="linkedin" title="Share on Linkedin"><img src="/images/linkedin.png"  alt="Share on linkedin" width="32" height="32" /></a>';
	
   // tbar += '<a href="'+delicious+'" id="delicious" title="Share on Del.icio.us"><img src="/images/delicious.png"  alt="Share on Delicious" width="32" height="32" /></a>';
   // tbar += '<a href="'+buzz+'" id="buzz" title="Share on Buzz"><img src="/images/google-buzz.png"  alt="Share on Buzz" width="32" height="32" /></a>';
    tbar += '</div></div>';
 
    // Add the share tool bar.
    $('body').append(tbar); 
    $('#socializethis').css({opacity: .7}); 
    // hover.
    $('#socializethis').bind('mouseenter',function(){
      $(this).animate({height:'35px', width:'260px', opacity: 1}, 300);
      $('#socializethis img').css('display', 'inline');   
    });
    //leave
    $('#socializethis').bind('mouseleave',function(){
		
      $(this).animate({ opacity: .7}, 300);
    });  
    // Click minimize
    $('#socializethis #minimize').click( function(event) { 
	event.preventDefault();
      minshare(); 
      $.cookie('minshare', '1');  
    }); 
 
    if($.cookie('minshare') == 1){
      minshare();
    }  
 
    function minshare(){
      $('#socializethis').animate({height:'15px', width: '40px', opacity: .7}, 300); 
      $('#socializethis img').css('display', 'none');
      return false;
    }  
  });
})(jQuery);
