;(function($) {
/* The removeOrphan prevents orphan words in headlines, basicaly by adding a
 * non-breaking space between the 2 last words. */

    $.removeOrphan = function(text){
        var words = $.trim(text).split(' ');

        if(words.length < 3) return words.join(' ');

        words[words.length - 2] += '&nbsp;'+words.pop();
        return words.join(' ');
    };

    $.fn.removeOrphan = function(options) {

        return this.each(function() {
            var $this = $(this);
            $this.html($.removeOrphan($this.text()));
        });

    };

})(jQuery);

