$(document).ready(function() {
    calculateContainers();
});



function calculateContainers() {
  if (layout<9) {
    var conH=new Array();
	for(var ch=1;ch<=7;ch++) {
	  var cont="containerModule"+ch;
      if (document.getElementById(cont)) conH[ch]=document.getElementById(cont).offsetHeight;
	else conH[ch]=0;

 //     document.getElementById(cont).style.minHeight=0;
 //     document.getElementById(cont).style.height=conH[ch];
	}
    var max=conH[3];
	if (max<conH[2]+conH[4]) max=conH[2]+conH[4];
	if (max<conH[2]+conH[5]+conH[6]) max=conH[2]+conH[5]+conH[6];
	if (max<conH[2]+conH[5]+conH[7]) max=conH[2]+conH[5]+conH[7];
	conH[3]=max;
	conH[4]=max-conH[2];
	conH[6]=max-conH[2]-conH[5];
	conH[7]=max-conH[2]-conH[5];
	if (document.all) {
    document.getElementById("containerModule3").style.height=conH[3];
    document.getElementById("containerModule4").style.height=conH[4];
    document.getElementById("containerModule6").style.height=conH[6];
    if (document.getElementById("containerModule7")) document.getElementById("containerModule7").style.height=conH[7];
	}
	else {
    document.getElementById("containerModule3").style.minHeight=conH[3];
    document.getElementById("containerModule4").style.minHeight=conH[4];
    document.getElementById("containerModule6").style.minHeight=conH[6];
    if (document.getElementById("containerModule7")) document.getElementById("containerModule7").style.minHeight=conH[7];
	}
//	alert(max);
  }
  else if ((layout==9) || (layout==11)) {
    var conH=new Array();
    for(var ch=1;ch<=6;ch++) {
      var cont="containerModule"+ch;
      conH[ch]=document.getElementById(cont).offsetHeight;
    }
    conH[99]=document.getElementById("containerMenu").offsetHeight;
//alert(conH[99]);
    var max=conH[3]+conH[99];
    if (max<conH[4]+conH[5]) max=conH[4]+conH[5];
    if (max<conH[4]+conH[6]) max=conH[4]+conH[6];
    if (max<conH[2]) max=conH[2];
    conH[2]=max;
    conH[3]=max-conH[99];
    conH[5]=max-conH[4];
    conH[6]=max-conH[4];
    if (document.all) {
         document.getElementById("containerModule2").style.height=conH[2];
         document.getElementById("containerModule3").style.height=conH[3];
         document.getElementById("containerModule5").style.height=conH[5];
         document.getElementById("containerModule6").style.height=conH[6];
	}
	else {
         document.getElementById("containerModule2").style.minHeight=conH[2];
         document.getElementById("containerModule3").style.minHeight=conH[3];
         document.getElementById("containerModule5").style.minHeight=conH[5];
         document.getElementById("containerModule6").style.minHeight=conH[6];
    }
  }
  else {
    var conH=new Array();
    for(var ch=1;ch<=6;ch++) {
      var cont="containerModule"+ch;
      if(document.getElementById(cont)) conH[ch]=document.getElementById(cont).offsetHeight;
	else conH[ch]=0;
    }
    conH[99]=document.getElementById("containerMenu").offsetHeight;
//alert(conH[99]);
    var max=conH[3]+conH[99];
    if (max<conH[2]+conH[5]) max=conH[2]+conH[5];
    if (max<conH[2]+conH[6]) max=conH[2]+conH[6];
    if (max<conH[4]) max=conH[4];
    conH[4]=max;
    conH[3]=max-conH[99];
    conH[5]=max-conH[2];
    conH[6]=max-conH[2];
    if (document.all) {
         document.getElementById("containerModule4").style.height=conH[4];
         document.getElementById("containerModule3").style.height=conH[3];
         document.getElementById("containerModule5").style.height=conH[5];
         document.getElementById("containerModule6").style.height=conH[6];
	}
	else {
         document.getElementById("containerModule4").style.minHeight=conH[4];
         document.getElementById("containerModule3").style.minHeight=conH[3];
         document.getElementById("containerModule5").style.minHeight=conH[5];
         document.getElementById("containerModule6").style.minHeight=conH[6];
    }
  }
}
