        function summ_goods_catchild(numMass,summGoods){
                 
                 for(var i = 0; i < massCat.length; i++){
                     if(massCat[i][0] == massCat[numMass][1]){
                        summGoods += parseInt(massCat[i][3]);
                     }
                 
                 }
                 
                 return summGoods;
        }
        
        function name_catchild(numMass){
        
                 var promStr = massCat[numMass][2];  
                 var summGoods = parseInt(massCat[numMass][3]);
                 
                 for(var i = 0; i < massCat.length; i++){
                     if(massCat[i][0] == "0"){
                        if(massCat[i][1] == massCat[numMass][0]){
                           summGoods = summ_goods_catchild(numMass,summGoods);
                           if(summGoods){
                              promStr = '<b><A Href="?id_categories='+massCat[numMass][1]+'" style="color:#1c407e;" name="cat'+massCat[numMass][1]+'">'+massCat[numMass][2]+'</A></b> <font color=#fa7000>['+summGoods+']</font>';
                              return promStr;
                           }
                        }
                     }
                 }
                 
                 if(summGoods)
                    promStr = '<b><A Href="?id_categories='+massCat[numMass][1]+'" style="color:#1c407e;" name="cat'+massCat[numMass][1]+'">'+massCat[numMass][2]+'</A></b> <font color=#fa7000>['+massCat[numMass][3]+']</font>';
                    
                 return promStr;
        }
        
        function show_catchild_all(idParent,numStyle){
                 
                 var promStr = "";
                 numStyle++;
                 
                 if(numStyle == 1){
                    promStr = "<Table Border=0 Width=100% CellSpacing=1 CellPadding=0 style='font-family:tahoma;color:#1c407e;font-size:11px;'>";
                    for(var i = 0; i < massCat.length; i++){
                        if(massCat[i][0] == idParent){
                           promStr += "<Tr VAlign=top BgColor=#d2d8e4><Td Width=30% style='padding:5px'>"+name_catchild(i)+"</Td><Td style='padding:1px'>";
                          // promStr += show_catchild_all(massCat[i][1],numStyle);
                           promStr += "</Td></Tr>";
                           promStr += "<Tr><Td ColSpan=2 BgColor=#639bc3><Img Src='images/pixel.gif' Width=1 Height=1 Border=0 Alt=''></Td></Tr>";
                        }
                    }
                    promStr += "</Table>";    
                 } else {
                    var j = 0;
                    var colTd = 2;
                    promStr = "<Table Width=100% Border=0 CellSpacing=1 CellPadding=2 style='font-family:tahoma;color:#1c407e;font-size:9px;'>";
                    for(var i = 0; i < massCat.length; i++){
                        if(massCat[i][0] == idParent){
                           if(!j) promStr += "<Tr BgColor=#EEEEEE VAlign=top>";
                           promStr += "<Td Width=50%>"+name_catchild(i);
                           promStr += show_catchild_all(massCat[i][1],numStyle);
                           promStr += "</Td>";
                           j++;
                           if(j == colTd) { promStr += "</Tr>"; j = 0; }
                        }
                    }
                    if(j < colTd & j > 0) { for(i = j; i < colTd; i++) promStr += "<Td>&nbsp;</Td>"; promStr += "</Tr>"; }
                    promStr += "</Table>";    
                 }
                 
                 return promStr;
        }
        
        function show_catchild(numMass){
                 
                 var idParent = massCat[numMass][1];
                 var i = 0;
                 var oneTd = "";
                 var promStr = "<Table Border=0 Width=98% Align=center CellPadding=0 CellSpacing=1 style='font-family:tahoma;color:#1c407e;font-size:11px;'>";
                     promStr += "<Tr Height=35><Td ColSpan=2 style='color:#fa7000;font-size:16px'>"+massCat[numMass][2]+"</Td></Tr></Table>";
                     //promStr += "<div Align=center style='display:block;height:200px;width:98%;overflow:auto;background:#FFFFFF;border:0px;scrollbar-dark-shadowcolor:#ffea8b;scrollbar-light-shadow-color:#ffea8b;scrollbar-base-color:#ffea8b;scrollbar-arrow-color:#cccccc;scrollbar-face-color:#ffea8b;scrollbar-shadow-color:#ffea8b;scrollbar-3d-light-color:#ffea8b;'>";
                     promStr += "<Table Border=0 Width=99% Align=right CellPadding=0 CellSpacing=1 style='font-family:tahoma;color:#1c407e;font-size:11px;'>";
                     for(i = 0; i < massCat.length; i++){
                         if(massCat[i][0] == idParent){
                            oneTd = show_catchild_all(massCat[i][1],0);
                            promStr += "<Tr BgColor=#dde2eb VAlign=top>";
                            promStr += "<Td Width=25% BgColor=#ffea8b style='padding:5px;color:#fa7000;font-size:13px;'>"+name_catchild(i)+"</Td><Td>"+oneTd+"</Td>";
                            promStr += "</Tr>";
                            promStr += "<Tr><Td BgColor=#FFFFFF ColSpan=2><Img Src='images/pixel.gif' Border=0 Width=1 Height=5 Alt=''></Td></Tr>";
                         }
                     }
                     promStr += "</Table>";
                     //</div>";
                     
                     document.getElementById("catchild").innerHTML = promStr;
                     document.getElementById("mainbody").innerHTML = "";

        }
        
        function hide_catchild(){
                 
                 document.getElementById("catchild").innerHTML = '';
        }