
function setupBoxWidth(){
    if ($('#bbox_cnt').length) {
     
    container = document.getElementById('bbox_cnt');

    resizeWidth();


    var num = Math.floor(contanerWidth/186);
    widz = 100/num + "%";
    if(document.getElementsByClassName){
        elements = container.getElementsByClassName('cat_element');
    }else{
        elements = [];
        for(var k = 0; k < container.getElementsByTagName('div').length; k++){
            elem = container.getElementsByTagName('div')[k];
            if(elem.className == 'cat_element'){
                elements.push(elem);
            }
        }
    }
/*
    for(var i = 0; i < elements.length; i++){
        elements[i].style.width = widz;
    } */
    for(var j = 0; j < elements.length; j+=num){
        h = 0;
        for(var i = j; i < (j+num < elements.length ? j+num : elements.length); i++){
            h = Math.max(h, elements[i].getElementsByTagName('div')[0].clientHeight);
        };
        for(var i = j; i < (j+num < elements.length ? j+num : elements.length); i++){
	        //elements[i].getElementsByTagName('div')[0].getElementsByTagName('div')[3].style.height = h+"px";
	        elements[i].getElementsByTagName('div')[0].style.height = h+"px"; // Высота авто для рамки, т.е. по контенту

        };
    }
    document.getElementById('hidden_box').style.visibility = "visible";
}
}
function resizeWidth() {
  if ($('#bbox_cnt').length) {
    container = document.getElementById('bbox_cnt');

    contanerWidth=container.offsetWidth;
    var cat = $('.spec-table');
    var lis = cat.find('.cat_element');
    function set_cat_width (n) {
        lis.each(function(){
           $(this).width((container.offsetWidth / n) - 10); 
           //$(this).width((container.offsetWidth / n) + 0); 
        });
        /*for (var i=0;i<lis.length;i++) {
        lis[i].style.width = ((container.offsetWidth / n) - 10) + 'px';
        }*/
    }

    var width = document.body.clientWidth;
     if (width<1000) {
        set_cat_width (2); 
     }
      else
     if (width < 1250) {
    set_cat_width (3);
    } else if (width < 1440) {
     set_cat_width (4);
     } else {
     set_cat_width (5);
     }

  }
}
function imgResize() {
    $('.b-table-images').each(function(){
        var width=$(this).width();
        if (!$.browser.msie) 
        
        $(this).css({width:'85%',maxWidth:width});
        /*if ($(this).width()>width) {
            $(this).width(width);
        }    */
        /*$(window).bind('resize',function(){
            if ($(this).width()>width) {
               $(this).width(width);
            }
        });
        $(this).resize(function(){
            

        });  */
    });
}
//$(window).bind('resize',setupBoxWidth);
window.onresize = setupBoxWidth;
 window.onload=function(){setupBoxWidth();imgResize();};


