const
	script_name='Allocine';
	language='French';
	version=16;
	author='Vlad/JeF';
	MinProgramBuild=5500;
	PCount = 12;
	//MAX_PHOTOS_COUNT = 3;
var
	DownloadPersonBiography, DownloadPersonAdditionalInfo: boolean;
	MaxPhotosCount: integer;

	persons_count: integer;
	persons: array of string;
	imdb_codes: array of string;
	imdb_code, person_code: string;
	name, code, year, description: string;
	person, BasicURL, biography, trivia, character, birth_date, birthplace, birth_name, salary, height, original_name, death_date, person_site_url: string;
	photo_url: string;
	monthes: array [1..12] of string;
	prefixes: array [1..PCount] of string;
	movie_html, PhotosURL: string;
	person_height: integer;
	pictures_exist: boolean;

	OvrMainDlOptions, DlOriginalName, DlPersonHeight, DlBirthDate, DlBirthPlace, DlDeathDate, DlBiography, DlPersonDesc : boolean;
	DlFilmoAsActor, DlFilmoAsDirector, DlFilmoAsWriter, DlFilmoAsComposer : boolean;
	
function GetSearchURLbyName(PersonName: string): string;
var
	url: string;
begin
	url:=format('http://www.allocine.fr/recherche/5/?q=%s', [PersonName]);
	url:=ReplaceStr(url, ' ', '+', -1);
	result:=url;
end;

//Download search results from URL
function DownloadSearchURL(url: string): integer;
begin
	all:=DownloadURL(url);
	if all='-1' then
		result:=-1
	else
		result:=PersonSearch;
end;

function PersonSearch: integer;
var
	url, s, s2, small_photo, original_name, description: string;
	i, j, k, l: integer;
