$(document).ready(function () {

	$('div.product').wrapInner("<div class='prod_content'></div>");
	$('div.product').prepend("<div class='img1'></div><div class='img2'></div><div class='img3'></div><div class='clear'></div><div class='img4'></div>");
	$('div.product').append("<div class='img5'></div><div class='clear'></div><div class='img6'></div><div class='img7'></div><div class='img8'></div><div class='clear'></div>");
	
	$('div.img2').each(function(index){
	    WidPar = $(this).parent().width();
		WidImgs = 66;		
		WidCon = (WidPar - WidImgs);
	 	$(this).siblings('.prod_content').width(WidCon+"px");
		$(this).width(WidCon+"px");
		HeightImgs = $(this).siblings('.prod_content').height() + 1;
		$(this).siblings('.img4, .img5').height(HeightImgs+"px");
		$(this).siblings('.img7').width(WidCon+"px");
	});
	
	
	$('div.product img').load(function() {
		//Handler for .load() called.		
		HeightImgs = $(this).parent().height() + 1;
		HeightImg4 = $(this).parent().siblings(".img4").height();
		HeightImg5 = $(this).parent().siblings(".img5").height();		
		//$("#debug").append("<p>HeightImgs="+HeightImgs+ "</p>");
		//$("#debug").append("<p>HeightImg4="+HeightImg4+ "</p>");
		//$("#debug").append("<p>HeightImg5="+HeightImg5+ "</p>");
		if ($(this).parent().siblings(".img4").height() < HeightImgs){
			$(this).parent().siblings(".img4").height(HeightImgs+"px");					
			//$("#debug").append("<p>Set img height for 4 to "+HeightImgs+ "</p>");
		}
		if ($(this).parent().siblings(".img5").height() < HeightImgs){			
			$(this).parent().siblings(".img5").height(HeightImgs+"px");					
			//$("#debug").append("<p>Set img height for 5 to "+HeightImgs+ "</p>");			
		}

	});
	
	

});





