//Some useful constants
const
 //Script types
 stMovies = 0;
 stPeople = 1; 
 stPoster = 2;
  
 //Script modes
 smSearch   = 0; 
 smNormal   = 1;
 smCast     = 2;
 smReview   = 3;
 smCredits  = 4;
 smPoster   = 5;
 smFinished = 6;
  
 //Parse results
 prError     = 0; 
 prFinished  = 1;
 prList      = 2;
 prListImage = 3;
 prDownload  = 4;
 
 //Download methods
 dmGET  = 0;
 dmPOST = 1;
 
 //Prefix modes
 pmNone   = 0;
 pmEnd    = 1;
 pmBegin  = 2;
 pmRemove = 3; 
  
 //Movie fields
 mfURL         = 0;
 mfTitle       = 1;
 mfOrigTitle   = 2;
 mfAka         = 3;
 mfYear        = 4;
 mfGenre       = 5;
 mfCategory    = 6;
 mfCountry     = 7;
 mfStudio      = 8;
 mfMPAA        = 9;
 mfRating      = 10;
 mfTags        = 11;
 mfTagline     = 12;
 mfDescription = 13;
 mfDuration    = 14;
 mfFeatures    = 15;
  
 //People fields
 pfURL        = 0;
 pfName       = 1;
 pfTransName  = 2;
 pfAltNames   = 3;
 pfBirthday   = 4;
 pfBirthplace = 5;
 pfGenre      = 6;
 pfBio        = 7;
 pfDeathDate  = 8;
  
 //Credits types
 ctActors    = 0;
 ctDirectors = 1;
 ctWriters   = 2;
 ctComposers = 3;
 ctProducers = 4;
  
 //Script data 
 SCRIPT_VERSION = '0.0.0.1'; 
 SCRIPT_NAME    = 'Test';
 SCRIPT_DESC    = 'Test';
 SCRIPT_LANG    = $09; //English
 SCRIPT_TYPE    = stMovies;
 
 BASE_URL    = 'http://www.test.com';
 RATING_NAME = 'Test';
 
 SEARCH_STR  = 'http://www.test.com/search/%s';
 
 CODE_PAGE   = 65001; //Use 0 for Autodetect 

 
//Functions 
function GetCanConfig : Byte;
begin
 Result := 1;
end;

function Configure(LangID : Integer; AppHandle : Cardinal; CustomFields : String) : Byte;
var
 F : TForm;
 L : TLabel;
 ComboBox : TComboBox;
 CheckBox : TCheckBox;
 OKBtn : TButton;
 Ini : TIniFile; 
begin
 //Create and position a window (form)
 F := TForm.Create(nil);
 try
  F.BorderStyle := bsDialog;  
  F.ClientWidth := 200;
  F.ClientHeight := 120;  
  F.Left := 100;
  F.Top := 100;
  F.Caption := 'Test Configuration';
  
  //Create and position controls
  L := TLabel.Create(F);
  L.Parent := F;
  L.Left := 6;
  L.Top := 6;
  L.Caption := 'Select a custom field:';
  
  ComboBox := TComboBox.Create(F);
  ComboBox.Parent := F;
  ComboBox.Left := 6;
  ComboBox.Top := L.Top + L.Height + 6;
  ComboBox.Width := 188;
  ComboBox.Items.Text := CustomFields;
  
  CheckBox := TCheckBox.Create(F);
  CheckBox.Parent := F;
  CheckBox.Left := 6;
  CheckBox.Top := ComboBox.Top + ComboBox.Height + 6;
  CheckBox.Width := 188;
  CheckBox.Caption := 'This is a test';
  
  OKBtn := TButton.Create(F);
  OkBtn.Parent := F;
  OkBtn.Left := F.ClientWidth - OkBtn.Width - 6;
  OkBtn.Top := F.ClientHeight - OKBtn.Height - 6;
  OkBtn.Caption := '&OK';
  OkBtn.ModalResult := mrOK;
  OkBtn.Default := True;
  
  //Create or open an ini file 
  Ini := TIniFile.Create(GetAppPath + 'Scripts\testconf.ini');
  try
   //Load settings
   ComboBox.Text := Ini.ReadString('Section', 'Selected Custom Field', '');
   CheckBox.Checked := Ini.ReadBool('Section', 'CheckBox Value', False);
  
   //Show configuration window
   F.ShowModal;   
     
   //Save settings	 
   Ini.WriteString('Section', 'Selected Custom Field', ComboBox.Text);
   Ini.WriteBool('Section', 'CheckBox Value', CheckBox.Checked);
  finally
   Ini.Free; 
  end;
 finally
  F.Free; 
 end;

 Result := 1;
end;

function GetScriptVersion : String;
begin
 Result := SCRIPT_VERSION;
end; 
 
function GetScriptName : String;
begin
 Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
 Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
 Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
 Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
 Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
 Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
 Result := SEARCH_STR;
end;

function GetScriptType : Byte; 
begin
 Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte; 
begin
 Result := smSearch;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
 Result := prFinished;  
end;

begin 
end.