begin
	persons_count:=0;

	s:='';	
	i:=pos('Stars</h2>', all);
	if i>0 then begin
		j:=MyPos('</table>', all, i+1);
		if j>0 then
			s:=copy(all, i, j-i);
	end;
	
	if (s='') or (pos('on n''a pas trouv', all)>0) then
		//Person not found
	else begin
	  i:=pos('<a href=''/personne/', s);
	  while i>0 do begin
			//small photo of the person
			j := MyPos('</a>', s, i+1);
			s2 := copy(s, i, j-i);
			small_photo := ParseString(s2, 'src=''http://images.allocine.fr/(.*?).jpg', 1);
			if small_photo<>'' then
				small_photo := 'http://images.allocine.fr/' + small_photo + '.jpg';
			delete(s, 1, i+5);
			i:=Pos('<a href=''/personne/', s);
			persons_count:=persons_count+1;
			SetLength(persons, persons_count);
			j:=MyPos('</tr>', s, i);
			s2:=copy(s, i, j-i);
			person_code:=ParseString(s2, '/personne/fichepersonne_gen_cpersonne=(\d+).html', 1);
			
			//original name
			original_name := '';
			k := Pos('NГ©(e) : ', s2);
			if k>0 then begin
				l := MyPos(#10, s2, k+1);
				original_name := copy(s2, k+9, l-k-9);
				original_name := DecodeHTML(original_name);
				original_name := ClearExtraBlankCharacters(original_name);
			end;
			
			description := ParseString(s2, '<span class="fs11">(.*?)<br />', 1);
			description := ClearExtraBlankCharacters(description);
			description := RemoveTags(description);
			description := DecodeHTML(description);

			//name
			k := Pos('</a>', s2);
			name := copy(s2, 1, k-1);			
			name:=RemoveTags(name);
			name:=ClearExtraSpaces(name);
			while (length(name)>0) and (name[1]=' ') do
				delete(name, 1, 1);
			SetSearchResult2(name, person_code, '', original_name, description, small_photo);
			delete(s, 1, j);
			i:=pos('<a href=''/personne/', s);
		end;
	end;
	result:=persons_count;
end;

function GetPersonURL(code: string; images_only: boolean): string;
begin
	result:=format('http://www.allocine.fr/personne/fichepersonne_gen_cpersonne=%s.html', [code])
end;

procedure GetShots;
var
	i, j, shots_cnt: Integer;
	url, s, s2, image_code, image_url: String;
begin
	shots_cnt := 0;
	all := GetHTMLPageContentFromRequest(PhotosURL);
	s := '<a href="/personne/fichepersonne-'+person_code+'/photos/detail';
	i := Pos(s, all);
	while (i>0) and (shots_cnt<=MaxPhotosCount) do begin
		shots_cnt := shots_cnt + 1;
		j := MyPos('</a>', all, i+1);
		s2 := copy(all, i, j-i);
		image_code := ParseString(s2, '"http://images.allocine.fr/c_100_100/.*?/medias/nmedia/(.*?).jpg"', 1);
		if image_code <> '' then begin
			image_url := 'http://images.allocine.fr/r_760_x/medias/nmedia/'+image_code+'.jpg';
			SetImageName('', image_url, '', 6);
		end;
		delete(all, 1, j);
		i := Pos(s, all);
	end;		
end;


//returnes images links
procedure GetImages;
var
	min_photos: Integer;
begin
	min_photos := 0;
	if photo_url<>'' then begin
		SetImageName('', photo_url, '', 6);
		min_photos := 1;
	end;
	if (pictures_exist) and (MaxPhotosCount>min_photos) then 
		GetShots;
	//GetGoogleImage;
end;

function GetGoogleImage: boolean;
var
	all, url: string;
	i, j: integer;
begin
	url:=format('http://images.google.com/images?svnum=20&hl=en&lr=&safe=on&c2coff=1&q=%%22%s%%22', [person]);
	url:=ReplaceStr(url, ' ', '+', -1);
	all:=DownloadURL(url);
	i:=pos('dyn.Img(', all);
	if i>0 then begin
		i:=MyPos('","', all, i+1);
		i:=MyPos('","', all, i+1);
		i:=MyPos('","', all, i+1) + 3;
		j:=MyPos('","', all, i+1);
		if j>0 then begin
			url:=copy(all, i, j-i);
			SetImageName('', url, '', 6);
		end;
	end;
end;

function SavePhoto(url, FileName: string): boolean;
var
	fs: TFileStream;
	s: string;
begin
	s:=DownloadURL(url);
	if (length(s)>0) and (s<>'-1') then begin
		try
			fs:=TFileStream.Create(FileName, fmCreate);
			fs.Write(s, Length(s));
			fs.Free;
			result:=true;
		except
			result:=false;
		end;
	end
	else
		result:=false;
end;

function MovePrefixLeft(name: string): string;
var
	i, j: integer;
begin
	// replace "The", "A", "An"... to the left
	for j:=1 to PCount do
	begin
		i:=pos(', '+Prefixes[j], name);
		if i>0 then
			if (i = length(name)-length(Prefixes[j])-1) or
			(length(name) >= i+2+length(Prefixes[j])) and (name[i+2+length(Prefixes[j])]=':') then
			begin
				if Prefixes[j][length(Prefixes[j])] = '''' then
					name := Prefixes[j] + copy(name, 1, i-1) + copy(name, i+length(Prefixes[j])+2, length(name)-i-length(Prefixes[j])-2+1)
				else
					name := Prefixes[j]+' ' + copy(name, 1, i-1) + copy(name, i+length(Prefixes[j])+2, length(name)-i-length(Prefixes[j])-2+1);
				break;
			end;
	end;
	Result := name;
end;

function ClearBrackets(name: string): string;
var
	i: integer;
begin
	// clear word in brackets at the end of name
	i := pos(' (', name);
	if i>0 then
		name := copy(name, 1, i-1);
	Result := name;
end;

function ClearExtraQuotes(name: string): string;
begin
	// Clears extra quotes «"»
	if length(name)>0 then
		if (name[1]='"') and (name[length(name)]='"') then
			name := copy(name,2,length(name)-2);
	Result := name;
end;

function MyRemoveTags(s: string): string;
var
	i, j: integer;
begin
	i:=pos('<br /><br />', s);
	while i>0 do begin
		delete(s, i, 6);
		i:=pos('<br /><br />', s);
	end;
	i:=pos('<', s);
	while i>0 do begin
		if i=MyPos('<br />', s, i) then
			i:=MyPos('<', s, i+1)
		else begin
			j:=MyPos('>', s, i+1);
			delete(s, i, j-i+1);
			i:=MyPos('<', s, i);
		end;
	end;
	result:=s;

end;

function ExtractDate(s: string): string;
var
	i, j: integer;
	day, month, year: string;
begin
	s := RemoveTags(s);
	s := ClearExtraBlankCharacters(s);
	day:=ParseString(s, '^(\d+) ', 1);
	if day='' then
		//no date
	else begin
		j:=pos(day, s);
		delete(s, 1, j+length(day));
		month:=ParseString(s, '^(.*?) ', 1);
		if month<>'' then begin
			j:=pos(month, s);
			delete(s, 1, j+length(month));
			year:=ParseString(s, '^(\d+) ', 1);
			if year='' then
				year:=ParseString(s, '^(\d+)$', 1);
		end;
		i:=1;
		while (i<=12) and (LowerCase(monthes[i])<>LowerCase(month)) do begin	
			i:=i+1;
		end;
		if (i<=12) and (month<>'') then
			result:=IntToStr(i)+format('/%s/%s', [day, year]);
	end;
	if (day='') or (month='') or (year='') then
		result:=''
end;

function GetInfo(url: string; images_only: boolean): string;
var
	s, s2, s3, s4, day, month, year, FilmoURL, BioURL, temp: string;
	i, j, k, l, ke, mode: integer;
	not_last: boolean;
begin
	result:='';
	BasicURL:=url;
	PhotosURL := '';
	person_code:=ParseString(url, 'http://www.allocine.fr/personne/fichepersonne_gen_cpersonne=(\d+).html', 1);
	person_site_url:=GetPersonSiteURL(person_code);
	all:=DownloadURL(url);
	if all='-1' then
		result:='-1'
	else
		result:=all;
		
	FilmoURL:='http://www.allocine.fr/personne/filmographie_gen_cpersonne='+person_code+'.html';
	AddRequestForHTMLPageContent(FilmoURL, False);
	
	BioURL := '';
	if DownloadPersonBiography or (OvrMainDlOptions and DlBiography) then begin
		BioURL := 'http://www.allocine.fr/personne/fichepersonne-' + person_code + '/biographie/';
		AddRequestForHTMLPageContent(BioURL, False);
	end;
	
	//Galerie
	pictures_exist:=false;
	s := 'personne/fichepersonne-'+person_code+'/photos/';
	i:= pos(s, all);
	if i>0 then
		pictures_exist:=true;
	if pictures_exist and (MaxPhotosCount > 0) then begin
		PhotosURL := 'http://www.allocine.fr/personne/fichepersonne-'+person_code+'/photos/';
		AddRequestForHTMLPageContent(PhotosURL, False);
	end;


	//name
	person := ParseString(all, '<h1.*?>(.*?)</h1>', 1);
	person := ClearExtraBlankCharacters(DecodeHTML(person));


	original_name:='';
	biography:='';
	birth_date:='';
	birthplace:='';
	death_date:='';
	
	//biography
	if DownloadPersonBiography or OvrMainDlOptions then begin
		if DlBiography then begin
			temp := GetHTMLPageContentFromRequest(BioURL);
			s := GetStr(temp, 'Sa biographie'#10, '<div class="breaker"');
			i := Pos('</ul>', s);
			if i>0 then
				delete(s, 1, i-1);
			s := ReplaceStr(s, '<br />', #13#10, -1);
			biography:=DecodeHTML(RemoveTags(s));
			biography:=ClearExtraBlankCharacters(biography);
		end;
	end;
	
	//photo
	i := Pos('<div class="poster">', all);
	if i>0 then begin
		j := MyPos('</div>', all, i + 1);
		s := copy(all, i, j-i);
		photo_url:=ParseString(s, ' src=''(.*?)''', 1);
		if (Pos('emptymedia', photo_url)>0) then
			photo_url := '';
	end;
	
	
	//birth date and place
	s := GetStr(all, 'Naissance', '</li>');
	if s<>'' then begin
		birthplace := GetStr(s, '(', ')');
		s2 := GetStr(s, ' content="', '"');
		day := ParseString(s2, '-(\d+)$', 1);
		month := ParseString(s2, '-(\d+)-', 1);
		year := ParseString(s2, '^(\d+)-', 1);
		if (day<>'') and (month<>'') and (year<>'') then
			birth_date := format('%s/%s/%s', [month, day, year]);
	end;
	
	//original name
	original_name := '';
	s := GetStr(all, 'Nom de naissance', '</li>');
	if s<>'' then
		original_name := ClearExtraBlankCharacters(DecodeHTML(RemoveTags(s)));
		
	//death date
	s := GetStr(all, '>Décès', '</li>');
	if s<>'' then begin
		s2 := GetStr(s, ' content="', '"');
		day := ParseString(s2, '-(\d+)$', 1);
		month := ParseString(s2, '-(\d+)-', 1);
		year := ParseString(s2, '^(\d+)-', 1);
		if (day<>'') and (month<>'') and (year<>'') then
			death_date := format('%s/%s/%s', [month, day, year]);
	end;

	//loading filmography
	
	all:=GetHTMLPageContentFromRequest(FilmoURL);
	
	//filmography
	i:=pos('<h1>Filmographie', all);
	if i>0 then begin
		j:=MyPos('<div class="social">', all, i+1);
		s2:=copy(all, i, j-i);
		i := Pos('<h2 ', s2);
		while i>0 do begin
			j := MyPos('</table>', s2, i+1);
			s3 := copy(s2, i, j-i);
			delete(s2, 1, j);
			if (Pos('Réalisation</h2>', s3)>0) then
				mode := 1
			else if (Pos('Acteur</h2>', s3)>0) or (Pos('Actrice</h2>', s3)>0) then
				mode := 3
			else if (Pos('Scénario</h2>', s3)>0) then
				mode := 2
			else if (Pos('Equipe Technique</h2>', s3)>0) then
				mode := 4
			else
				mode := 0;
			k:=pos('<tr>', s3);
			while (k>0) do begin
				l:=MyPos('</tr>', s3, k+4);
				s4:=copy(s3, k, l-k);
				code:=ParseString(s4, ' href="/film/fichefilm_gen_cfilm=(\d+).html', 1);
				name:=GetStr(s4, '<a class=', '/a>');
				if name = '' then
					name := GetStr(s4, '<span class', '/span>');
				name:=GetStr(name, '>', '<');
				name:=RemoveTags(name);
				name:=ClearExtraBlankCharacters(name);
				year:=GetStr(s4, '<td class="lighten">', '</td>');
				year:=ClearExtraBlankCharacters(year);
				ke := Pos(' en ', year);
				while ke>0 do begin
					delete(year, 1, ke+3);
					ke := Pos(' en ', year);
				end;
				if length(year) < 4 then
					year := '';
				if LowerCase(year)='prochainement' then year:='';
				character := GetStr(s4, '</a>', '<div ');
				character := ClearExtraBlankCharacters(RemoveTags(character));
				if character = '-' then
					character := '';
				if (name <> '') then begin
					if DlFilmoAsDirector and (mode = 1) then
						SetMovieName(name, '', mode, code, year);
					if DlFilmoAsWriter and (mode = 2) then
						SetMovieName(name, '', mode, code, year);
					if DlFilmoAsComposer and (mode = 4) and (Pos('Compositeur', character)>0) then
						SetMovieName(name, '', mode, code, year);
					if DlFilmoAsActor and (mode = 3) then
						SetMovieName(name, character, mode, code, year);
				end;
				delete(s3, 1, l-1);
				k:=pos('<tr>', s3);
			end;
			i := Pos('<h2 ', s2);
		end;
	end;
	
	
