(function ($) {
  
  /**
   * Embed video links inline
   */
  Drupal.behaviors.embed = {
    attach: function() {
      $("a.embed").click(function(e) {
        e.preventDefault();
        var type = $(this).attr("rel");
        switch (type) {
          case 'youtube':
            var id = this.href.match(/v=([a-z\d]+)/i);
            if (id[1].length) {
              var embed = $("<iframe>").attr({
                            "type": "text/html", 
                            "width": "590", 
                            "height": "355", 
                            "src": 'http://www.youtube.com/embed/' + id[1], 
                            "frameborder": "0",
                            "class": "youtube-player",
                            "style": "height: 0; overflow: hidden"
                          });
              $(this).replaceWith(embed);
              embed.animate({"height": 385});
            }
            break;
        }
      });
    }
  };

})(jQuery);;
(function ($) {
  Drupal.behaviors.highlightOverflow = {
    attach: function() {
      $("body")
        .delegate(".syntaxhighlighter", "mouseenter", function() {
          var el = $(this);
          if (!el.data('origWidth')) {
            el.data('origWidth', el.width());
          }
          if (!el.data('targetWidth')) {
            el.data('targetWidth', el.find("table").width());
          }
          el.stop().animate({
              width: el.data('targetWidth')
            }, "fast", "swing");
        })
        .delegate(".syntaxhighlighter", "mouseleave", function() {
          var el = $(this);
          el.stop().animate({
            width: el.data('origWidth')
          }, "fast", "swing");
        })
    }
  };
}(jQuery));;

