// socialmediatooltips.js

!(function(window, document, $, undefined){

var topOffEnd = '66px';
var topOffStart = '16px';
var topOn= '36px';
var timing = 400;


$(document).ready(function(){

$('#metabar .socialicons a')
  .find('span')
    .each(function(){
      var $this = $(this);
      $this.html('<span class="text">'+$this.text()+'</span>');
      var width = $this.outerWidth();
      $this.css({ opacity: 0, left: '50%', marginLeft: '-'+(width/2)+'px'});
      $this.prepend('<span class="tooltip-arrow"> </span>');
    })
    .end()
  .hover(
    function(){
      var $this = $(this);
      var span = $this.children('span');
      if(span.css('opacity') == 0){
        span.css('top', topOffStart);
      }
      
      span.stop().animate(
        { opacity: 1,
          top: topOn },
        timing
      );
    },
    function(){
      var $this = $(this);
      var span = $this.children('span');
      
      span.stop().animate(
        { opacity: 0,
          top: topOffEnd },
        timing,
        function(){
          $(this).css('top', '-999px');
        }
      );
    });
  
});

})(window, window.document, jQuery);