end;

//get movie site url
function GetPersonSiteURL(code: string): string;
begin
	if code='' then
		result:=''
	else
		result:='http://www.allocine.fr/personne/fichepersonne_gen_cpersonne='+code+'.html';
end;

//get movie site url
function GetMovieSiteURL(code: string): string;
begin
	if code='' then
		result:=''
	else
		result:='http://www.allocine.fr/film/fichefilm_gen_cfilm='+code+'.html';
end;

function ClearExtraBlankCharacters(text: string): string;
begin
	// Clear all extra blank charackters
	while (length(text) > 0) and (ord(text[1]) in [1..32]) do
		delete(text, 1, 1);
	while (length(text) > 0) and (ord(text[length(text)]) in [1..32]) do
		delete(text, length(text), 1);
	Result := text;
end;

function BoolToInt(b: boolean): integer;
begin
  if b then result:=1
  else result:=0;
end;

function IntToBool(intval: integer): boolean;
begin
  if intval < 1 then result := false
  else result := true;
end;

function GetStr(str: String; s1: String; s2: String): String;
var
  I: Integer;
  J: Integer;
begin
  // Вырезает кусок строки между s1 и s2
	Result := '';
	I := Pos(s1, str);
	if I > 0 then
	begin
		J := MyPos(s2, str, I + Length(s1));
		if J > 0 then
  		Result := Copy(str, I + Length(s1), J - I - Length(s1));
	end;
