$(document).ready(function() {


/* ----- Portfolio items ----- */

	var associatedInsert = "";
	var associatedItem = "";
	var insertFadeSpeed = 200;

	if(jQuery.browser.msie) insertFadeSpeed = 0;

	$(".portfolioItem").click(function() {
		$(this).find("h3 a").click();
	});

	$(".portfolioItem img, .portfolioInsert img").hide();

	$(".portfolioItem:not(.upcomingItem)").hoverIntent(function() {
		associatedInsert = "#insert-" + $(this).attr("id");
		liftMeUp($(this));
		$("img", associatedInsert).fadeIn(200);

	}, function() {
		putMeDown($(this));
		$("img", associatedInsert).fadeOut(200);	
	});

	$(".portfolioInsert").hoverIntent(function() {
		associatedItem = "#" + $(this).attr("id").split("-")[1];
		$("img", associatedItem).fadeIn(200);
		$("img", this).fadeIn(insertFadeSpeed);
		liftMeUp(associatedItem);		

	}, function() {
		$("img", associatedItem).fadeOut(200);
		$("img", this).fadeOut(insertFadeSpeed);
		putMeDown(associatedItem);		
	});

	function liftMeUp(item) {
		$(item).animate({height : 177 }, 150)
		$(".inner", item).animate({top : -6 }, 150);
		$("img", item).fadeIn(200);
	}

	function putMeDown(item) {
		$(item).animate({height : 163 }, 150)		
		$(".inner", item).animate({top : 0 }, 150);
		$("img", item).fadeOut(200);
	}

});

