function [D DMAP] = mapper_dl(d, SchMAX, dSchVec, nCellID, mapper)

D = []; DMAP = [];

% vypocet volneho mista
N = length(d);
fRB0 = 12*7*2 - 8 - 2*12;
fRB1 = 12*7*2 - 8;
I = 0;

while (N>0)
    if(mod(I,10) == 0),
        N = N - sum(dSchVec)*fRB0;
    else
        N = N - sum(dSchVec)*fRB1;
    end
    I = I+2;
end

for i = 0:2:I-1,
    [D DMAP] = ADD_subframe_downlink(D, DMAP, SchMAX, mod(i,20), nCellID, true, true, true, false);
end

N = length(d);
index = 0;
while(index < N)
    for i2 = 1:size(DMAP,2),
        for i = 1:SchMAX,
            if(dSchVec(i) == 1),
                for a = 1:12,
                    if(DMAP((i-1)*12+a,i2) == 0),
                        index = index + 1;
                        if((index) > length(d)),
                            break;
                        end
                        D((i-1)*12+a,i2) = d(index);
                        DMAP((i-1)*12+a,i2) = 6;
                    end
                end
            end
        end
    end
end

% if(mapper.MAP),
%     f = figure('name','Struktura radioveho ramce, schematicky');
%     axes1 = axes('Parent',f,...
%         'YTickLabel',{'0','12','24','36','28','60','71'},...
%         'YTick',[1 13 25 37 49 61 72],...
%         'XTickLabel',0:1:I/2,...
%         'XTick',1:14:14*(I)/2);
%     xlim(axes1,[1 14*(I)/2]);
%     ylim(axes1,[1 72]);
%     view(axes1,[-0.5 90]);
%     grid(axes1,'on');
%     hold(axes1,'all');
%     surf(DMAP,'Parent',axes1,'MarkerSize',0.5,'Marker','.','LineStyle','none',...
%         'FaceColor','texturemap');
% end
% 
% if(mapper.mag),
%     f2 = figure('name','Struktura radioveho ramce, modul');
%     axes1 = axes('Parent',f2,...
%         'YTickLabel',{'0','12','24','36','28','60','71'},...
%         'YTick',[1 13 25 37 49 61 72],...
%         'XTickLabel',0:1:I/2,...
%         'XTick',1:14:14*(I)/2);
%     xlim(axes1,[1 14*(I)/2]);
%     ylim(axes1,[1 72]);
%     view(axes1,[-0.5 90]);
%     grid(axes1,'on');
%     hold(axes1,'all');
%     surf(abs(D),'Parent',axes1,'MarkerSize',0.5,'Marker','.','LineStyle','none',...
%         'FaceColor','texturemap');
% end
% if(mapper.angle),
%     f2 = figure('name','Struktura radioveho ramce, uhel');
%     axes1 = axes('Parent',f2,...
%         'YTickLabel',{'0','12','24','36','28','60','71'},...
%         'YTick',[1 13 25 37 49 61 72],...
%         'XTickLabel',0:1:I/2,...
%         'XTick',1:14:14*(I)/2);
%     xlim(axes1,[1 14*(I)/2]);
%     ylim(axes1,[1 72]);
%     view(axes1,[-0.5 90]);
%     grid(axes1,'on');
%     hold(axes1,'all');
%     surf(angle(D),'Parent',axes1,'MarkerSize',0.5,'Marker','.','LineStyle','none',...
%         'FaceColor','texturemap');
% end