function h=HinkJ(t,s,j)
% HinkJ	- Returns enthalpies for compounds listed in cnms: kJ/mol
%
% HinkJ calculates the enthalpy of cmpds in state: s and at
%       temperature: t relative to the elements used to form
%	     them.  Elements are taken to be in their normal states 
%       at 25 degrees C.
% Returns the enthalpy of each specified compound in kJ/mol
% Must execute start301 and load data for mass and energy balances
% See also mHinkJ
%
% function h=HinkJ(t,s,j)
% Argument   Gives
%    t      temperature in units of Tdeg.
%    s      State: 'v', 'l' or 's'.
%    j      Indices of compounds in cnms
%           that are to be found.  If the
%           3rd argument is omitted, all are found.
%
% Example: After executing start301 with the cmpds in this order:
%	     benzene, water, carbon, bromine:
%	>>HinkJ(300,'v');   this will find vapor enthalpies for all cmpds
%	>>HinkJ(300,'l',[1 2 4]);  this will find liquid enthalpies for 
%     cmpds 1,2,4
%
% OKB, revised help by TYLC, SHD, & MAH

global cnms hcpl hcpv hcps nc
if s=='v'
   Hcp=hcpv;
elseif s=='l'
   Hcp=hcpl;
elseif s=='s'
   Hcp=hcps;
else
   disp('Error in state variable to HinkJ')
   if ischar(s)
      disp(['State was given as ',s])
   else
      disp('The second argument is not a string.')
   end
   return
end
if nargin==2
   j=1:nc;
end
TK=at(t);
h=[];
for i=j
   h=[h,(polyval(Hcp(i,:),TK))];
end
