(function ($) {
    $.fn.jFav = function (d) {
        var e = $.extend({}, $.fn.jFav.defaults, d);
        var f = e.msg;
        this.each(function () {
            if (!$(this).attr('href') || $(this).attr('href') == "#") {
            	$(this).attr('href', window.location.href)
            }
            if (($.browser.safari) || (navigator.userAgent.toLowerCase().indexOf('chrome') > -1)) {
                $(this).attr('title', f); 
                $(this).addClass('inactive'); 
				$(this).attr('href','return false');
            }else if ($.browser.opera) {
                $(this).attr('link', $(this).attr('href')).attr('href', '').attr('href', 'javascript:void(0)').attr('onClick', '$.fn.jFav.OperaBookmark(this,"' + $(this).attr('title') + '","' + $(this).attr('link') + '")')
            } else {
                $(this).click(addToFavorites)
            }
        });

        function addToFavorites(a) {
            var b = $(this).attr('href');
            var c = $(this).attr('title');
            b = b.replace("file:///", "http://file/");
            if ($.browser.msie) {
                window.external.AddFavorite(b, c)
            } else if ($.browser.mozilla) {
                window.sidebar.addPanel(c, b, '')
            }
            a.preventDefault()
        };
        return this
    };
    $.fn.jFav.defaults = {
        msg: 'Naciśnij "Ctrl + D" lub "CMD + D" dla MAC`a, aby dodać tąstronę to Twoich zakładek.'
    };
    $.fn.jFav.OperaBookmark = function (e, a, b) {
        e.rel = "sidebar";
        e.title = a;
        e.href = "";
        e.href = b;
        e.click();
        return false
    }
})(jQuery);
