var EAProdLoop = {};
EAProdLoop.numProds = 0;	//default value for number of products on the page
EAProdLoop.setHeight = function () {
	var d = document;
	var box;
	
	if (EAProdLoop.numProds != 0) {
		//No need to resize the prod boxes on the last line if there's only one product
		if (EAProdLoop.numProds % 3 > 1) {
			//EAProdLoop.numProds = EAProdLoop.numProds - (EAProdLoop.numProds % 3);
		}
		box = new Array(EAProdLoop.numProds);
		for (var i = 0;i < EAProdLoop.numProds;i++) {
			box[i] = "prod" + i;
		}
	}

	for(var x = 0;x < EAProdLoop.numProds;x++)//determine the tallest div
	{
		if (x == 0 || x % 3 == 0) {
			h = d.getElementById(box[x]).offsetHeight;
			if (d.getElementById(box[x+1])) {
				h2 = d.getElementById(box[x+1]).offsetHeight;
			}
			else {
				h2 = 0;
			}
			if (d.getElementById(box[x+2])) {
				h3 = d.getElementById(box[x+2]).offsetHeight;
			}
			else {
				h3 = 0;
			}

			h = Math.max(h,h2);
			h = Math.max(h,h3);

			d.getElementById(box[x]).style.height = (h - 10) + "px";
			if (d.getElementById(box[x+1])) { d.getElementById(box[x+1]).style.height = (h - 10) + "px"; }
			if (d.getElementById(box[x+2])) { d.getElementById(box[x+2]).style.height = (h - 10) + "px"; }
		}
	}
}

//Launches setHeight() on page load
Event.observe(window,"load",EAProdLoop.setHeight);