(function ($) {
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	$(this).css('margin-top', mh);
	});
};
})(jQuery);

(function ($) {
$.fn.hAlign = function() {
	return this.each(function(i){
	var aw = $(this).width();
	var pw = $(this).parent().width();
	var mw = (pw - aw) / 2;
	$(this).css('margin-left', mw);
	});
};
})(jQuery);

$(document).ready(function() {

	var total_logo_width = 0;
	var logo_count = $('#pre_footer img').length;

	// Vertically align images, check total image width
	$('#pre_footer a').each(function() {
		$img = $('img', this);
		$(this).width( $img.width() ).height( $img.height() ).vAlign();
		total_logo_width = total_logo_width + $img.width();
	});
	
	// Set consistent logo margins
	empty_space	= $('#pre_footer').width() - total_logo_width;
	img_margin	= empty_space / (logo_count * 2);
	$('#pre_footer a').css({ marginLeft: img_margin, marginRight: img_margin });
});
