jQuery.noConflict();
(function($) {
    $(function() {
        if (jQuery("#slider").length > 0){
            jQuery("#slider").easySlider({
                auto: true,
                continuous: true,
                speed: 1400
            });
        }
        jQuery('.header .menu ul:first').superfish({
            autoArrows: false
        });

        jQuery('.contents').live('click',function(){
            var href = $(this).prev('a').attr('href');
            window.location = href;
            return false;
        });

        /*** Ajax-fetching posts ***/
        if ($('#pagination').length > 0){
            $('#pagination a').live('click', function(e){
                e.preventDefault();
                var anchor = $(this).html();
                $(this).addClass('loading').html('<span>Ładowanie</span>');
                $.ajax({
                    type: "GET",
                    url: $(this).attr('href') + '#loop',
                    dataType: "html",
                    success: function(out){
                        result = $(out).find('#loop .post');
                        nextlink = $(out).find('#pagination a').attr('href');
                        $('#loop').append(result.fadeIn(300));
                        $('#pagination a').removeClass('loading').html(anchor);
                        if (nextlink != undefined) {
                            $('#pagination a').attr('href', nextlink);
                        } else {
                            $('#pagination').remove();
                        }
                        if ( $.cookie('mode') == 'grid' ) {
                            grid_update();
                        } else {
                            list_update();
                        }
                    }
                });
            });
        }
        /*** Misc ***/

        $('#comment, #author, #email, #url')
        .focusin(function(){
            $(this).parent().css('border-color','#888');
        })
        .focusout(function(){
            $(this).parent().removeAttr('style');
        });
        $('.rpthumb:last, .comment:last').css('border-bottom','none');

    })
})(jQuery)

