$(window).load(function(){

		ulWidth = $('ul.productsListHomepage').width();
		//alert(ulWidth);
		liWidth = $('ul.productsListHomepage li').width();
		//alert(liWidth);
		//liWidthMarginL = parseInt($('ul.productsListHomepage li').css("margin-left").replace("px", ""));
		//liWidthMarginR = parseInt($('ul.productsListHomepage li').css("margin-right").replace("px", ""));
		//newLiWidth = liWidth + liWidthMarginL + liWidthMarginR;
		//alert(newLiWidth);

		/*horizontalCount = 0;
		widthRemaining = ulWidth;
		while (widthRemaining >= newLiWidth) {
			widthRemaining -= newLiWidth;
			horizontalCount++;
		}*/
		var itemCount = 0;
		var currentClassCount = 0;
		$('li.alignable').each(function(){
			className = 'group_' + currentClassCount;
			$(this).addClass(className);
			itemCount++;
			if (itemCount == horizontalCount) {
				itemCount = 0;
				currentClassCount++;
			}
		});
		for (i = 0;i <= currentClassCount;i++) {
		var maxHeight = 0;
		var biggest;
		//Loop over each item first to see which is biggest
		$('li.alignable.group_'+i).each(function(){
			id = $(this).attr('id');
			imgHeight = $('#'+id+' div.headerTitleBar').height();
			h2Height = $('#'+id+' div.prodImage').height();
			introHeight = $('#'+id+' div.prodDetail').height();
			buttonHeight = $('#'+id+' div.prodDetailLink').height();
			//Calculate total height
			totalHeight = imgHeight + h2Height + introHeight + buttonHeight;
			//alert('ID - '+id+"\nimg - "+imgHeight+"\nh2 - "+h2Height+"\nintro - "+introHeight+"\nbutton - "+buttonHeight+"\ntotal - "+totalHeight);
			//See if item is larger than current biggest
			if (totalHeight > maxHeight) {
				maxHeight = totalHeight;
				biggest = id;
			}
		});
		//Loop over again now that we know which is biggest
		$('li.alignable.group_'+i).each(function(){
			id = $(this).attr('id');
			//Only change ones that aren't the biggest, obviously
			if (id != biggest) {
				imgHeight = $('#'+id+' div.headerTitleBar').height();
				h2Height = $('#'+id+' div.prodImage').height();
				introHeight = $('#'+id+' div.prodDetail').height();
				introHeightMarginB = parseInt($('#'+id+' div.prodDetail').css("margin-bottom").replace("px", ""));

				totalWithoutButton = imgHeight + h2Height + introHeight;
				//alert('Total' + totalWithoutButton);

				newButtonTotal = maxHeight - totalWithoutButton;
				//alert('New ' + newButtonTotal);

				buttonHeight = $('#'+id+' div.prodDetailLink').height();
				//alert('Button '+buttonHeight);
				newMargin = (newButtonTotal - buttonHeight) + introHeightMarginB;
				//alert('M '+newMargin);
				newMarginString = newMargin + 'px';

				//alert('id - '+id+"\n newButtonTotal - "+newButtonTotal+"\n newMargin - "+newMarginString);
				//Set bottom button's margin to make them all align
				$('#'+id+' div.prodDetailLink').css('margin-top',newMarginString);
				// shorten product headers if too long	
				if ($('#' + id + ' div.headerTitleBar h3').html().length > 28){
					$('#' + id + ' div.headerTitleBar h3').html($('#' + id + ' div.headerTitleBar h3').html().substring(0, 28) + "...");
				}

			}
		});
		//alert('Biggest - '+biggest+"\nheight - "+maxHeight);
		
		}
		Cufon.replace('.headerTitleBar h3, #goButton, .product-title, .product-model-number, .product-price', {
			fontFamily: 'Interstate',
			wmode: 'transparent'
		});
		

	});

