// PrettyPhoto (lightbox)
jQuery(document).ready(function($){$("a[rel^='prettyPhoto']").prettyPhoto();});

// gallery thumbnail hover effect
jQuery(document).ready(function () {
	jQuery('#gallery .block img').mouseover(function() {
		jQuery(this).stop().fadeTo(300, 0.5);
	});
	jQuery('#gallery .block img').mouseout(function() {
		jQuery(this).stop().fadeTo(400, 1.0);
	});
});

// gallery tag sorting
jQuery(document).ready(function(){
								
	jQuery('.port-cat a').click(function(evt){
		var clicked_cat = jQuery(this).attr('rel');
		if(clicked_cat == 'all'){
			jQuery('#gallery .post').hide().fadeIn(200);
		} else {
			jQuery('#gallery .post').hide()
			jQuery('#gallery .' + clicked_cat).fadeIn(400);
		 }
		//eq_heights();
		evt.preventDefault();
	})	

	// Thanks @johnturner, I owe you a beer!
	var postMaxHeight = 0;
	jQuery("#gallery .post").each(function (i) {
		 var elHeight = jQuery(this).height();
		 if(parseInt(elHeight) > postMaxHeight){
			 postMaxHeight = parseInt(elHeight);
		 }
	});
	jQuery("#gallery .post").each(function (i) {jQuery(this).css('height',postMaxHeight+'px');});
														
});
