$(function() {

	$('ul.nav li').click(function() {

		if ($(this).hasClass('rev')) {
			$('#portf').fadeIn(200);
		}
		return false;
	});

	$('#portf').click(function() {
		$(this).fadeOut(100);
	});

	$('#pfclose').click(function() {
		$('#portf').fadeOut(100);
	});

	$('div.pf-wrap').click(function(e) {
		e.stopPropagation()
	});

    $('#pfnext').click(function() {

        if ( parseInt($('#pslider').css('left')) <= -2560 ) {
            $('#pslider').not(':animated').animate({left:'0'});
        } else {
            $('#pslider').not(':animated').animate({left:'-=512'});
        }
	});

	$('#pfprev').click(function() {
	    if ( parseInt($('#pslider').css('left')) >= 0 ) {
            $('#pslider').not(':animated').animate({left:'-2560'});
        } else {
            $('#pslider').not(':animated').animate({left:'+=512'});
        }
	});

    $('#pfeed > div p').click(function() {
		var coord = parseInt($(this).attr('data-coord')) + 'px';
		$('#pslider').animate({left:coord});
	});

	$('ul.nav > li').hover(function() {
	    $(this).children('p').delay(100).fadeIn(200);
	}, function() {
	    $(this).children('p').stop(true, true).fadeOut(200);
	});
});
