(function($) {
    $.fn.SittingDuck = function(options) {
        var opts = $.extend({}, $.fn.SittingDuck.defaults, options);
        return this.each(function() {
            var container = $(this);
            var anchor = $('a:first', container);
            var href = anchor.attr('href');
            var o = $.meta ? $.extend({}, opts, anchor.data()) : opts;
            container.css('cursor', o.cursor);
            container.hover(function() {
                $this = $(this);
                //$this.addClass(o.hoverclass);
            }, function() {
                //$this.removeClass(o.hoverclass);
            }).click(function() {
                if($.fn.SittingDuck.getSelectedText() == "") {
                    if(anchor.is('[rel*=external]')) {
                        window.open(href);
                        return false;
                    }
                    else {
                        window.location = href;
                    }
                }
            });
        });
    }
    $.fn.SittingDuck.getSelectedText = function() {
        if(window.getSelection) {
            return window.getSelection().toString();
        }
        else if(document.getSelection) {
            return document.getSelection();
        }
        else if(document.selection) {
            return document.selection.createRange().text;
        }
    }
})(jQuery);
jQuery.fn.SittingDuck.defaults = {
    hoverclass : 'hover',
    cursor : 'pointer'
}