 jQuery(document).ready(function(){

    jQuery('ul#filter-profile a').click(function() {
        jQuery(this).css('outline','none');
        jQuery('ul#filter-profile .current').removeClass('current');
        //jQuery(this).parent().addClass('current');
        jQuery(this).addClass('current');

        profileFilter = jQuery(this).text().toLowerCase().replace(/ /g,'-');

       if(profileFilter == 'all') {
            jQuery('.thumbnail-wrapper li.hidden').fadeIn('slow').removeClass('hidden');
        } else {
            jQuery('.thumbnail-wrapper li').each(function() {
                if(!jQuery(this).hasClass(profileFilter)) {
                    jQuery(this).fadeOut('slow').addClass('hidden');
                } else {
                    jQuery(this).fadeIn('slow').removeClass('hidden');
                }

            });
        }

    });

    var thumbnail = {
        imgIncrease : 100, /* the image increase in pixels (for zoom) */
        effectDuration : 400, /* the duration of the effect (zoom and caption) */
        imgWidth : jQuery('.thumbnail-wrapper ul li').find('img').width(),
        imgHeight : jQuery('.thumbnail-wrapper ul li').find('img').height()
    };

    jQuery('.thumbnail-wrapper ul li').css({
        'width' : thumbnail.imgWidth,
            'height' : thumbnail.imgHeight

    });

    //when mouse over the list item...
    jQuery('.thumbnail-wrapper ul li').hover(function(){

        /*jQuery(this).find('img').stop().animate({
            width: parseInt(thumbnail.imgWidth) + thumbnail.imgIncrease,
            left: thumbnail.imgIncrease/2*(-1),
            top: thumbnail.imgIncrease/2*(-1)
        },{
        "duration": thumbnail.effectDuration,
        "queue": false
        });*/

        jQuery(this).find('.caption:not(:animated)').slideDown(thumbnail.effectDuration);
    }, function(){
        /*jQuery(this).find('img').animate({
            width: thumbnail.imgWidth,
            left: 0,
            top: 0
    }, thumbnail.effectDuration);*/

        jQuery(this).find('.caption').slideUp(thumbnail.effectDuration);

    });

    var cache = [];
    // Arguments are image paths relative to the current page.
    jQuery.preLoadImages = function() {
        var args_len = arguments.length;
        for (var i = args_len; i--;) {
            var cacheImage = document.createElement('img');
            cacheImage.src = arguments[i];
            cache.push(cacheImage);
        }
    }
});
