function [hFig,hAx] = PspecMenu(chid,csta,ii,Nwin);
% Usage: [hFig,hAx] = PspecMenu(chid,csta,ii,NcohBand);
%  sets up multiple coherence menu + figure for plotting

[nchid,nt] = size(chid);
%  stmonitr
if nt <=5
   height_1 = 60;
elseif nt<=10
   height_1 = 300/nt;
else
   nt = 30
end
width = 200; height_1 = 50;
height = (nt+4)*height_1;
widthAll = width+(nt+2)*height_1;
loc = [700,300];
rect_fig = [loc widthAll height ];
hFig = figure('Position',rect_fig,...
	'Tag','Coherence Figure',...
	'UserData',ii);
k = 0;

rectN = [rect_fig(3) rect_fig(4) rect_fig(3) rect_fig(4)];
rect_1 = [ width*.15 (nt-k)*height_1+5 width*.75 height_1*.7];

rectN1 = rect_1./rectN;

uicontrol('style','text',...
        'units','normalized',...
	'position',rectN1,...
	'string','CH/STA',...
        'FontWeight','demi')
for k=1:nt
   rect = [ width*.15 (nt-k)*height_1+5 width*.75 height_1*.8];
   rect_2 = [ width*.65 (nt-k)*height_1+5 width*.125 height_1*.8];
   rect_3 = [ width*.85 (nt-k)*height_1+5 width*.125 height_1*.8];

  name = [csta(:,k)' '  ' chid(:,k)' ];
  h1(k) = uicontrol('style','checkbox', ...
     'parent',hFig,...
     'units','normalized',...
     'position',rect./rectN,...
     'string',name,...
     'FontWeight','demi',...
     'value',0,...
     'UserData',k,...
     'tag','SpecCheckBox',...
     'callback','PspecCB');
      
end  %  loop over channels 1:nt

rect = [ width*.1 (nt+2.6)*height_1+5 width*.8 height_1*.8];
h_plot = uicontrol('style','pushbutton', ...
   'parent',hFig,...
   'units','normalized',...
   'position',rect./rectN,...
   'string','PLOT',...
   'FontWeight','demi',...
   'Tag','SpecPlot',...
   'callback','PspecCB');
        
rect = [ width (nt+2.6)*height_1+5 width*.8 height_1*.8];
h_plot = uicontrol('style','radiobutton', ...
   'parent',hFig,...
   'units','normalized',...
   'position',rect./rectN,...
   'string','Full TS',...
   'FontWeight','demi',...
   'Tag','FullTS',...
   'Value',1,...
   'callback','PspecCB');

rect = [ width*.1 (nt+1.5)*height_1+5 width*.4 height_1*.8];
h_NcB = uicontrol('style','text',...
   'parent',hFig,...
   'units','normalized',...
   'position',rect./rectN,...
   'string','# of Windows',...
   'FontWeight','demi',...
   'Tag','NBands text');

rect = [ width*.55 (nt+1.5)*height_1+5 width*.3 height_1*.8];
h_NcB = uicontrol('style','edit',...
   'parent',hFig,...
   'units','normalized',...
   'position',rect./rectN,...
   'string',num2str(Nwin),...
   'FontWeight','demi',...
   'Tag','Nwindows',...
   'Callback','PspecCB');

set(gcf,'Name','Power Spectra');

rEdge = (rect_3(1)+rect_3(3))/rectN(1);
offset = .075;
w = 1-rEdge-1.5*offset;
rectPlotAx = [rEdge+offset .1 w .7];
hAx = axes('Position',rectPlotAx,...
	'FontWeight','demi',...
	'FontSize',12,...
	'box','on', ...
	'tag','R2 PLOT');
