function printalgae(direction,filename)

%% Applies white background (export setup > apply),
%       changes page options to color, 
%       manual position and orientation (page setup),
%       saves as an eps file.
%       then prints it in Algae
%
% Input:     Direction = 'landscape' or 'portrait' ('l' or 'p' works ok)
%            Filename = optional input.  Any filename to save it as 
%               (ie 'temperature_diagram').  If specified it doesn't print
%               it - just saves it in a directory called figures.
%
% Output: A print to Algae
%         A saved 'filename'.eps (if specified)  
%
%   If no filename is specified it saves as an esp called 'currentfigure',
%   prints, then deletes 'currentfigure' file. 
%
% Note: -dpdf, -dpng, and -djpeg don't work on Algae when printing from 
%   linux command line - Always saves then prints it as an eps file

% Written by Kieran Helm (25-10-2006)


        if strncmp('landscape',direction,1)==1
            set(gcf,...
              'Color',[1 1 1],...
              'InvertHardcopy','off',...
              'PaperOrientation','landscape',...
              'PaperPosition',[0.6589 0.9758 27.78 19.26],...
              'PaperSize',[29.68 20.98]);
        elseif strncmp('portrait',direction,1)==1
            set(gcf,...
              'Color',[1 1 1],...
              'InvertHardcopy','off',...
              'PaperPosition',[0.6682 7.661 19.73 15.69],...
              'PaperSize',[20.98 29.68]);
        end

        
%% Save file, print to algae, then delete (if no file name given)
if nargin==2;   % Save in dir figures - don't print on algae
    current_dir=pwd;
%     cd /v/kphelm/matlab/figures/
     print('-depsc',filename) % best
    
%     print('-dpng',filename)
%     print('-dtiff',filename)
%     print('-djpeg',filename)    
%    print('-dpdf',filename)  % works well 
%     eval(['cd ',current_dir])
else
    print('-depsc','currentfigure')
    !lpr -PAlgae currentfigure.eps
    !rm currentfigure.eps 
end