end;

//show available settings for the script
function ShowScriptOptions: integer;
var
	s: string;
	f: TForm;
	b: TButton;
	cbOvrMainDlOptions, cbDlOriginalName, cbDlBirthDate, cbDlBiography, cbDlBirthPlace, cbDlDeathDate: TCheckBox;
	cbDlPersonDesc, cbDlPersonHeight, cbDlFilmoAsDirector, cbDlFilmoAsActor, cbDlFilmoAsWriter, cbDlFilmoAsComposer: TCheckBox;
	cbAdvSearch: TCheckBox;
	labTitleLang, labMPAADefault, labMPAAReplace, labLocalService, labPicSize, labPicMulti: TLabel;
	edTitleLang, edMPAADefault, edMPAAReplace, edPicSizeX, edPicSizeY: TEdit;
	gbDlOptions: TGroupBox;
	comboLocalService: TComboBox;
	posx, posy, my_value: integer;
	cbTMDBPosters, cbTMDBImages: TCheckBox;

procedure ButtonClick(Sender: TButton);
var
	zn: integer;
begin
	try
		RegWriteInteger('ALLOCINE_OvrMainDlOptions'  , BoolToInt(cbOvrMainDlOptions.Checked));
		RegWriteInteger('ALLOCINE_DlOriginalName'    , BoolToInt(cbDlOriginalName.Checked));
		RegWriteInteger('ALLOCINE_DlPersonHeight'    , BoolToInt(cbDlPersonHeight.Checked));
		RegWriteInteger('ALLOCINE_DlBirthDate'       , BoolToInt(cbDlBirthDate.Checked));
		RegWriteInteger('ALLOCINE_DlBiography'       , BoolToInt(cbDlBiography.Checked));
		RegWriteInteger('ALLOCINE_DlBirthPlace'      , BoolToInt(cbDlBirthPlace.Checked));
		RegWriteInteger('ALLOCINE_DlDeathDate'       , BoolToInt(cbDlDeathDate.Checked));
		RegWriteInteger('ALLOCINE_DlPersonDesc'      , BoolToInt(cbDlPersonDesc.Checked));
		RegWriteInteger('ALLOCINE_DlFilmoAsDirector' , BoolToInt(cbDlFilmoAsDirector.Checked));
		RegWriteInteger('ALLOCINE_DlFilmoAsActor'    , BoolToInt(cbDlFilmoAsActor.Checked));
		RegWriteInteger('ALLOCINE_DlFilmoAsWriter'   , BoolToInt(cbDlFilmoAsWriter.Checked));
		RegWriteInteger('ALLOCINE_DlFilmoAsComposer' , BoolToInt(cbDlFilmoAsComposer.Checked));
	except
	end;

	f.ModalResult := mrOk;
