//Thanks to http://hoeben.net/aldo/variable_height_liquid_float_galleries_with_jquery_and_prototype
$(window).resize(FG_fixfloats);
$(document).ready(prepare);
$(document).ready(FG_fixfloats);

function prepare() {
	$(".acidfree-cell").parent().append("<div class='acidfree-cell' style='clear: left' />");
}

function FG_fixfloats() {
	lastParent = 0;
	galleryitems = $(".acidfree-cell");
	galleryitems.each(function(i){
		if(this.parentNode != lastParent) {
			lastTop = 0;
			rowHeight = 0;
			rowStart = i;
			lastParent = this.parentNode;
		}
		this.style.height = "auto";
		if (this.firstChild != null) {
			//this.firstChild.style.height = "auto";
		}
		if (this.nextSibling != null) {
			this.style.clear="none";
		}
		if(this.offsetTop != lastTop) {
			this.style.clear="left";
			rowHeight = this.offsetTop - lastTop - (this.style.marginTop + this.style.marginBottom);
			for(j=rowStart;j<i;j++) {
				galleryitems.get(j).style.height = rowHeight+"px";
				//galleryitems.get(j).firstChild.style.height = rowHeight - 14 +"px";
			}
			lastTop = this.offsetTop;
			rowStart = i;
		} 
	});
	
}