function loadportfolio(pfurl) {
	$.ajax({
		url: pfurl,
		success: function(data) {
			$('.portfolio-thumb').html(data);
			portfolio_thumb();
		},
		error:function(x,e){
			$('.portfolio-thumb').html('<p>There was a error processing your request.</p>');
		}
	});
}
function portfolio_thumb() {
	$('.thumb-item a img').each(function() {
		$(this).hide();
		$(this).parent().append('<div class="thumbloader"></div>');
	});
	$('.thumb-item a img').imgpreload({
		each: function() {
			var thumbcapt = $(this).parent().attr('title');
			$(this).parent().attr('title', '');
			$(this).parent().append('<div class="thumbbg"></div><div class="thumbcaption">' + thumbcapt + '</div>');
			$(this).parent().find('.thumbbg, .thumbcaption').css({opacity: 0.0}).show();
			$(this).parent().find('.thumbloader').remove();
			$(this).fadeIn();
		}
		, all: function() {
			
		}
	});
	$('.thumb-item a').each(function() {
		$(this).hover(function() {
			$(this).css({'cursor':'pointer'});
			$(this).children('.thumbbg').animate({opacity: 0.85}, 'fadeIn');
			$(this).children('.thumbcaption').animate({opacity: 1.0}, 'fadeIn');
		}, function() {
			$(this).children('.thumbbg, .thumbcaption').stop().animate({opacity: 0.0}, 'fadeOut');
			$(this).css({'cursor':'default'});
		});
	});
}

$(function() {
	if ($.browser.opera) {
		$.support.opacity = true;
	}
});

$(document).ready(function() {
	loadportfolio($('.portfolio-nav a.active').attr('href'));
	$('.portfolio-nav a').click(function() {
		if(!($(this).hasClass('active'))) {
			loadportfolio($(this).attr('href'));
			$('.portfolio-nav a.active').removeClass('active');
			$(this).addClass('active');
		}
		return false;
	});
});
