var Precision = new function()
{
    $(function(e)
    {
        if (!$.browser.msie) {
            DD_roundies.addRule('#mainnav li a,.pagination a,.pagination span', '2px', true);
            DD_roundies.addRule('#focal dl.split', '3px', true);
            DD_roundies.addRule('#featured div#search', '2px', true);
            DD_roundies.addRule('#index #focal a.more', '2px', true)
        }

        $('#mainnav li:not(.selected) a').hoverfx({color: '#e11313', backgroundColor: '#fff'}, 500);
        $(window).load(function(e)
        {
            $('#mainnav li.selected a').delay(500).animate({color: '#e11313', backgroundColor: '#fff'}, 500);
        });

        $('html[id!=index] #focal dl.split').hoverfx({backgroundColor: '#242121'}, 500)
                            .each(function(i, o)
                            {
                                $(o).click(function(e)
                                {
                                    if (!/a/i.test(e.target.tagName)) {
                                        location.href = $('dt a', this).attr('href');
                                        return false;
                                    }
                                });
                            });

        $('#featured a').hoverfx({backgroundColor: '#fff'}, 500);
        $('div.gallery a').fancybox();
    });
};


;(function($)
{
    $.fn.hoverfx = function (o, d) {

        var self = this;
        d = d || 200;

        var mouseenter = function(e)
        {
            $(this).stop().animate(o, d);
        };

        var mouseleave = function(e)
        {
            var self = $(this);
            var css = self.data('__css');
            self.stop().animate(css, d, function(){
                var i = 0;
                $.each(css, function(k){
                    ++i;
                    self.delay(i * d).css(k, '');
                })
            });
        };

        this.live({
            mouseenter: mouseenter,
            mouseleave: mouseleave
        });

        $.each(self, function(i)
        {
            var el = $(self[i]);
            var css = {};
            $.each(o, function(k)
            {
                css[k] = el.css(k);
            });
            el.data('__css', css);
            el.mouseenter(mouseenter);
            el.mouseleave(mouseleave);
        });

        return this;
    };

})(jQuery);
