function [TS_new,h1]=line_overlay(ax,frac,y3,TS,TS_lims,col,iitop,fmt, ...
	lwidth,fname,ptsize,iibold,dash,ii_hor_ax)
%
% Call line_overlay(ax,frac,y3,TS,TS_lims,col,iitop,fmt,lwidth,fname,ptsize,iibold)
%
% Overlays TS(y3) on vertical axis, using frac of width.
%
% TS_lims		= [min,max] TS to plot;
% col			= color of plot;
% iitop			= 1 to place at top, 0 at bottom;
% fmt			= format for [min,max] labels ([]=no labels or dots);
% lwidth		= line width;
% fname			= font name;
% ptsize		= font size;
% iibold		= 1 for bold;
% dash			= line type '-','--',':'
%
if nargin<6, col='r'; end
if nargin<7, iitop=1; end
if nargin<8, fmt='%2.2f'; end
if nargin<9, lwdith=2; end
if nargin<10, fname='Arial'; end
if nargin<11, ptsize=14; end
if nargin<12, iibold=1; end
if nargin<13 | isempty(dash), dash='-'; end
if nargin<14, ii_hor_ax=0; end
% Overlay line plot of TS(y3):
hold on;
if ii_hor_ax,
	xmin=ax(3); xmax=ax(3) + frac*(ax(4)-ax(3));
	fac=(xmax-xmin)/(TS_lims(2)-TS_lims(1));
	TS_new=xmin + (TS-TS_lims(1))*fac;
	%
	% Do not plot anything outside of TS_lims:
	iibad=find(TS<TS_lims(1) | TS>TS_lims(2));
	TS_new(iibad)=NaN;
	%
	h1=plot_cfill(y3,TS_new,'none',col,5,dash,lwidth);
	if iibold, iib='Bold'; else, iib='Normal'; end
	%
	if ~isempty(fmt),
		TS_low=sprintf(fmt,TS_lims(1));
		TS_hi=sprintf(fmt,TS_lims(2));
		if iitop, iiy=1; valign='Bottom'; else; iiy=length(y3); valign='Top'; end
		h2=plot_cfill([y3(iiy),y3(iiy)],[xmin,xmax],'o',col,8);
		h3=text(y3(iiy),xmin,TS_low,'VerticalAlignment',valign, ...
			'FontName',fname,'FontSize',ptsize,'FontWeight',iib,'Color',col);
		h4=text(y3(iiy),xmax,TS_hi,'VerticalAlignment',valign, ...
			'FontName',fname,'FontSize',ptsize,'FontWeight',iib,'Color',col);
		h1=[h1;h2;h3;h4];
	end
else
	xmin=ax(1); xmax=ax(1) + frac*(ax(2)-ax(1));
	fac=(xmax-xmin)/(TS_lims(2)-TS_lims(1));
	TS_new=xmin + (TS-TS_lims(1))*fac;
	%
	% Do not plot anything outside of TS_lims:
	iibad=find(TS<TS_lims(1) | TS>TS_lims(2));
	TS_new(iibad)=NaN;
	%
	h1=plot_cfill(TS_new,y3,'none',col,5,dash,lwidth);
	if iibold, iib='Bold'; else, iib='Normal'; end
	%
	if ~isempty(fmt),
		TS_low=sprintf(fmt,TS_lims(1));
		TS_hi=sprintf(fmt,TS_lims(2));
		if iitop, iiy=1; valign='Bottom'; else; iiy=length(y3); valign='Top'; end
		h2=plot_cfill([xmin,xmax],[y3(iiy),y3(iiy)],'o',col,8);
		h3=text(xmin,y3(iiy),TS_low,'VerticalAlignment',valign, ...
			'FontName',fname,'FontSize',ptsize,'FontWeight',iib,'Color',col);
		h4=text(xmax,y3(iiy),TS_hi,'VerticalAlignment',valign, ...
			'FontName',fname,'FontSize',ptsize,'FontWeight',iib,'Color',col);
		h1=[h1;h2;h3;h4];
	end
end
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
