Pencil = Class.extend({
    $: this,
    document: $(document),

    init: function() {
        this.document.click(function() {
            path = '';
            pointer = document.getSelection().getRangeAt(0).commonAncestorContainer;
            while(pointer.parentElement && pointer.parentElement.tagName != 'BODY') {
                path += '<span>' + pointer.parentElement.tagName + '</span>';
                pointer = pointer.parentElement;
            }
            $('#crumbs').html(path);
        });
    },
});

Pencil = new Pencil();
