jQuery(document).ready(function() {
    
    jQuery('.profilecontent').width(jQuery('.profile').length * 308);
    jQuery('#arrows .prev').parent('li').addClass('inactive');
    
    jQuery('.profile').hover(function() {
        var jQuerythis = jQuery(this);

        clearTimeout(jQuerythis.data('timeout'));
        jQuerythis.data('timeout', setTimeout(function() {
            jQuerythis.stop().animate({ top: '-308px' }, 1000, 'easeInOutQuart');
        }, 150));
    }, function() {
        var jQuerythis = jQuery(this);

        clearTimeout(jQuerythis.data('timeout'));
        jQuerythis.data('timeout', setTimeout(function() {
            jQuerythis.stop().animate({ top: '0' }, 1000, 'easeInOutQuart');
        }, 250));
    });
    
    jQuery('#arrows .next').click(function(event) {
        event.preventDefault();
        var jQuerythis = jQuery(this);
        
        jQuery('#arrows .prev').parent('li').removeClass('inactive');
        
        jQuery('.profileslider').animate({ scrollLeft: '+=308px' }, 1000, 'easeInOutQuart', function() {
            if(jQuery('.profileslider').scrollLeft() >= jQuery('#profiles').width()) {
                jQuerythis.parent('li').addClass('inactive');
            } else {
                jQuerythis.parent('li').removeClass('inactive');
            }
        });
    });

    jQuery('#arrows .prev').click(function(event) {
        event.preventDefault();
        var jQuerythis = jQuery(this);
        
        jQuery('#arrows .next').parent('li').removeClass('inactive');
     
        jQuery('.profileslider').animate({ scrollLeft: '-=308px' }, 1000, 'easeInOutQuart', function() {
            if(jQuery('.profileslider').scrollLeft() <= 0) {
                jQuerythis.parent('li').addClass('inactive');
            } else {
                jQuerythis.parent('li').removeClass('inactive');
            }
        });
    });

});
