var WorkWidth = 0;
var hb, lb, cb, rb;    /*,  infb, infb2;*/
var float_cb, float_rb;



function my_ini()
{
           hb = document.getElementById('page_header');
           lb  = document.getElementById('content_left_block');
           cb  = document.getElementById('conent_center_block');
           rb  = document.getElementById('content_right_block');
/*
           infb = document.getElementById('my_info_block');
           infb2 = document.getElementById('my_2info_block');
*/
           float_cb = false; float_rb = false;
           lb.style.height =  "auto";
           cb.style.height = "auto";

   my_f();

}



function my_f()
{
// Maximized
          if(((screen.width - hb.clientWidth) < 20) || ( hb.clientWidth >  WorkWidth ))
          {
                 lb.setAttribute("class", "leftblock0");
                 cb.setAttribute("class", "centrblock0");
                 rb.setAttribute("class", "rightblock0");
          }
// Removes the width's accumulated errors for refreshing
          if(hb.clientWidth <  500) {
                  lb.setAttribute("class", "leftblock2");
                  cb.setAttribute("class", "centrblock2");
                  rb.setAttribute("class", "rightblock2");
          }
// All anoter events
           if(rb.offsetTop > cb.offsetTop){ float_rb = true;}else{float_rb = false;}
           if(cb.offsetTop > lb.offsetTop){ float_cb = true;}else{float_cb = false;}

           if(!float_rb && !float_cb){rb.setAttribute("class", "rightblock0");cb.setAttribute("class", "centrblock0"); lb.setAttribute("class", "leftblock0");}
           if(float_rb && !float_cb){rb.setAttribute("class", "rightblock2");cb.setAttribute("class", "centrblock1"); lb.setAttribute("class", "leftblock1");}
           if(float_cb  && float_rb){rb.setAttribute("class", "rightblock2");cb.setAttribute("class", "centrblock2");lb.setAttribute("class", "leftblock2");}

// If float_cb = true, closing the remaining empty space under the left or the right to block
         lb.style.height =  "auto";
         cb.style.height = "auto";

// equalize the height of left and right blocks
           if(float_rb && !float_cb){
                          if(lb.clientHeight <  cb.clientHeight)
                               lb.style.height = cb.clientHeight.toString() + "px";
                          else
                              if(lb.clientHeight > cb.clientHeight)
                                   cb.style.height = lb.clientHeight.toString() + "px";
         }

          WorkWidth  =  hb.clientWidth;
          //showdata();
}

function showdata()
{
      var s = "Maximized:"+  ((screen.width - hb.clientWidth) < 20) +
                  ", Width=" +  WorkWidth  +
                  ", l="  + lb.clientWidth +
                  ", c=" + cb.clientWidth +
                  ", r=" + rb.clientWidth +
                  " Height: " + "l="  + lb.clientHeight  +
                  ", c=" + cb.clientHeight +
                  ", r=" + rb.clientHeight +
                  " CSS: " + lb.getAttribute("class") +
                  ", " + cb.getAttribute("class") +
                  ", " + rb.getAttribute("class");

     infb.innerHTML = s;
     infb2.innerHTML = s;
}