end;

begin
	result:=0;
	f := TForm.Create(nil);
	f.Caption := GetLangStr(1924);
	f.BorderStyle := bsDialog;
	f.Position := poScreenCenter;
	f.Width:=450;
	f.Height:=300;
	f.AutoSize:=false;
	
	posx :=  10;
	posy := -10;
	
	posy := posy + 20;
	cbOvrMainDlOptions := TCheckBox.Create(f);
	cbOvrMainDlOptions.Name := 'cbOvrMainDlOptions';
	cbOvrMainDlOptions.Parent := f;
	cbOvrMainDlOptions.SetBounds(posx, posy, 350, 20);
	if GetLangStr(2744) = '' 
		then cbOvrMainDlOptions.Caption := 'Override Global Download Options (F10)'
	else cbOvrMainDlOptions.Caption := GetLangStr(2744);
	if GetLangStr(2745) = '' 
		then cbOvrMainDlOptions.Hint := 'Override values/flags set in main download options window (F10)'
	else cbOvrMainDlOptions.Hint := GetLangStr(2745);
	cbOvrMainDlOptions.Checked := IntToBool(RegReadInteger('ALLOCINE_OvrMainDlOptions', 0));

	posy := posy + 10;
	gbDlOptions:=TGroupBox.Create(f);
	gbDlOptions.Name:='gbDlOptions';
	gbDlOptions.Parent:=f;
	gbDlOptions.SetBounds(posx, posy + 20, 425, 30);
	gbDlOptions.Caption:=' ' + GetLangStr(2734) + ' ';
	gbDlOptions.Hint:=GetLangStr(2734);
	posy := 0;
	
	posy := posy + 20;
	gbDlOptions.Height := gbDlOptions.Height + 20;
	cbDlOriginalName := TCheckBox.Create(f);
	cbDlOriginalName.Name := 'cbDlOriginalName';
	cbDlOriginalName.Parent := gbDlOptions;
	cbDlOriginalName.SetBounds(posx, posy, 200, 20);
	cbDlOriginalName.Caption := GetLangStr(284);
	cbDlOriginalName.Checked := IntToBool(RegReadInteger('ALLOCINE_DlOriginalName', 1));
		
	posy := posy + 20;
	gbDlOptions.Height := gbDlOptions.Height + 20;
	cbDlPersonHeight := TCheckBox.Create(f);
	cbDlPersonHeight.Name := 'cbDlPersonHeight';
	cbDlPersonHeight.Parent := gbDlOptions;
	cbDlPersonHeight.SetBounds(posx, posy, 200, 20);
	cbDlPersonHeight.Caption := GetLangStr(709);
	cbDlPersonHeight.Checked := IntToBool(RegReadInteger('ALLOCINE_DlPersonHeight', 1));
	//Not available from Allocine site
	cbDlPersonHeight.Checked := False;
	cbDlPersonHeight.Enabled := False;

	posy := posy + 20;
	gbDlOptions.Height := gbDlOptions.Height + 20;
	cbDlBirthDate := TCheckBox.Create(f);
	cbDlBirthDate.Name := 'cbDlBirthDate';
	cbDlBirthDate.Parent := gbDlOptions;
	cbDlBirthDate.SetBounds(posx, posy, 200, 20);
	cbDlBirthDate.Caption := GetLangStr(285);
	cbDlBirthDate.Checked := IntToBool(RegReadInteger('ALLOCINE_DlBirthDate', 1));
		
	posy := posy + 20;
	gbDlOptions.Height := gbDlOptions.Height + 20;
	cbDlBirthPlace := TCheckBox.Create(f);
	cbDlBirthPlace.Name := 'cbDlBirthPlace';
	cbDlBirthPlace.Parent := gbDlOptions;
	cbDlBirthPlace.SetBounds(posx, posy, 200, 20);
	cbDlBirthPlace.Caption := GetLangStr(287);
	cbDlBirthPlace.Checked := IntToBool(RegReadInteger('ALLOCINE_DlBirthPlace', 1));
		
	posy := posy + 20;
	gbDlOptions.Height := gbDlOptions.Height + 20;
	cbDlDeathDate := TCheckBox.Create(f);
	cbDlDeathDate.Name := 'cbDlDeathDate';
	cbDlDeathDate.Parent := gbDlOptions;
	cbDlDeathDate.SetBounds(posx, posy, 200, 20);
	cbDlDeathDate.Caption := GetLangStr(286);
	cbDlDeathDate.Checked := IntToBool(RegReadInteger('ALLOCINE_DlDeathDate', 1));

	gbDlOptions.Height := gbDlOptions.Height + 20;
	
	posx := 220;
	posy := 0;
	
	posy := posy + 20;
	cbDlBiography := TCheckBox.Create(f);
	cbDlBiography.Name := 'cbDlBiography';
	cbDlBiography.Parent := gbDlOptions;
	cbDlBiography.SetBounds(posx, posy, 200, 20);
	cbDlBiography.Caption := GetLangStr(282);
	cbDlBiography.Checked := IntToBool(RegReadInteger('ALLOCINE_DlBiography', 1));

	posy := posy + 20;
	cbDlPersonDesc := TCheckBox.Create(f);
	cbDlPersonDesc.Name := 'cbDlPersonDesc';
	cbDlPersonDesc.Parent := gbDlOptions;
	cbDlPersonDesc.SetBounds(posx, posy, 200, 20);
	cbDlPersonDesc.Caption := GetLangStr(162);
	cbDlPersonDesc.Checked := IntToBool(RegReadInteger('ALLOCINE_DlPersonDesc', 1));
		
	posy := posy + 20;
	cbDlFilmoAsActor := TCheckBox.Create(f);
	cbDlFilmoAsActor.Name := 'cbDlFilmoAsActor';
	cbDlFilmoAsActor.Parent := gbDlOptions;
	cbDlFilmoAsActor.SetBounds(posx, posy, 200, 20);
	cbDlFilmoAsActor.Caption := GetLangStr(289);
	cbDlFilmoAsActor.Checked := IntToBool(RegReadInteger('ALLOCINE_DlFilmoAsActor', 1));
		
	posy := posy + 20;
	cbDlFilmoAsDirector := TCheckBox.Create(f);
	cbDlFilmoAsDirector.Name := 'cbDlFilmoAsDirector';
	cbDlFilmoAsDirector.Parent := gbDlOptions;
	cbDlFilmoAsDirector.SetBounds(posx, posy, 200, 20);
	cbDlFilmoAsDirector.Caption := GetLangStr(290);
	cbDlFilmoAsDirector.Checked := IntToBool(RegReadInteger('ALLOCINE_DlFilmoAsDirector', 1));
		
	posy := posy + 20;
	cbDlFilmoAsWriter := TCheckBox.Create(f);
	cbDlFilmoAsWriter.Name := 'cbDlFilmoAsWriter';
	cbDlFilmoAsWriter.Parent := gbDlOptions;
	cbDlFilmoAsWriter.SetBounds(posx, posy, 200, 20);
	cbDlFilmoAsWriter.Caption := GetLangStr(291);
	cbDlFilmoAsWriter.Checked := IntToBool(RegReadInteger('ALLOCINE_DlFilmoAsWriter', 1));
		
	posy := posy + 20;
	cbDlFilmoAsComposer := TCheckBox.Create(f);
	cbDlFilmoAsComposer.Name := 'cbDlFilmoAsComposer';
	cbDlFilmoAsComposer.Parent := gbDlOptions;
	cbDlFilmoAsComposer.SetBounds(posx, posy, 200, 20);
	cbDlFilmoAsComposer.Caption := GetLangStr(492);
	cbDlFilmoAsComposer.Checked := IntToBool(RegReadInteger('ALLOCINE_DlFilmoAsComposer', 1));
		
	b := TButton.Create(f);
	b.Name := 'btnOK';
	b.Parent := f;
	b.SetBounds(trunc(f.width/2)-40, f.Height-60, 80, 25);
	b.Caption := '&OK';
	b.OnClick := @ButtonClick;

	f.ShowModal;
	f.Free;
