function frontScreen(win,message,fixationflag,countDownTime,triggerTime);
% frontScreen: present a front screen for an experiment
%
% Usage: frontScreen(win,message,[fixationflag],[countDownTime],[triggerTime]);
%
%
%
% written 1/14/03 by ras
if ~exist('fixationflag','var')		fixationflag = 0;		end
if ~exist('countDownTime','var')		countDownTime = 10;	end
if ~exist('triggerTime','var')		triggerTime = 1;		end

if ~iscell(message)
	message= {message};
end

if fixationflag
	message{end+1} = 'Keep your eyes fixated on the red cross.';
end

%%%%% parameters %%%%%%%%%%%%%%%%%%
textColor = 225;	% color in lookup table for textColor
backgnd = 127;		% color in lookup table for background
lineHeight = 50;		% size in pixels for each line
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

scratch = screen(win,'OpenOffScreenWindow');
screen(scratch,'TextSize',24);
screen(win,'FillRect',backgnd);
screen(win,'TextSize',24);
HideCursor;

rect = screen(win,'Rect');
X = rect(3); Y = rect(4);
numLines = length(message);
yStart = round(Y/2 - lineHeight*(numLines-1)/2); 
yEnd = round(Y/2 + lineHeight*(numLines-1)/2);
yVals = yStart:lineHeight:yEnd;

for lineNum = 1:numLines
	newX = screen(scratch,'DrawText',message{lineNum},0,0,textColor);
	xPos = round(X/2-newX/2);
	yPos = yVals(lineNum);
	screen(win,'DrawText',message{lineNum},xPos,yPos,textColor);
end

ScreenNum = screen(win,'WindowScreenNumber');
if ScreenNum > 0	% if presenting on a screen other than first screen
	disp('Press any key to begin experiment...');
end

% Wait for any key press to begin run
keycode = zeros(1,128); keydown = 0;
while keydown==0 %keycode(50)==0	
	[keydown,temp,keycode] = kbcheck;
end

% display = loadDisplayParams;
display.rect = rect; display.windowPtr = win;
tic
countdown2(display,countDownTime,triggerTime);
toc;
% showCursor;

return
