function resizeLayout() {
  $(".image-switch img").each(function(){
    var imageheight = $(this).height;
    var imagewidth = $(this).width;
    var ratio = imageheight/imagewidth;
    var top = 0;
	var left = 0;
    if (ratio < 1) {
      $(this).width("80px");
      var afterheight = 80 * ratio;
      $(this).height(afterheight + "px");
      left = 0;
      top = 40*(1 - ratio)/2;
    } else if (ratio = 1) {
      $(this).width("80px");
      $(this).height("80px");
      top = 0;
      left = 0;
    } else {
      $(this).height("80px");
      var afterwidth = 80 * ratio;
      $(this).width(afterwidth + "px");
      top = 0;
      left = 40*(1 - ratio)/2;
    }
    $(this).css("top",top + "px");
    $(this).css("left",left + "px");
    $(this).show();
  });
}
$(function(){resizeLayout();});

// $(window).load(function(){resizeLayout();});
// $(window).unload(function(){resizeLayout();});