end;


begin
	
	monthes[1]:='Janvier';
	monthes[2]:='Fйvrier';
	monthes[3]:='Mars';
	monthes[4]:='Avril';
	monthes[5]:='Mai';
	monthes[6]:='Juin';
	monthes[7]:='Juillet';
	monthes[8]:='Aoыt';
	monthes[9]:='Septembre';
	monthes[10]:='Octobre';
	monthes[11]:='Novembre';
	monthes[12]:='Dйcembre';

	prefixes[1]:='The';
	prefixes[2]:='A';
	prefixes[3]:='An';
	prefixes[4]:='La';
	prefixes[5]:='Les';
	prefixes[6]:='Des';
	prefixes[7]:='L''';
	prefixes[8]:='Un';
	prefixes[9]:='El';
	prefixes[10]:='Il';
	prefixes[11]:='Le';
	prefixes[12]:='Uno';

	OvrMainDlOptions  := IntToBool(RegReadInteger('ALLOCINE_OvrMainDlOptions', 0));
	DlOriginalName    := IntToBool(RegReadInteger('ALLOCINE_DlOriginalName', 1));
	DlPersonHeight    := IntToBool(RegReadInteger('ALLOCINE_DlPersonHeight', 1));
	DlBirthDate       := IntToBool(RegReadInteger('ALLOCINE_DlBirthDate', 1));
	DlBirthPlace      := IntToBool(RegReadInteger('ALLOCINE_DlBirthPlace', 1));
	DlDeathDate       := IntToBool(RegReadInteger('ALLOCINE_DlDeathDate', 1));
	DlBiography       := IntToBool(RegReadInteger('ALLOCINE_DlBiography', 1));
	DlPersonDesc     := IntToBool(RegReadInteger('ALLOCINE_DlPersonDesc', 1));
	DlFilmoAsDirector := IntToBool(RegReadInteger('ALLOCINE_DlFilmoAsDirector', 1));
	DlFilmoAsActor    := IntToBool(RegReadInteger('ALLOCINE_DlFilmoAsActor', 1));
	DlFilmoAsWriter   := IntToBool(RegReadInteger('ALLOCINE_DlFilmoAsWriter', 1));
	DlFilmoAsComposer := IntToBool(RegReadInteger('ALLOCINE_DlFilmoAsComposer', 1));

end.