/**
 * jQuery Adjacent plugin
 *
 * Selects all elements consecutively adjacent to the current element which match the given filter.
 *
 * Usage: eg: Find all the elements with class "foo" next to the #active element:
 * $('#active').adjacent('.foo');
 *
 *                                   SELECTED?
 * <p class="foo"></p>                  no
 * <p></p>                              no
 * <p class="foo"></p>                  yes
 * <p class="foo"></p>                  yes
 * <p class="foo" id="active"></p>      yes
 * <p class="foo"></p>                  yes
 * <p></p>                              no
 * <p class="foo"></p>                  no
 * <p class="foo"></p>                  no
 *
 *
 * Note that this will select the current item even if it doesn't match the filter itself.
 */

jQuery.fn.adjacent = function(filter) {
    var $all = this;

    //edit. find next adjacent only. to do, add options...
    /*for (var $curr = this.prev(filter); $curr.length > 0; $curr = $curr.prev(filter)) {
        $all = $all.add($curr);
    }*/
    for (var $curr = this.next(filter); $curr.length > 0; $curr = $curr.next(filter)) {
        $all = $all.add($curr);
    }
    return $all;
};
