$(function(){
	
	$('.set_height').each(function(){
		var img = $(this) // Get my img elem
		var pic_real_width, pic_real_height;
		temp = $("<img/>") // Make in memory copy of image to avoid css issues
	    .attr("src", $(img).attr("src"))
	    .load(function() {
	        pic_real_width = this.width;   // Note: $(this).width() will not
	        pic_real_height = this.height; // work for in memory images.
			$(img).attr("height", pic_real_height)
	    });
		
	}).load(function(){
		match_heights('.match_height');
		match_heights('.match_height_2');
		match_heights('.match_height_3');
	});
	
	
	
	
	
})



function match_heights(c){
	c = c || ".match_height";
	
	//Create an array of matched elements
	e = $(c)
	
	//Create an empty array to add the height of the elements to
	e_array = new Array()
	
	//Loop through the matched elements and add height to the array
	for(i=0; i<e.length; i++){
		e_array.push($(e[i]).height())
	}

	//Get the tallest height
	h = Math.max.apply( Math, e_array );
	

	if(c == ".match_height_2"){
		console.log(h)
	}


	//Set all the heightd
	$(c).css({
		height: h
	})
	
}
