var oldHandler = window['onload']; // сохраняем старый onload (если есть)
window['onload'] = function() {
   if(typeof(oldHandler) == 'function') {
      oldHandler();
   }
   setHeight(); // наша функция
};
function setHeight() {
   var b1 = document.getElementById('block1');
   var b2 = document.getElementById('block2');
   var b3 = document.getElementById('block3');
   var b4 = document.getElementById('block4');
   if (!b1 || !b2) return;
   var h1 = b1.offsetHeight;
   var h2 = b2.offsetHeight;
   if (h1 > h2) {
      b2.style.height = (h1 - 11) + 'px';
      b1.style.height = (h1 - 11) + 'px';
   }else if (h1 < h2) {
      b1.style.height = (h2 - 11) + 'px';
      b2.style.height = (h2 - 11) + 'px';
   }
   
   if (!b3 || !b4) return;
   var h3 = b3.offsetHeight;
   var h4 = b4.offsetHeight;
   if (h3 > h4) {
      b3.style.height = (h3 - 11) + 'px';
      b4.style.height = (h3 - 11) + 'px';
   }else if (h3 < h4) {
      b3.style.height = (h4 - 11) + 'px';
      b4.style.height = (h4 - 11) + 'px';
   }
}