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','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y',
'z','á','é','í','ó','ú','ñ'] then
Dec(Str[Index], 32) else
else
if Str[Index] in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y',
'Z','Á','É','Í','Ó','Ú','Ñ'] then
Inc(Str[Index], 32);
Result := Str;
end;