window.onload = function() {
  //Show social bookmarks
  if ($('socialbookmarks-show') != undefined)
  {
    $('socialbookmarks-show').observe('click', function(event) {
      Event.stop(event);
  
      var element  = Event.element(event);
      var position = Position.cumulativeOffset(element);
      var left     = position[0];
      var top      = position[1] + 20;
  
      $('socialbookmarks').toggle().setStyle({
         left: left + 'px',
         top:  top + 'px'
      });
  
      Event.observe(document, 'click', function(event) {
        hideSocialBookmarks();
      });
    });
  }

  //Hide social bookmarks
  if ($('socialbookmarks-hide') != undefined)
  {
    $('socialbookmarks-hide').observe('click', function(event) {
      Event.stop(event);
      hideSocialBookmarks();
    });

    function hideSocialBookmarks() {
      $('socialbookmarks').hide();
    } 
  }

function odump(object, depth, max){
  depth = depth || 0;
  max = max || 2;

  if (depth > max)
    return false;

  var indent = "";
  for (var i = 0; i < depth; i++)
    indent += "  ";

  var output = "";  
  for (var key in object){
    output += "\n" + indent + key + ": ";
    output += object[key];
  }
  return output;
}


  //Show social bookmark name
  if ($('socialbookmarks-inline') != undefined)
  {
/*
    $$('#socialbookmarks-inline a').each(function(s){
s.observe('mouseover', function(ev){alert('test');});
});
*/
    $$('#socialbookmarks-inline a').invoke('observe', 'mouseover', function(event)
    {
      Event.stop(event);
      showSocialBookmarkTitle(Event.element(event).parentNode);
    });
    $$('#socialbookmarks-inline a').invoke('observe', 'mouseout', function(event)
    {
      Event.stop(event);
      hideSocialBookmarkTitle(Event.element(event).parentNode);
    });

    function showSocialBookmarkTitle(bookmark)
    {
      $('socialbookmarks-text').innerHTML = bookmark.readAttribute('title');
    }

    function hideSocialBookmarkTitle(bookmark)
    {
      text = $('socialbookmarks-text');
      if (text.innerHTML = bookmark.title)
      {
        text.innerHTML = '...';
      }
    }
  }
}

