function Capitalize(Str: string): string;
var Index: Cardinal;
begin
for Index := 1 to Length(Str) do
if (Index = 1) or (Str[Index - 1] = ' ') then
if Str[Index] in ['a'..'z','á','é','í','ó','ú','ñ'] then
Dec(Str[Index], 32) else
else
if Str[Index] in ['A'..'Z','Á','É','Í','Ó','Ú','Ñ'] then
Inc(Str[Index], 32);
Result := Str;
end;