$(document).ready(function(){	
	
	var port = $('.portfolio-main');
	
	// get the piece value
	var hash = document.location.href;
				
	fader(port, hash);
	
	// only activate the hover if the portfolio is present
	if(port.length > 0)
	{
		var thumbs = $('#thumbs li a');
		thumbs.hover( function() 
		{ 
			var hoverhash = $(this).attr('href');
			fader(port, hoverhash);
		}, function() {});
		
		thumbs.click( function(event) { event.preventDefault()});
	}				
});

function fader(port, hash)
{
	var hashpos = hash.indexOf('piece-');
	
	if(hashpos == -1) 
	{
		var el = port.first();					
	}
	else
	{
		var piece = hash.substr(hashpos+6);
		el = $('#piece-'+piece);
	}
	
	port.hide();
	el.fadeIn('slow');				
}
