unit Picture2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, MPlayer, jpeg, TransparentPanel, Menus, StdCtrls,
  Buttons, Spin;

type
  TPic2 = class(TForm)
    Image1: TImage;
    left_sensor: TImage;
    TopSensor: TImage;
    CenterSensor: TImage;
    right_sensor: TImage;
    Inventar1: TMediaPlayer;
    bottom_sensor: TImage;
    Music1: TMediaPlayer;
    Video1: TMediaPlayer;
    InvBev: TBevel;
    InvPic: TImage;
    wallsensor: TImage;
    keypad1: TTransparentPanel;
    btn1: TImage;
    btn7: TImage;
    btn4: TImage;
    btn2: TImage;
    btn5: TImage;
    btn8: TImage;
    btn3: TImage;
    btn6: TImage;
    btn9: TImage;
    shelfsensor: TImage;
    vasesensor: TImage;
    wardrobesensor: TImage;
    wardrobe: TImage;
    booksensor: TImage;
    drawersensor1: TImage;
    tuisensor: TImage;
    spearsensor: TImage;
    coin_offering: TImage;
    delay_stat26: TTimer;
    inv_delay: TTimer;
    delay_tuidown: TTimer;
    voice1: TMediaPlayer;
    keypad2: TTransparentPanel;
    k2btn1: TImage;
    k2btn2: TImage;
    k2btn3: TImage;
    k2btn4: TImage;
    k2btn5: TImage;
    k2btn6: TImage;
    k2btn7: TImage;
    k2btn8: TImage;
    k2btn9: TImage;
    o_exitsensor: TImage;
    globesensor: TImage;
    book2sensor: TImage;
    telesensor: TImage;
    boardsensor: TImage;
    fixbooksensor: TImage;
    lenspocket: TImage;
    lenspocketclose: TImage;
    wheel_small: TImage;
    wheel_big: TImage;
    turn_delay: TTimer;
    tokensocket: TImage;
    laddersensor: TImage;
    blanketsensor: TImage;
    cheat4: TSpeedButton;
    picsensor: TImage;
    cheat3: TSpeedButton;
    pic2sensor: TImage;
    waysensor1: TImage;
    torchsensor: TImage;
    windowsensor: TImage;
    doorsensor: TImage;
    cheat1: TSpeedButton;
    cheat2: TSpeedButton;
    floorshelfsensor: TImage;
    booksensor1: TImage;
    booksensor2: TImage;
    booksensor3: TImage;
    mystsensor: TImage;
    lavasensor: TImage;
    SpinEdit1: TSpinEdit;
    statshow: TTimer;
    keysensor1: TImage;
    report: TButton;
    Memo1: TMemo;
    reporttimer: TTimer;
    wheelplayer: TMediaPlayer;
    cheat5: TSpeedButton;
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Video1Notify(Sender: TObject);
    procedure left_sensorDblClick(Sender: TObject);
    procedure right_sensorDblClick(Sender: TObject);
    procedure CenterSensorDblClick(Sender: TObject);
    procedure Music1Notify(Sender: TObject);
    procedure wallsensorDblClick(Sender: TObject);
    procedure bottom_sensorDblClick(Sender: TObject);
    procedure btn1Click(Sender: TObject);
    procedure btn4Click(Sender: TObject);
    procedure btn7Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
    procedure btn5Click(Sender: TObject);
    procedure btn8Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
    procedure btn6Click(Sender: TObject);
    procedure btn9Click(Sender: TObject);
    procedure shelfsensorDblClick(Sender: TObject);
    procedure vasesensorDblClick(Sender: TObject);
    procedure wardrobesensorDblClick(Sender: TObject);
    procedure wardrobeDblClick(Sender: TObject);
    procedure booksensorDblClick(Sender: TObject);
    procedure Inventar1Notify(Sender: TObject);
    procedure drawersensor1DblClick(Sender: TObject);
    procedure tuisensorDblClick(Sender: TObject);
    procedure spearsensorDblClick(Sender: TObject);
    procedure coin_offeringDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure coin_offeringDragDrop(Sender, Source: TObject; X,
      Y: Integer);
    procedure InvPicEndDrag(Sender, Target: TObject; X, Y: Integer);
    procedure InvPicMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure coin_offeringDblClick(Sender: TObject);
    procedure delay_stat26Timer(Sender: TObject);
    procedure inv_delayTimer(Sender: TObject);
    procedure InvPicDblClick(Sender: TObject);
    procedure delay_tuidownTimer(Sender: TObject);
    procedure voice1Notify(Sender: TObject);
    procedure InvPicClick(Sender: TObject);
    procedure k2btn1Click(Sender: TObject);
    procedure k2btn7Click(Sender: TObject);
    procedure k2btn2Click(Sender: TObject);
    procedure k2btn3Click(Sender: TObject);
    procedure k2btn4Click(Sender: TObject);
    procedure k2btn5Click(Sender: TObject);
    procedure k2btn6Click(Sender: TObject);
    procedure k2btn8Click(Sender: TObject);
    procedure k2btn9Click(Sender: TObject);
    procedure o_exitsensorDblClick(Sender: TObject);
    procedure Image1DblClick(Sender: TObject);
    procedure TopSensorDblClick(Sender: TObject);
    procedure globesensorDblClick(Sender: TObject);
    procedure book2sensorDblClick(Sender: TObject);
    procedure telesensorDblClick(Sender: TObject);
    procedure boardsensorDblClick(Sender: TObject);
    procedure fixbooksensorDblClick(Sender: TObject);
    procedure lenspocketDblClick(Sender: TObject);
    procedure lenspocketcloseDblClick(Sender: TObject);
    procedure telesensorDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure telesensorDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure wheel_smallClick(Sender: TObject);
    procedure turn_delayTimer(Sender: TObject);
    procedure wheel_smallDblClick(Sender: TObject);
    procedure wheel_bigDblClick(Sender: TObject);
    procedure tokensocketDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure tokensocketDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure laddersensorDblClick(Sender: TObject);
    procedure blanketsensorDblClick(Sender: TObject);
    procedure cheat4Click(Sender: TObject);
    procedure picsensorDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure picsensorDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure cheat3Click(Sender: TObject);
    procedure pic2sensorDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure pic2sensorDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure waysensor1DblClick(Sender: TObject);
    procedure torchsensorDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure torchsensorDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure windowsensorDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure cheat1Click(Sender: TObject);
    procedure doorsensorDblClick(Sender: TObject);
    procedure cheat2Click(Sender: TObject);
    procedure floorshelfsensorDblClick(Sender: TObject);
    procedure booksensor1DblClick(Sender: TObject);
    procedure booksensor2DblClick(Sender: TObject);
    procedure booksensor3DblClick(Sender: TObject);
    procedure mystsensorDblClick(Sender: TObject);
    procedure lavasensorDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure lavasensorDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure statshowTimer(Sender: TObject);
    procedure keysensor1DragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure keysensor1DragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure reportClick(Sender: TObject);
    procedure reporttimerTimer(Sender: TObject);
    procedure wheelplayerNotify(Sender: TObject);
    procedure windowsensorDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure cheat5Click(Sender: TObject);
    
  private
    { Private declarations }
    procedure Book_aClick(Sender: TObject);
    procedure fwpageClick(Sender: TObject);
    procedure bwpageClick(Sender: TObject);
    procedure fwpageDblClick(Sender: TObject);
    procedure Videoplay(videofile:string);
    procedure CVideoPlay(videofile:string;Left, Top, Width, Height:Integer);
    procedure Exittelescope;
    procedure Bookpagesensors;
    procedure BookClose;
    procedure BookDisplay(imagename:string);
    procedure PageCreate;
    procedure Bookplay(videofile:string);
    procedure PageSound;
    procedure ButtonSound(soundfile:string);
    procedure NoOffering;
    procedure Recycle(videofile:string);
  public
    finite, firstoffer, doorflag1, coinsout, entertui, tuiexit, spear, templeopen,
    firsttimeshirt ,firsttimetui ,firsttimespear, firsttimebook, firsttimespear2,
    shelfempty, book1open, book2open, drawerempty, tuiempty, wardrobeempty, spear3,
    voicefinished, o_exit, medallion, firsttimemedallion, globeempty, book,
    book2, firsttimebook2, chairempty, exittele, skipexit_l, skipexit_r, coins,
    token, lens, lensempty, lensinserted, tokeninserted, blanket, spear2,
    firsttimeblanket, exitswordchamber, blanketplaced, scroll, firsttimescroll,
    introflag01, startoffering, havetorch, firsttimetorch, offering, inventarclose,
    firsttimeflask1, flask1, firsttimekey1, key1, sword, emptyflask,
    templeexitnode, swordtaken, video2, haveblanket, medallionused:boolean;
    book_a:TImage;
    bwpage, fwpage:TImage;
    pages, invitem, coincount, cycles, starpos, throwcount, booktolava:Integer;
    displayeditem:String;
    { Public declarations }
  end;

var
  Pic2: TPic2;

var
 Status:Integer;
 Panel:TTransparentPanel;
 InvPanel:TTransparentPanel;
 wheelpanel:TTransparentPanel;
 exitnode:Integer;
 combination:String;

implementation

uses evo_menu, Picture1, Picture3, help_evo;

{$R *.dfm}

procedure TPic2.Videoplay(videofile:string);
begin
 Panel:=TTransparentPanel.Create(self);
 Panel.Parent := Self;
 Panel.Left := 72;
 Panel.Top := 40;
 Panel.Width:=640;
 Panel.Height:=480;
 video1.FileName:=videofile;
 video1.Open;
 video1.Display:=panel;
 video1.DisplayRect:=Panel.ClientRect;
 video1.play;
end;

procedure TPic2.CVideoPlay(videofile:string;Left, Top, Width, Height:Integer);
begin
 Panel:=TTransparentPanel.Create(self);
 Panel.Parent := Self;
 Panel.Left :=left;
 Panel.Top :=top;
 Panel.Width:=width;
 Panel.Height:=height;
 video1.FileName:=videofile;
 video1.Open;
 video1.Display:=panel;
 video1.DisplayRect:=Panel.ClientRect;
 video1.play;
end;

procedure TPic2.Exittelescope;
begin
 music1.Notify:=false;
 music1.Pause;
 music1.Notify:=true;
 image1.Picture.LoadFromFile('resources\img\black.jpeg');
 exittele:=true;
end;

Procedure TPic2.Bookpagesensors;
begin
 bwpage:=TImage.Create(self);
 bwpage.Parent := Self;
 bwpage.Left := 72;
 bwpage.Top := 40;
 bwpage.Width:=320;
 bwpage.Height:=420;
 bwpage.OnClick:=bwpageClick;

 fwpage:=TImage.Create(self);
 fwpage.Parent := Self;
 fwpage.Left :=392;
 fwpage.Top := 40;
 fwpage.Width:=320;
 fwpage.Height:=420;
 fwpage.OnClick:=fwpageClick;
 fwpage.OnDblClick:=fwpageDblClick;
end;

procedure TPic2.PageCreate;
begin
 bwpage:=TImage.Create(self);
 bwpage.Parent := Self;
 bwpage.Left := 72;
 bwpage.Top := 40;
 bwpage.Width:=320;
 bwpage.Height:=480;
 bwpage.OnClick:=bwpageClick;

 fwpage:=TImage.Create(self);
 fwpage.Parent := Self;
 fwpage.Left :=392;
 fwpage.Top := 40;
 fwpage.Width:=320;
 fwpage.Height:=480;
 fwpage.OnClick:=fwpageClick;
end;

procedure TPic2.BookClose;
begin
 image1.Picture.loadfromfile('resources\img\2_055.jpeg');
 status:=52;
 fwpage.free;
 bwpage.Free;
 pages:=1;
 invpic.visible:=true;
end;

procedure TPic2.PageSound;
begin
 inventar1.FileName:='resources\books\page.wav';
 inventar1.Open;
 inventar1.play;
 inventarclose:=true;
end;

procedure TPic2.ButtonSound(soundfile:string);
begin
 voice1.FileName:=soundfile;
 voice1.Open;
 voice1.play;
end;

procedure TPic2.NoOffering;
begin
 invpic.Visible:=false;
 music1.Notify:=false;
 music1.pause;
 Panel:=TTransparentPanel.Create(self);
 Panel.Parent := Self;
 Panel.Left := 72;
 Panel.Top := 40;
 Panel.Width:=640;
 Panel.Height:=480;
 voice1.FileName:='resources\audio\wwg.avi';
 voice1.Open;
 voice1.play;
end;

procedure TPic2.Recycle(videofile:string);
begin
 music1.Notify:=false;
 music1.pause;
 Panel:=TTransparentPanel.Create(self);
 Panel.Parent := Self;
 Panel.Left := 72;
 Panel.Top := 40;
 Panel.Width:=640;
 Panel.Height:=480;
 voice1.FileName:=videofile;
 voice1.Open;
 voice1.Display:=panel;
 voice1.DisplayRect:=Panel.ClientRect;
 voice1.play;
end;

procedure TPic2.Bookplay(videofile:string);
begin
 InvPanel:=TTransparentPanel.Create(self);
 InvPanel.Parent := Self;
 InvPanel.Left := 72;
 InvPanel.Top := 40;
 InvPanel.Width:=640;
 InvPanel.Height:=480;

 inventar1.FileName:=videofile;
 inventar1.Open;
 inventar1.Display:=invpanel;
 inventar1.DisplayRect:=invPanel.ClientRect;
 inventar1.play;
end;

procedure TPic2.BookDisplay(imagename:string);
begin
 Book_a:=TImage.Create(self);
 Book_a.Parent := Self;
 Book_a.Left := 72;
 Book_a.Top := 40;
 Book_a.Width:=640;
 Book_a.Height:=480;
 Book_a.OnClick:=Book_aClick;
 Book_a.Picture.loadfromfile(imagename);
end;

procedure TPic2.FormActivate(Sender: TObject);
begin
 Music1.FileName:='resources\music\b.avi';
 Music1.Open;
 Music1.play;
 Music1.notify:=true;
 Status:=0;
 exitnode:=0;
 videoplay('resources\anim\2_001.avi');
 invpic.Visible:=true;
 inv_delay.enabled:=true;
 keypad1.Visible:=false;
 keypad2.Visible:=false;
end;

procedure TPic2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 music1.notify:=false;
 music1.stop;
 evomenu.show;
end;

procedure TPic2.Video1Notify(Sender: TObject);
begin
with Sender as TMediaPlayer do
   begin
     case Mode of
       mpStopped:
        begin
         if status<>61 then panel.free;

         if status=0 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_001.jpeg');
           centersensor.visible:=true;
          end;
          
         if status=1 then image1.Picture.LoadFromFile('resources\img\2_002.jpeg');
         if status=2 then image1.Picture.LoadFromFile('resources\img\2_004.jpeg');
         if status=3 then image1.Picture.LoadFromFile('resources\img\2_003.jpeg');

         if (status=4) and (blanketplaced=false) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_005.jpeg');
           picsensor.Visible:=true;
          end
           else
          if (status=4) and (blanketplaced=true) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_051.jpeg');
           picsensor.Visible:=false;
           centersensor.Visible:=false;
           pic2sensor.visible:=true;
           waysensor1.visible:=true;
           if firsttimescroll=true then
            begin
             invitem:=10;
             scroll:=true;
             displayeditem:='scroll';
             invpic.Picture.loadfromfile('resources\inv\scroll.gif');
             firsttimescroll:=false;
            end;
            if firsttimespear2=true then
             begin
              invitem:=11;
              displayeditem:='spear2';
              invpic.Picture.loadfromfile('resources\inv\spear2.gif');
              spear2:=true;
              firsttimespear2:=false;
             end
          end;

         if (status=5) and (introflag01=false) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_006.jpeg');
           picsensor.Visible:=false;
           pic2sensor.Visible:=false;
           centersensor.Visible:=true;
           waysensor1.visible:=false;
          end
         else
          if (status=5) and (introflag01=true) then
           begin
           image1.Picture.loadfromfile('resources\img\black.jpeg');
           VideoPlay('resources\anim\2_133.avi');
           introflag01:=false;
          end;

         if status=6 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_007.jpeg');
           keypad2.Visible:=true;
          end;

         if (status=7) and (o_exit=true) then
          begin
            music1.FileName:='resources\music\b.avi';
            music1.Notify:=true;
            music1.Open;
            music1.Play;
            o_exit:=false;
          end;

         if status=7 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_008.jpeg');
           keypad2.Visible:=false;
           combination:='';
           centersensor.Visible:=true;
          end;

         if status=8 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_009.jpeg');
           keypad1.Visible:=false;
          end;

         if (status=9) and (tuiexit=false) then image1.Picture.LoadFromFile('resources\img\2_010.jpeg');

         if (status=9) and (tuiexit=true) then
          begin
            image1.Picture.LoadFromFile('resources\img\2_010.jpeg');
            music1.Notify:=false;
            music1.stop;
            music1.close;
            music1.FileName:='resources\music\b.avi';
            music1.Notify:=true;
            music1.Open;
            music1.Play;
           end;

         if status=10 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_011.jpeg');
           keypad1.Visible:=true;
          end;

         if status=11 then image1.Picture.LoadFromFile('resources\img\2_012.jpeg');

         if (status=12) and (entertui=false) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_013.jpeg');
           vasesensor.visible:=true;
           shelfsensor.Visible:=true;
           startoffering:=false;
          end;

         if (status=12) and (entertui=true) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_013.jpeg');

           music1.Notify:=false;
           music1.stop;
           music1.close;
           music1.FileName:='resources\music\c.avi';
           music1.Notify:=true;
           music1.Open;
           music1.Play;

           vasesensor.visible:=true;
           shelfsensor.Visible:=true;
           startoffering:=false;
          end;

         if status=13 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_014.jpeg');
           vasesensor.visible:=false;
          end;

         if status=14 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_016.jpeg');
           vasesensor.Visible:=false;
          end;

         if status=15 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_018.jpeg');
           vasesensor.visible:=false;
          end;

         if status=16 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_027.jpeg');
           vasesensor.visible:=false;
           if startoffering=true then
            begin
             coins:=true;
             invpic.Picture.loadfromfile('resources\inv\coins.gif');
             displayeditem:='coins';
             invitem:=3;
            end
          end;

         if status=17 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_015.jpeg');
           spearsensor.Visible:=false;
          end;
          
         if status=18 then image1.Picture.LoadFromFile('resources\img\2_022.jpeg');

         if status=19 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_023.jpeg');
           if firsttimespear=true then
            begin
             invpic.picture.loadfromfile('resources\inv\spear.gif');
             displayeditem:='spear';
             invitem:=4;
             firsttimespear:=false;
            end;
          end;

         if status=20 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_017.jpeg');
           if firsttimebook=true then
            begin
             invpic.picture.loadfromfile('resources\inv\book.gif');
             displayeditem:='book';
             invitem:=1;
             firsttimebook:=false;
            end;
          end;

         if status=21 then image1.Picture.LoadFromFile('resources\img\2_019.jpeg');
         if status=22 then image1.Picture.LoadFromFile('resources\img\2_020.jpeg');

         if status=23 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_021.jpeg');
           if firsttimeshirt=true then
            begin
             invpic.picture.loadfromfile('resources\inv\shirt.gif');
             displayeditem:='shirt';
             invitem:=2;
             firsttimeshirt:=false;
            end;
          end;

         if status=24 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_024.jpeg');
           if firsttimetui=true then
            begin
             invpic.picture.loadfromfile('resources\inv\coins.gif');
             displayeditem:='coins';
             invitem:=3;
             firsttimetui:=false;
            end;
          end;

         if status=25 then
          begin
           coin_offering.enabled:=true;
           image1.Picture.LoadFromFile('resources\img\2_025.jpeg');
           if coinsout=true then
            begin
             coins:=false;
             inv_delay.Enabled:=true;
            end;
           if (coincount=3) and (firstoffer=false) then
            begin
             invpic.Visible:=false;
             coin_offering.enabled:=false;
             offering:=true;
             music1.Notify:=false;
             music1.Pause;
             delay_stat26.Enabled:=true;
             CVideoPlay('resources\effects\tui_up.avi', 319,42,146,185);
             firstoffer:=true;
             status:=26;
            end;
            if voicefinished=true then invpic.Visible:=true;
          end;

         if status=26 then
          begin
           delay_tuidown.enabled:=true;
          end;

         if status=27 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_028.jpeg');
           centersensor.Visible:=false;
          end;

          if (status=28) and (combination='447') then
          begin
           music1.FileName:='resources\music\d.avi';
           music1.Notify:=true;
           music1.Open;
           music1.Play;
           image1.Picture.LoadFromFile('resources\img\2_029.jpeg');
           combination:='';
          end;
     
         if (status=28) and (tokeninserted=true) and (starpos<>10) then
          begin
           VideoPlay('resources\anim\2_101.avi');
           tokensocket.Visible:=false;
           wheel_small.visible:=true;
           telesensor.visible:=true;
           boardsensor.visible:=true;
           image1.Picture.LoadFromFile('resources\img\2_029.jpeg');
           tokeninserted:=false;
           status:=46;
          end

        else
        
         begin
         if (status=28) and (exittele=false) then
          begin
           invpic.Visible:=true;
           tokensocket.Visible:=false;
           wheel_small.visible:=true;
           telesensor.visible:=true;
           boardsensor.visible:=true;
           image1.Picture.LoadFromFile('resources\img\2_029.jpeg');
          end

        else
         if (status=45) then
           begin
            displayeditem:='token';
            token:=true;
            inv_delay.enabled:=true;
            status:=38;
           end
          else
           if (status=46) then
           begin
            displayeditem:='token';
            token:=true;
            inv_delay.enabled:=true;
            status:=28;
           end
         end;

         if (status=37) and (exittele=true) then
          begin
           VideoPlay('resources\anim\2_069.avi');
           music1.Play;
           exittele:=false;
           status:=28;
          end;

         if (status=29) and (chairempty=false) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_030.jpeg');
            if firsttimebook2=true then
             begin
              invpic.picture.loadfromfile('resources\inv\book2.gif');
              book2sensor.visible:=false;
              invitem:=6;
              displayeditem:='book2';
              book2:=true;
              chairempty:=true;
              firsttimebook2:=false;
             end
            else
            if firsttimemedallion=true then
             begin
              invpic.picture.loadfromfile('resources\inv\medallion.gif');
              invitem:=5;
              globeempty:=true;
              medallion:=true;
              firsttimemedallion:=false;
             end
           end;

         if (status=29) and (chairempty=true) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_033.jpeg');
            if firsttimebook2=true then
             begin
              invpic.picture.loadfromfile('resources\inv\book2.gif');
              book2sensor.visible:=false;
              invitem:=6;
              displayeditem:='book2';
              chairempty:=true;
              firsttimebook2:=false;
             end
            else
            if firsttimemedallion=true then
             begin
              invpic.picture.loadfromfile('resources\inv\medallion.gif');
              invitem:=5;
              globeempty:=true;
              medallion:=true;
              firsttimemedallion:=false;
             end
          end;

         if status=30 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_032.jpeg');
           o_exitsensor.Visible:=true;
           tokensocket.Visible:=false;
          end;

         if (status=31) and (tokeninserted=true) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_035.jpeg');
           tokensocket.Visible:=false;
           laddersensor.Visible:=true;
           keysensor1.visible:=false;

           if exitswordchamber=true then
            begin
             music1.Notify:=false;
             music1.stop;
             music1.close;
             music1.FileName:='resources\music\d.avi';
             music1.Notify:=true;
             music1.Open;
             music1.Play;

             exitswordchamber:=false;
            end;

          end
         else
         begin
         if status=31 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_031.jpeg');
           tokensocket.Visible:=true;
           keysensor1.Visible:=false;
          end
         end;

         if status=32 then image1.Picture.LoadFromFile('resources\img\2_036.jpeg');

         if (status=33) and (tokeninserted=true) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_034b.jpeg');
          end;

         if (status=33) and (tokeninserted=false) then
          begin
           image1.Picture.LoadFromFile('resources\img\2_034.jpeg');
          end;

         if (status=34) and (chairempty=false) and (medallionused=true) then
          begin
           VideoPlay('resources\anim\2_119.avi');
           status:=29;
          end
         else
          if (status=34) and (chairempty=true) and (medallionused=true) then
          begin
           VideoPlay('resources\anim\2_124.avi');
           status:=29;
          end
        else
         if (status=34) and (chairempty=false) and (medallion=false) then
          begin
           VideoPlay('resources\anim\2_118.avi');
           status:=29;
          end
         else
          if (status=34) and (chairempty=false) and (medallion=true) then
          begin
           VideoPlay('resources\anim\2_119.avi');
           status:=29;
          end
         else
          if (status=34) and (chairempty=true) and (medallion=false) then
          begin
           VideoPlay('resources\anim\2_123.avi');
           status:=29;
          end
         else
          if (status=34) and (chairempty=true) and (medallion=true) then
          begin
           VideoPlay('resources\anim\2_124.avi');
           status:=29;
          end;

         if exitnode=1 then
          begin
           music1.notify:=false;
           music1.stop;
           pic2.Hide;
           pic1.show;
           pic1.status:=1;
           pic1.Starused:=true;
          end;

         if (status=37) and (lensinserted=false) then
          begin
           VideoPlay('resources\anim\2_077.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=0) then
          begin
           VideoPlay('resources\anim\2_078.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=1) then
          begin
           VideoPlay('resources\anim\2_079.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=2) then
          begin
           VideoPlay('resources\anim\2_080.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=3) then
          begin
           VideoPlay('resources\anim\2_081.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=4) then
          begin
           VideoPlay('resources\anim\2_082.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=5) then
          begin
           VideoPlay('resources\anim\2_083.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=6) then
          begin
           VideoPlay('resources\anim\2_084.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=7) then
          begin
           VideoPlay('resources\anim\2_085.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=8) then
          begin
           VideoPlay('resources\anim\2_086.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=9) then
          begin
           VideoPlay('resources\anim\2_087.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=10) then
          begin
           VideoPlay('resources\anim\2_088.avi');
           Exittelescope;
          end
         else
          if (status=37) and (lensinserted=true) and (starpos=11) then
          begin
           VideoPlay('resources\anim\2_089.avi');
           Exittelescope;
          end;

         if (status=38) and (tokeninserted=true) and (starpos<>10) then
          begin
           VideoPlay('resources\anim\2_101.avi');
           image1.Picture.LoadFromFile('resources\img\2_039.jpeg');
           wheel_big.visible:=true;
           tokeninserted:=false;
           status:=45;
          end;

         if status=38 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_039.jpeg');
           wheel_big.visible:=true;
          end;

         if status=39 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_040.jpeg');
           fixbooksensor.Visible:=true;
            if lens=true then
              begin
               invpic.picture.loadfromfile('resources\inv\lens.gif');
               invitem:=8;
               displayeditem:='lens';
              end
            end;

         if status=40 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_042.jpeg');
           invpic.Visible:=false;
          end;

         if status=41 then
          begin
           image1.Picture.LoadFromFile('resources\books\2_043.jpeg');

           bwpage:=TImage.Create(self);
           bwpage.Parent := Self;
           bwpage.Left := 72;
           bwpage.Top := 40;
           bwpage.Width:=320;
           bwpage.Height:=420;
           bwpage.OnClick:=bwpageClick;

           fwpage:=TImage.Create(self);
           fwpage.Parent := Self;
           fwpage.Left :=392;
           fwpage.Top := 40;
           fwpage.Width:=320;
           fwpage.Height:=420;
           fwpage.OnClick:=fwpageClick;
           fwpage.OnDblClick:=fwpageDblClick;

           pages:=10;
          end;

          if status=42 then
           begin
            image1.Picture.LoadFromFile('resources\img\2_041.jpeg');
           end;

          if (status=44) and (blanket=false) then
           begin
            image1.Picture.LoadFromFile('resources\img\2_037.jpeg');
            blanketsensor.Visible:=true;

            music1.Notify:=false;
            music1.stop;
            music1.close;
            music1.FileName:='resources\music\b.avi';
            music1.Notify:=true;
            music1.Open;
            music1.Play;
           end;

          if (status=44) and (haveblanket=true) and (firsttimeblanket=false) then
           begin
            image1.Picture.LoadFromFile('resources\img\2_038.jpeg');
            keysensor1.Visible:=true;

            music1.Notify:=false;
            music1.stop;
            music1.close;
            music1.FileName:='resources\music\b.avi';
            music1.Notify:=true;
            music1.Open;
            music1.Play;
           end
          else
           begin
            if (status=44) and (haveblanket=true) and (firsttimeblanket=true) then
             begin
              image1.Picture.LoadFromFile('resources\img\2_038.jpeg');
              
              invpic.Picture.LoadFromFile('resources\inv\blanket.gif');
              invitem:=9;
              displayeditem:='blanket';
              firsttimeblanket:=false;
             end
           end;

          if status=48 then
           begin
            image1.Picture.LoadFromFile('resources\img\2_052.jpeg');
            waysensor1.visible:=false;
            centersensor.Visible:=false;

            windowsensor.Visible:=true;
            doorsensor.visible:=true;
            torchsensor.Visible:=true;

            if firsttimetorch=true then
             begin
              spear3:=true;
              displayeditem:='spear3';
              invpic.picture.loadfromfile('resources/inv/spear3.gif');
              firsttimetorch:=false;
             end;
           end;

          if (status=47) and (templeopen=false) then
           begin
            image1.Picture.LoadFromFile('resources\img\black.jpeg');
            VideoPlay('resources\anim\2_157.avi');
            pic2sensor.visible:=false;
            status:=48;
           end;

          if status=50 then
            begin
             image1.Picture.LoadFromFile('resources\img\2_053.jpeg');
             invpic.visible:=true;
             music1.Notify:=true;
             music1.play;
             doorsensor.Visible:=true;
             torchsensor.Visible:=true;
             windowsensor.Visible:=false;
             waysensor1.Visible:=false;

             if firsttimetorch=true then
             begin
              spear3:=true;
              displayeditem:='spear3';
              invpic.picture.loadfromfile('resources/inv/spear3.gif');
              firsttimetorch:=false;
             end;
            end;

          if (status=47) and (templeopen=true) then
           begin
            image1.Picture.LoadFromFile('resources\img\black.jpeg');
            VideoPlay('resources\anim\2_158.avi');
            pic2sensor.visible:=false;
            status:=50;
           end;

          if status=49 then
           begin
            image1.Picture.LoadFromFile('resources\img\2_057.jpeg');
            centersensor.Visible:=true;

            windowsensor.Visible:=false;
            doorsensor.visible:=false;
            torchsensor.Visible:=false;
           end;

          if status=54 then
           begin
            music1.notify:=true;
            music1.Play;
            VideoPlay('resources\anim\2_162.avi');
            status:=50;
           end;

          if (status=51) and (drawerempty=true) then
           begin
            image1.Picture.LoadFromFile('resources\img\2_054.jpeg');
            torchsensor.visible:=false;
            windowsensor.Visible:=false;
            doorsensor.Visible:=false;
            floorshelfsensor.Visible:=true;

            booksensor1.Visible:=false;
            booksensor2.Visible:=false;
            booksensor3.Visible:=false;
            mystsensor.visible:=false;
           end;

          if (status=51) and (drawerempty=false) then
           begin
            music1.Notify:=false;
            music1.Pause;
           
            image1.Picture.LoadFromFile('resources\img\2_054b.jpeg');

            Panel:=TTransparentPanel.Create(self);            // Blocking access
            Panel.Parent := Self;                             // via
            Panel.Left := 72;                                 // invisible
            Panel.Top := 40;                                  // Panel
            Panel.Width:=640;                                 // during
            Panel.Height:=480;                                // audio playing.

            video1.FileName:='resources\audio\tunika.avi';
            video1.Open;
            video1.play;

            status:=54;
           end;

          if status=53 then
           begin
            image1.Picture.LoadFromFile('resources\img\2_056.jpeg');
            doorsensor.Visible:=true;
            floorshelfsensor.Visible:=false;
            lavasensor.visible:=false;

            booksensor1.Visible:=false;
            booksensor2.Visible:=false;
            booksensor3.Visible:=false;
            mystsensor.visible:=false;
           end;

          if status=52 then
           begin
            image1.Picture.LoadFromFile('resources\img\2_055.jpeg');
            floorshelfsensor.Visible:=false;
            booksensor1.Visible:=true;
            booksensor2.Visible:=true;
            booksensor3.Visible:=true;
            mystsensor.visible:=true;
            invpic.visible:=true;
           end;

          if status=55 then
          begin
           image1.Picture.LoadFromFile('resources\books\2_060_a.jpeg');
           Bookpagesensors;
           pages:=16;
          end;

          if status=56 then
          begin
           image1.Picture.LoadFromFile('resources\books\2_061_a.jpeg');
           Bookpagesensors;
           pages:=18;
          end;

          if status=57 then
          begin
           image1.Picture.LoadFromFile('resources\books\2_062_a.jpeg');
           Bookpagesensors;
           pages:=20;
          end;

         if status=58 then
           begin
            image1.Picture.LoadFromFile('resources\img\2_058.jpeg');
            doorsensor.Visible:=false;
            floorshelfsensor.Visible:=true;
            torchsensor.Visible:=false;
            lavasensor.visible:=false;
            mystsensor.visible:=false;
            booksensor1.Visible:=false;
            booksensor2.Visible:=false;
            booksensor3.Visible:=false;
           end;

         if status=59 then
           begin
            image1.Picture.LoadFromFile('resources\img\2_059.jpeg');
            doorsensor.Visible:=false;
            floorshelfsensor.Visible:=false;
            lavasensor.visible:=true;
           end;
         
          if status=60 then
           begin
            image1.Picture.LoadFromFile('resources\img\2_060.jpeg');
            doorsensor.Visible:=false;
            floorshelfsensor.Visible:=false;
            lavasensor.Visible:=false;

            if firsttimeflask1=false then
             begin
              flask1:=true;
              displayeditem:='flask1';
              invpic.picture.loadfromfile('resources\inv\flask1.gif');

              firsttimeflask1:=true;
             end;

            if firsttimekey1=false then
             begin
              key1:=true;
              displayeditem:='key1';
              invpic.picture.loadfromfile('resources\inv\key1.gif');

              firsttimekey1:=true;
             end;
           end;

         if status=61 then panel.Free;

         if booktolava=2 then
          begin
           VideoPlay('resources\anim\2_146.avi');
           templeopen:=false;
           status:=60;
           booktolava:=0;
         end;

         if status=62 then
          begin
           flask1:=false;
           emptyflask:=true;
           invpic.picture.loadfromfile('resources\inv\flask_empty.gif');

           music1.Notify:=false;
           music1.stop;

           templeexitnode:=true;
           video2:=true;
           image1.Picture.LoadFromFile('resources\img\black.jpeg');
           spear3:=false;

           floorshelfsensor.Visible:=false;
           lavasensor.Visible:=false;
           doorsensor.visible:=false;
           status:=0;

           pic2.hide;
           pic1.Show;
          end;

         if status=63 then
          begin
           image1.Picture.LoadFromFile('resources\img\2_063.jpeg');
           sword:=true;
           invpic.picture.loadfromfile('resources\inv\sword.gif');

           voice1.FileName:='resources\audio\positiv_negativ.avi';
           voice1.Open;
           voice1.play;
          end;

         if status=64 then
          begin
           music1.notify:=true;
           music1.Play;
           invpic.Visible:=true;
           image1.Picture.LoadFromFile('resources\img\2_062.jpeg');
          end;
         end;

     end;
     Notify := True;
   end;
end;


procedure TPic2.left_sensorDblClick(Sender: TObject);
begin
 if status=0 then
  begin
   VideoPlay('resources\anim\2_002.avi');
   status:=1;
  end
else
 if status=3 then
  begin
   VideoPlay('resources\anim\2_012.avi');
   status:=0;
  end
else
 if status=2 then
  begin
   VideoPlay('resources\anim\2_011.avi');
   status:=3;
  end
else
 if status=1 then
  begin
   VideoPlay('resources\anim\2_007.avi');
   status:=2;
  end
else
 if (status=5) and (blanketplaced=false) then
  begin
   VideoPlay('resources\anim\2_029.avi');
   status:=4;
  end
else
 if (status=5) and (blanketplaced=true) then
  begin
   VideoPlay('resources\anim\2_138.avi');
   status:=4;
  end
else
 if (status=27) and (combination='447') then
  begin
   VideoPlay('resources\anim\2_142.avi');
   status:=7;
  end
else
 if status=6 then
  begin
   VideoPlay('resources\anim\2_030.avi');
   status:=7;
  end
else
 if status=8 then
  begin
   VideoPlay('resources\anim\2_020.avi');
   status:=9;
  end
else
 if status=11 then
  begin
   VideoPlay('resources\anim\2_017.avi');
   status:=9;
   doorflag1:=true;
  end
else
 if (status=12) and (tuiempty=true) then
  begin
   VideoPlay('resources\anim\2_038.avi');
   status:=24;
   entertui:=false;
   vasesensor.visible:=false;
   shelfsensor.Visible:=false;
   wardrobesensor.Visible:=true;
  end
else
 if status=12 then
  begin
   VideoPlay('resources\anim\2_037.avi');
   status:=13;
   entertui:=false;
   vasesensor.visible:=false;
   shelfsensor.Visible:=false;
   wardrobesensor.Visible:=true;
   tuisensor.Visible:=true;
  end
else
 if (status=28) and (chairempty=true) then
  begin
   VideoPlay('resources\anim\2_075.avi');
   status:=29;
   wheel_small.visible:=false;
   boardsensor.Visible:=false;
   telesensor.Visible:=false;
   book2sensor.Visible:=true;
   globesensor.Visible:=true;
  end
else
 if (status=28) and (chairempty=false) then
  begin
   VideoPlay('resources\anim\2_076.avi');
   status:=29;
   wheel_small.visible:=false;
   boardsensor.Visible:=false;
   telesensor.Visible:=false;
   book2sensor.Visible:=true;
   globesensor.Visible:=true;
  end
else
 if (status=29) and (chairempty=true) then
  begin
   VideoPlay('resources\anim\2_126.avi');
   status:=30;
   book2sensor.Visible:=false;
   globesensor.Visible:=false;
   o_exitsensor.Visible:=true;
  end
else
 if (status=29) and (chairempty=false) then
  begin
   VideoPlay('resources\anim\2_121.avi');
   status:=30;
   book2sensor.Visible:=false;
   globesensor.Visible:=false;
   o_exitsensor.Visible:=true;
  end
else
 if (status=30) and (tokeninserted=true) then
  begin
   VideoPlay('resources\anim\2_114.avi');
   status:=31;
   o_exitsensor.Visible:=false;
  end
else
 if status=30 then
  begin
   VideoPlay('resources\anim\2_113.avi');
   status:=31;
   o_exitsensor.Visible:=false;
  end
else
 if (status=31) and (tokeninserted=true) then
  begin
   VideoPlay('resources\anim\2_100.avi');
   status:=28;
   tokensocket.visible:=false;
   laddersensor.Visible:=false;
  end
else
 if status=31 then
  begin
   VideoPlay('resources\anim\2_107.avi');
   status:=28;
   wheel_small.Visible:=true;
  end
else
 if status=32 then
  begin
   VideoPlay('resources\anim\2_111.avi');
   status:=30;
  end
else
 if (status=49) and (templeopen=false) then
  begin
   VideoPlay('resources\anim\2_168.avi');
   status:=48;
  end
else
 if (status=49) and (templeopen=true) then
  begin
   VideoPlay('resources\anim\2_167.avi');
   status:=50;
  end
else
 if status=51 then
  begin
   VideoPlay('resources\anim\2_173.avi');
   status:=53;
  end
else
 if status=58 then
  begin
   VideoPlay('resources\anim\2_170.avi');
   status:=53;
  end
else
 if status=59 then
  begin
   VideoPlay('resources\anim\2_182.avi');
   status:=58;
  end
else
 if (status=53) and (spear3=true) then
  begin
   VideoPlay('resources\anim\2_178.avi');
   status:=59;
  end
else
 if status=60 then
  begin
   VideoPlay('resources\anim\2_147.avi');
  end
end;

procedure TPic2.right_sensorDblClick(Sender: TObject);
begin
 if status=1 then
  begin
   VideoPlay('resources\anim\2_006.avi');
   status:=0;
  end
else
 if status=0 then
  begin
   VideoPlay('resources\anim\2_003.avi');
   status:=3;
  end
else
 if status=3 then
  begin
   VideoPlay('resources\anim\2_013.avi');
   status:=2;
  end
else
 if status=2 then
  begin
   VideoPlay('resources\anim\2_010.avi');
   status:=1;
  end
else
 if (status=4) and (blanketplaced=false) then
  begin
   VideoPlay('resources\anim\2_027.avi');
   status:=5;
  end
else
 if (status=4) and (blanketplaced=true) then
  begin
   VideoPlay('resources\anim\2_134.avi');
   status:=5;
  end
else
 if status=7 then
  begin
   VideoPlay('resources\anim\2_032.avi');
   status:=6;
  end
else
 if (status=9) and (doorflag1=true) then
  begin
   VideoPlay('resources\anim\2_026.avi');
   status:=11;
  end
else
 if (status=9) and (doorflag1=false) then
  begin
   VideoPlay('resources\anim\2_025.avi');
   status:=8;
  end
else
 if status=13 then
  begin
   VideoPlay('resources\anim\2_054.avi');
   status:=12;
   wardrobesensor.Visible:=false;
   tuisensor.Visible:=false;
  end
else
 if (status=24) and (tuiempty=true) then
  begin
   VideoPlay('resources\anim\2_058.avi');
   status:=12;
   wardrobesensor.Visible:=false;
   tuisensor.Visible:=false;
  end
else
 if (status=28) and (tokeninserted=true) then
  begin
   VideoPlay('resources\anim\2_074.avi');
   status:=31;
   wheel_small.visible:=false;
   boardsensor.Visible:=false;
   telesensor.Visible:=false;
  end
else
 if status=28 then
  begin
   VideoPlay('resources\anim\2_073.avi');
   status:=31;
   wheel_small.visible:=false;
   boardsensor.Visible:=false;
   telesensor.Visible:=false;
  end
else
 if (status=29) and (chairempty=true) then
  begin
   VideoPlay('resources\anim\2_125.avi');
   status:=28;
   book2sensor.Visible:=false;
   globesensor.Visible:=false;
  end
else
 if (status=29) and (chairempty=false) then
  begin
   VideoPlay('resources\anim\2_120.avi');
   status:=28;
   book2sensor.Visible:=false;
   globesensor.Visible:=false;
  end
else
 if (status=31) and (tokeninserted=true) then
  begin
   VideoPlay('resources\anim\2_102.avi');
   status:=30;
   laddersensor.Visible:=false;
   o_exitsensor.Visible:=true;
  end
else
 if status=31 then
  begin
   VideoPlay('resources\anim\2_109.avi');
   status:=30;
   o_exitsensor.Visible:=true;
  end
else
 if (status=30) and (chairempty=true) then
  begin
   VideoPlay('resources\anim\2_116.avi');
   status:=29;
   book2sensor.Visible:=true;
   globesensor.Visible:=true;
   o_exitsensor.Visible:=false;
  end
else
 if (status=30) and (chairempty=false) then
  begin
   VideoPlay('resources\anim\2_117.avi');
   status:=29;
   book2sensor.Visible:=true;
   globesensor.Visible:=true;
   o_exitsensor.Visible:=false;
  end
else
 if status=32 then
  begin
   VideoPlay('resources\anim\2_111.avi');
   status:=30;
  end
else
 if status=48 then
  begin
   VideoPlay('resources\anim\2_166.avi');
   status:=49;
  end
else
 if status=50 then
  begin
   VideoPlay('resources\anim\2_163.avi');
   status:=49;
  end
else
 if (status=53) and (spear3=false) then
  begin
   VideoPlay('resources\anim\2_177.avi');
   status:=51;
  end
else
 if (status=53) and (spear3=true) then
  begin
   VideoPlay('resources\anim\2_176.avi');
   status:=58;
  end
else
 if status=58 then
  begin
   VideoPlay('resources\anim\2_172.avi');
   status:=59;
  end
else
 if status=59 then
  begin
   VideoPlay('resources\anim\2_183.avi');
   status:=53;
  end
end;

procedure TPic2.CenterSensorDblClick(Sender: TObject);
begin
if status=2 then
  begin
   VideoPlay('resources\anim\2_009.avi');
   status:=0;
   exitnode:=1;
  end
else
 if (status=0) and (blanketplaced=false) then
  begin
   VideoPlay('resources\anim\2_004.avi');
   status:=4;
  end
else
 if (status=0) and (blanketplaced=true) then
  begin
   VideoPlay('resources\anim\2_005.avi');
   status:=4;
  end
else
 if status=5 then
  begin
   VideoPlay('resources\anim\2_028.avi');
   status:=2;
  end
else
 if status=1 then
  begin
   VideoPlay('resources\anim\2_008.avi');
   status:=6;
  end
else
 if status=7 then
  begin
   VideoPlay('resources\anim\2_031.avi');
   status:=3;
  end
else
 if (status=3) and (doorflag1=true) then
  begin
   VideoPlay('resources\anim\2_015.avi');
   status:=11;
  end
else
 if status=3 then
  begin
   VideoPlay('resources\anim\2_014.avi');
   status:=8;
   wallsensor.Visible:=true;
  end
else
 if status=9 then
  begin
   VideoPlay('resources\anim\2_024.avi');
   status:=1;
  end
else
 if status=11 then
  begin
   VideoPlay('resources\anim\2_018.avi');
   status:=12;
   wallsensor.Visible:=false;
   entertui:=true;
  end
else
if (status=24) and (tuiempty=true) then
  begin
   VideoPlay('resources\anim\2_057.avi');
   status:=9;
   wardrobesensor.Visible:=false;
   tuisensor.Visible:=false;
   tuiexit:=true;
  end
else
if status=13 then
  begin
   VideoPlay('resources\anim\2_053.avi');
   status:=9;
   wardrobesensor.Visible:=false;
   tuisensor.Visible:=false;
   tuiexit:=true;
  end
else
 if status=12 then
  begin
   VideoPlay('resources\anim\2_035.avi');
   status:=16;
   coin_offering.Visible:=true;
   centersensor.Visible:=false;
   entertui:=false;
  end
else
 if status=49 then
  begin
   VideoPlay('resources\anim\2_186.avi');
   status:=5;
   introflag01:=true;
  end
end;

procedure TPic2.Music1Notify(Sender: TObject);
begin
if music1.NotifyValue=nvSuccessful then
  begin
    music1.Play;
    music1.Notify := True;
  end
end;

procedure TPic2.wallsensorDblClick(Sender: TObject);
begin
 if status=8 then
  begin
   VideoPlay('resources\anim\2_019.avi');
   status:=10;
  end
end;

procedure TPic2.bottom_sensorDblClick(Sender: TObject);
begin
 if status=10 then
  begin
   VideoPlay('resources\anim\2_022.avi');
   status:=8;
  end
else
 if status=14 then
  begin
   VideoPlay('resources\anim\2_039.avi');
   status:=12;
   centersensor.Visible:=true;
   booksensor.visible:=false;
  end
else
 if status=15 then
  begin
   VideoPlay('resources\anim\2_051.avi');
   status:=12;
   drawersensor1.visible:=false;
   centersensor.Visible:=true;
  end
else
 if status=16 then
  begin
   VideoPlay('resources\anim\2_043.avi');
   status:=12;
   coin_offering.Visible:=false;
   centersensor.Visible:=true;
  end
else
 if (status=17) and (tuiempty=true) then
  begin
   VideoPlay('resources\anim\2_063.avi');
   status:=24;
   wardrobe.visible:=false;
   centersensor.visible:=true;
   wardrobesensor.visible:=true;
  end
else
 if status=17 then
  begin
   VideoPlay('resources\anim\2_064.avi');
   status:=13;
   tuisensor.Visible:=true;
   wardrobe.visible:=false;
   centersensor.visible:=true;
   wardrobesensor.visible:=true;
  end
else
 if status=18 then
  begin
   VideoPlay('resources\anim\2_060.avi');
   status:=17;
  end
else
 if status=21 then
  begin
   VideoPlay('resources\anim\2_045.avi');
   status:=15;
  end
else
 if status=20 then
  begin
   VideoPlay('resources\anim\2_041.avi');
   status:=12;
  end
else
 if status=22 then
  begin
   VideoPlay('resources\anim\2_049.avi');
   status:=15;
  end
else
 if status=23 then
  begin
   VideoPlay('resources\anim\2_048.avi');
   status:=15;
  end
else
 if status=19 then
  begin
   VideoPlay('resources\anim\2_062.avi');
   status:=17;
  end
else
 if (status=25) and (coinsout=true) then
  begin
   VideoPlay('resources\anim\2_042.avi');
   status:=16;
   coinsout:=false;
  end
else
 if (status=33) and (tokeninserted=false) then
  begin
   VideoPlay('resources\anim\2_099.avi');
   status:=28;
  end
else
 if (status=33) and (tokeninserted=true) then
  begin
   VideoPlay('resources\anim\2_098.avi');
   status:=28;
  end
else
 if status=38  then
  begin
   VideoPlay('resources\anim\2_096.avi');
   status:=28;
   wheel_big.visible:=false;
   wheel_small.visible:=true;
   boardsensor.Visible:=true;
   telesensor.Visible:=true;
  end
else
 if status=39 then
  begin
   VideoPlay('resources\anim\2_091.avi');
   status:=38;
   wheel_big.visible:=true;
   lenspocket.visible:=false;
   fixbooksensor.visible:=false;
  end
else
 if status=40 then
  begin
   image1.Picture.loadfromfile('resources\img\2_040.jpeg');
   status:=39;
   fixbooksensor.visible:=true;
   lenspocket.Visible:=true;
   invpic.Visible:=true;
  end
else
 if status=41 then
  begin
   image1.Picture.loadfromfile('resources\img\2_040.jpeg');
   status:=39;
   fixbooksensor.visible:=true;
   lenspocket.Visible:=true;
   fwpage.free;
   bwpage.Free;
   pages:=1;
   invpic.visible:=true;
  end
else
 if (status=44) and (blanket=false) then
  begin
   VideoPlay('resources\anim\2_130.avi');
   status:=31;
   blanketsensor.Visible:=false;
  end
else
 if (status=44) and (blanket=true) then
  begin
   VideoPlay('resources\anim\2_128.avi');
   status:=31;
   blanketsensor.Visible:=false;
  end
else
 if (status=52) and (spear3=false) then
  begin
   VideoPlay('resources\anim\2_180.avi');
   status:=51;
   floorshelfsensor.Visible:=true;
  end
else
 if (status=52) and (spear3=true) then
  begin
   VideoPlay('resources\anim\2_179.avi');
   status:=58;
   floorshelfsensor.Visible:=true;
  end
else
 if (status=64) and (swordtaken=true) then
  begin
   VideoPlay('resources\anim\2_132.avi');
   status:=31;
   blanketsensor.Visible:=false;
  end
else
 if status=55 then
  begin
   BookClose;
  end
else
 if status=56 then
  begin
   BookClose;
  end
else
 if status=57 then
  begin
   BookClose;
  end
end;

procedure TPic2.btn1Click(Sender: TObject);
begin
 keypad1.Visible:=false;
 CVideoPlay('resources\effects\button.avi',344,314,30,16);
end;

procedure TPic2.btn4Click(Sender: TObject);
begin
 keypad1.Visible:=false;
 CVideoPlay('resources\effects\button.avi',344,340,30,16);
end;

procedure TPic2.btn7Click(Sender: TObject);
begin
 keypad1.Visible:=false;
 CVideoPlay('resources\effects\button.avi',344,364,30,16);
end;

procedure TPic2.btn2Click(Sender: TObject);
begin
 keypad1.Visible:=false;
 VideoPlay('resources\anim\2_023.avi');
 doorflag1:=true;
 status:=11;
end;

procedure TPic2.btn5Click(Sender: TObject);
begin
 keypad1.Visible:=false;
 CVideoPlay('resources\effects\button.avi',378,340,30,16);
end;

procedure TPic2.btn8Click(Sender: TObject);
begin
 keypad1.Visible:=false;
 CVideoPlay('resources\effects\button.avi',378,364,30,16);
end;

procedure TPic2.btn3Click(Sender: TObject);
begin
 keypad1.Visible:=false;
 CVideoPlay('resources\effects\button.avi',412,314,30,16);
end;

procedure TPic2.btn6Click(Sender: TObject);
begin
 keypad1.Visible:=false;
 CVideoPlay('resources\effects\button.avi',412,340,30,16);
end;

procedure TPic2.btn9Click(Sender: TObject);
begin
 keypad1.Visible:=false;
 CVideoPlay('resources\effects\button.avi',412,364,30,16);
end;

procedure TPic2.shelfsensorDblClick(Sender: TObject);
begin
if (status=12) and (shelfempty=false) then
  begin
   VideoPlay('resources\anim\2_034.avi');
   status:=14;
   booksensor.Visible:=true;
   entertui:=false;
  end
else
 if (status=12) and (shelfempty=true) then
  begin
   VideoPlay('resources\anim\2_033.avi');
   status:=20;
   entertui:=false;   
  end
end;

procedure TPic2.vasesensorDblClick(Sender: TObject);
begin
if status=12 then
  begin
   VideoPlay('resources\anim\2_036.avi');
   status:=15;
   drawersensor1.visible:=true;
   entertui:=false;
  end
end;

procedure TPic2.wardrobesensorDblClick(Sender: TObject);
begin
 if (status=24) and (tuiempty=true) then
  begin
   VideoPlay('resources\anim\2_059.avi');
   status:=17;
   wardrobe.Visible:=true;
   centersensor.Visible:=false;
   wardrobesensor.visible:=false;
   tuisensor.Visible:=false;
  end
else
 if status=13 then
  begin
   VideoPlay('resources\anim\2_056.avi');
   status:=17;
   wardrobe.Visible:=true;
   centersensor.Visible:=false;
   wardrobesensor.visible:=false;
   tuisensor.Visible:=false;
  end
end;

procedure TPic2.wardrobeDblClick(Sender: TObject);
begin
if (status=17) and (wardrobeempty=true) then
  begin
   VideoPlay('resources\anim\2_066.avi');
   status:=19;
  end
else
 if status=19 then
  begin
   VideoPlay('resources\anim\2_062.avi');
   status:=17;
   spearsensor.visible:=false;
  end
else
 if status=17 then
  begin
   VideoPlay('resources\anim\2_065.avi');
   status:=18;
   spearsensor.visible:=true;
  end
else
 if status=18 then
  begin
   VideoPlay('resources\anim\2_060.avi');
   status:=17;
   spearsensor.visible:=false;
  end
end;

procedure TPic2.booksensorDblClick(Sender: TObject);
begin
 if status=14 then
  begin
   VideoPlay('resources\anim\2_040.avi');
   status:=20;
   booksensor.visible:=false;
   invitem:=1;
   displayeditem:='book';
   book:=true;
   shelfempty:=true;
   firsttimebook:=true;
  end
end;

procedure TPic2.Inventar1Notify(Sender: TObject);
begin
 with Sender as TMediaPlayer do
   begin
     case Mode of
      mpStopped:
        begin
         if pic3.book3open=true then
          begin
           invpanel.free;
           book_a.Picture.LoadFromFile('resources\books\2_063_b.jpeg');
           invpic.Enabled:=true;
           inventar1.Close;
          end
        else
         if pages=0 then
          begin
           Invpanel.free;
           pages:=1;
           book_a.Picture.LoadFromFile('resources\books\2_029.jpeg');
           invpic.enabled:=true;
           pagecreate;
           inventar1.Close;
          end
        else
         if pages=6 then
          begin
           Invpanel.free;
           pages:=7;
           book_a.Picture.LoadFromFile('resources\books\2_052.jpeg');
           invpic.enabled:=true;
           pagecreate;
           inventar1.Close;
          end
        else
         if inventarclose=true then
          begin
           inventar1.Close;
           inventarclose:=false;
          end;
        end;
      end;
   end;
end;

procedure TPic2.fwpageDblClick(Sender: TObject);
begin
 if (pages=15) and (token=false) then
   begin
    Panel:=TTransparentPanel.Create(self);
    Panel.Parent := Self;
    Panel.Left := 72;
    Panel.Top := 40;
    Panel.Width:=640;
    Panel.Height:=480;

    voice1.FileName:='resources\anim\2_140.avi';
    voice1.Open;
    voice1.Display:=panel;
    voice1.DisplayRect:=Panel.ClientRect;
    voice1.play;

    displayeditem:='token';
    token:=true;
   end
end;

procedure TPic2.fwpageClick(Sender: TObject);
begin
 if pages=1 then
  begin
   PageSound;
   pages:=2;
   book_a.Picture.LoadFromFile('resources\books\2_030.jpeg');
  end
else
  if pages=2 then
   begin
    PageSound;
    pages:=3;
    book_a.Picture.LoadFromFile('resources\books\2_031.jpeg');
   end
else
  if pages=3 then
   begin
    PageSound;
    pages:=4;
    book_a.Picture.LoadFromFile('resources\books\2_032.jpeg');
   end
else
 if pages=4 then
   begin
    PageSound;
    pages:=5;
    book_a.Picture.LoadFromFile('resources\books\2_033.jpeg');
   end
else
 if pages=7 then
   begin
    PageSound;
    pages:=8;
    book_a.Picture.LoadFromFile('resources\books\2_053.jpeg');
   end
else
 if pages=8 then
   begin
    PageSound;
    pages:=9;
    book_a.Picture.LoadFromFile('resources\books\2_054.jpeg');
   end
else
 if pages=10 then
   begin
    PageSound;
    pages:=11;
    image1.Picture.LoadFromFile('resources\books\2_044.jpeg');
   end
else
 if pages=11 then
   begin
    PageSound;
    pages:=12;
    image1.Picture.LoadFromFile('resources\books\2_045.jpeg');
   end
else
 if pages=12 then
   begin
    PageSound;
    pages:=13;
    image1.Picture.LoadFromFile('resources\books\2_046.jpeg');
   end
else
 if pages=13 then
   begin
    PageSound;
    pages:=14;
    image1.Picture.LoadFromFile('resources\books\2_047.jpeg');
   end
else
 if (pages=14) and (token=false) then
   begin
    PageSound;
    pages:=15;
    image1.Picture.LoadFromFile('resources\books\2_048.jpeg');
   end
else
 if (pages=14) and (token=true) then
   begin
    PageSound;
    pages:=15;
    image1.Picture.LoadFromFile('resources\books\2_049.jpeg');
   end
else
 if pages=16 then
   begin
    PageSound;
    pages:=17;
    image1.Picture.LoadFromFile('resources\books\2_060_b.jpeg');
   end
else
 if pages=18 then
   begin
    PageSound;
    pages:=19;
    image1.Picture.LoadFromFile('resources\books\2_061_b.jpeg');
   end
else
 if pages=20 then
   begin
    PageSound;
    pages:=21;
    image1.Picture.LoadFromFile('resources\books\2_062_b.jpeg');
   end
else
 if pages=21 then
   begin
    PageSound;
    pages:=22;
    image1.Picture.LoadFromFile('resources\books\2_062_c.jpeg');
   end
end;

procedure TPic2.bwpageClick(Sender: TObject);
begin
  if pages=2 then
   begin
    PageSound;
    pages:=1;
    book_a.Picture.LoadFromFile('resources\books\2_029.jpeg');
   end
else
  if pages=3 then
   begin
    PageSound;
    pages:=2;
    book_a.Picture.LoadFromFile('resources\books\2_030.jpeg');
   end
else
 if pages=4 then
   begin
    PageSound;
    pages:=3;
    book_a.Picture.LoadFromFile('resources\books\2_031.jpeg');
   end
else
 if pages=5 then
   begin
    PageSound;
    pages:=4;
    book_a.Picture.LoadFromFile('resources\books\2_032.jpeg');
   end
else
 if pages=9 then
   begin
    PageSound;
    pages:=8;
    book_a.Picture.LoadFromFile('resources\books\2_053.jpeg');
   end
else
 if pages=8 then
   begin
    PageSound;
    pages:=7;
    book_a.Picture.LoadFromFile('resources\books\2_052.jpeg');
   end
else
 if pages=15 then
   begin
    PageSound;
    pages:=14;
    image1.Picture.LoadFromFile('resources\books\2_047.jpeg');
   end
else
 if pages=14 then
   begin
    PageSound;
    pages:=13;
    image1.Picture.LoadFromFile('resources\books\2_046.jpeg');
   end
else
 if pages=13 then
   begin
    PageSound;
    pages:=12;
    image1.Picture.LoadFromFile('resources\books\2_045.jpeg');
   end
else
 if pages=12 then
   begin
    PageSound;
    pages:=11;
    image1.Picture.LoadFromFile('resources\books\2_044.jpeg');
   end
else
 if pages=11 then
   begin
    PageSound;
    pages:=10;
    image1.Picture.LoadFromFile('resources\books\2_043.jpeg');
   end
else
 if pages=17 then
   begin
    PageSound;
    pages:=16;
    image1.Picture.LoadFromFile('resources\books\2_060_a.jpeg');
   end
else
 if pages=19 then
   begin
    PageSound;
    pages:=18;
    image1.Picture.LoadFromFile('resources\books\2_061_a.jpeg');
   end
else
 if pages=21 then
   begin
    PageSound;
    pages:=20;
    image1.Picture.LoadFromFile('resources\books\2_062_a.jpeg');
   end
else
 if pages=22 then
   begin
    PageSound;
    pages:=21;
    image1.Picture.LoadFromFile('resources\books\2_062_b.jpeg');
   end
end;

procedure TPic2.drawersensor1DblClick(Sender: TObject);
begin
if status=15 then
  begin
   VideoPlay('resources\anim\2_052.avi');
   status:=21;
  end
else
 if (status=21) and (drawerempty=false) then
  begin
   VideoPlay('resources\anim\2_047.avi');
   status:=22;
  end
else
 if (status=21) and (drawerempty=true) then
  begin
   VideoPlay('resources\anim\2_046.avi');
   status:=23;
  end
else
 if status=22 then
  begin
   VideoPlay('resources\anim\2_050.avi');
   status:=23;
   invitem:=2;
   displayeditem:='shirt';
   drawerempty:=true;
   firsttimeshirt:=true;   
  end
end;

procedure TPic2.tuisensorDblClick(Sender: TObject);
begin
 if status=13 then
  begin
   VideoPlay('resources\anim\2_055.avi');
   status:=24;
   tuisensor.visible:=false;
   tuiempty:=true;
   invitem:=3;
   coins:=true;
   displayeditem:='coins';
   firsttimetui:=true;   
  end
end;

procedure TPic2.spearsensorDblClick(Sender: TObject);
begin
 if status=18 then
  begin
   VideoPlay('resources\anim\2_061.avi');
   status:=19;
   wardrobesensor.visible:=false;
   wardrobeempty:=true;
   invitem:=4;
   spear:=true;
   displayeditem:='spear';
   firsttimespear:=true;   
  end
end;

procedure TPic2.coin_offeringDragOver(Sender, Source: TObject; X,
  Y: Integer; State: TDragState; var Accept: Boolean);
begin
if Status=16 then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic2.coin_offeringDragDrop(Sender, Source: TObject; X,
  Y: Integer);
begin
if (source = InvPic) and (displayeditem='coins') and (firstoffer=false) then
  begin
   VideoPlay('resources\anim\2_044.avi');
   status:=25;
   invpic.picture.loadfromfile('resources/img/black.jpeg');
   startoffering:=true;
   coincount:=coincount+1;
   coinsout:=true;   
  end
end;

procedure TPic2.InvPicEndDrag(Sender, Target: TObject; X, Y: Integer);
begin
if (Target = telesensor) then
  begin
   if displayeditem='lens' then
    begin
     lens:=false;
     invpic.picture.loadfromfile('resources/img/black.jpeg');
     inv_delay.Enabled:=true;
    end
   end
else
if (Target = tokensocket) then
 begin
    if (displayeditem='token') and (starpos=10) then
     begin
      token:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
     end
  end
else
if (Target = lavasensor) then
 begin
    if displayeditem='book' then
     begin
      book:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
     end
    else
     if displayeditem='book2' then
     begin
      book2:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
     end
  end
else
if (Target = picsensor) then
 begin
    if displayeditem='blanket' then
     begin
      blanket:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
      firsttimescroll:=true;
     end
  end
else
if (Target = pic2sensor) then
 begin
    if displayeditem='spear' then
     begin
      spear:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
     end
  end
else
if (Target = torchsensor) then
 begin
    if displayeditem='spear2' then
     begin
      spear2:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
      firsttimetorch:=true;
     end
  end
else
if (Target = keysensor1) then
 begin
    if displayeditem='key1' then
     begin
      key1:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
     end
  end
else
if (Target = windowsensor) then
 begin
    if (displayeditem='coins') and (offering=true) then
     begin
      coins:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
      throwcount:=throwcount+1;
     end
    else
    if (displayeditem='medallion') and (offering=true) then
     begin
      medallionused:=true;
      medallion:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
      throwcount:=throwcount+1;
     end
    else
    if (displayeditem='scroll') and (offering=true) then
     begin
      scroll:=false;
      invpic.picture.loadfromfile('resources/img/black.jpeg');
      inv_delay.Enabled:=true;
      throwcount:=throwcount+1;
     end
  end
end;

procedure TPic2.InvPicMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 if (Button = mbRight) and (displayeditem='coins') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='lens') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='token') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='blanket') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='spear') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='spear2') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='scroll') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='medallion') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='book') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='book2') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='sword') then InvPic.BeginDrag(False);
 if (Button = mbRight) and (displayeditem='key1') then InvPic.BeginDrag(False);
end;

procedure TPic2.coin_offeringDblClick(Sender: TObject);
begin
if coinsout=true then
  begin
   VideoPlay('resources\anim\2_042.avi');
   status:=16;
   coinsout:=false;   
  end;
end;

procedure TPic2.delay_stat26Timer(Sender: TObject);
begin
 image1.Picture.LoadFromFile('resources\img\2_026.jpeg');
 delay_stat26.enabled:=false;
end;

procedure TPic2.inv_delayTimer(Sender: TObject);
begin
 finite:=false;

 cycles:=0;

 repeat
 if invitem<31 then invitem:=invitem+1 else
  begin
   invitem:=1;
   cycles:=1;
  end;

 if (invitem=1) and (book=false) then invitem:=invitem+1;
 if (invitem=1) and (book=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\book.gif');
   displayeditem:='book';
   finite:=true;
  end;

 if (invitem=2) and (drawerempty=false) then invitem:=invitem+1;
 if (invitem=2) and (drawerempty=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\shirt.gif');
   displayeditem:='shirt';
   finite:=true;
  end;

 if (invitem=3) and (coins=false) then invitem:=invitem+1;
 if (invitem=3) and (coins=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\coins.gif');
   displayeditem:='coins';
   finite:=true;
  end;

 if (invitem=4) and (spear=false) then invitem:=invitem+1;
 if (invitem=4) and (spear=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\spear.gif');
   displayeditem:='spear';
   finite:=true;
  end;

 if (invitem=5) and (medallion=false) then invitem:=invitem+1;
 if (invitem=5) and (medallion=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\medallion.gif');
   displayeditem:='medallion';
   finite:=true;
  end;

 if (invitem=6) and (book2=false) then invitem:=invitem+1;
 if (invitem=6) and (book2=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\book2.gif');
   displayeditem:='book2';
   finite:=true;
  end;

 if (invitem=7) and (token=false) then invitem:=invitem+1;
 if (invitem=7) and (token=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\token.gif');
   displayeditem:='token';
   finite:=true;
  end;

 if (invitem=8) and (lens=false) then invitem:=invitem+1;
 if (invitem=8) and (lens=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\lens.gif');
   displayeditem:='lens';
   finite:=true;
  end;

 if (invitem=9) and (blanket=false) then invitem:=invitem+1;
 if (invitem=9) and (blanket=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\blanket.gif');
   displayeditem:='blanket';
   finite:=true;
  end;

 if (invitem=10) and (scroll=false) then invitem:=invitem+1;
 if (invitem=10) and (scroll=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\scroll.gif');
   displayeditem:='scroll';
   finite:=true;
  end;

 if (invitem=11) and (spear2=false) then invitem:=invitem+1;
 if (invitem=11) and (spear2=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\spear2.gif');
   displayeditem:='spear2';
   finite:=true;
  end;

 if (invitem=12) and (spear3=false) then invitem:=invitem+1;
 if (invitem=12) and (spear3=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\spear3.gif');
   displayeditem:='spear3';
   finite:=true;
  end;

 if (invitem=13) and (flask1=false) then invitem:=invitem+1;
 if (invitem=13) and (flask1=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\flask1.gif');
   displayeditem:='flask1';
   finite:=true;
  end;

 if (invitem=14) and (key1=false) then invitem:=invitem+1;
 if (invitem=14) and (key1=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\key1.gif');
   displayeditem:='key1';
   finite:=true;
  end;

 if (invitem=15) and (emptyflask=false) then invitem:=invitem+1;
 if (invitem=15) and (emptyflask=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\flask_empty.gif');
   displayeditem:='emptyflask';
   finite:=true;
  end;

 if (invitem=16) and (sword=false) then invitem:=invitem+1;
 if (invitem=16) and (sword=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\sword.gif');
   displayeditem:='sword';
   finite:=true;
  end;

 if (pic2.invitem=17) and (pic3.crowbar=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=17) and (pic3.crowbar=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\crowbar.gif');
   pic2.displayeditem:='crowbar';
   pic2.finite:=true;
  end;

 if (pic2.invitem=18) and (pic3.dust=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=18) and (pic3.dust=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\dust.gif');
   pic2.displayeditem:='dust';
   pic2.finite:=true;
  end;

 if (pic2.invitem=19) and (pic3.card=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=19) and (pic3.card=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\card.gif');
   pic2.displayeditem:='card';
   pic2.finite:=true;
  end;

 if (pic2.invitem=20) and (pic3.stone=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=20) and (pic3.stone=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\stone.gif');
   pic2.displayeditem:='stone';
   pic2.finite:=true;
  end;

 if (pic2.invitem=21) and (pic3.mirror=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=21) and (pic3.mirror=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\mirror.gif');
   pic2.displayeditem:='mirror';
   pic2.finite:=true;
  end;

 if (pic2.invitem=22) and (pic3.shieldbook=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=22) and (pic3.shieldbook=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\shieldbook.gif');
   pic2.displayeditem:='shieldbook';
   pic2.finite:=true;
  end;

 if (pic2.invitem=23) and (pic3.cloak=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=23) and (pic3.cloak=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\cloak.gif');
   pic2.displayeditem:='cloak';
   pic2.finite:=true;
  end;

 if (pic2.invitem=24) and (pic3.powder=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=24) and (pic3.powder=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\powder.gif');
   pic2.displayeditem:='powder';
   pic2.finite:=true;
  end;

 if (pic2.invitem=25) and (pic3.yellowflask=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=25) and (pic3.yellowflask=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\flask_yellow.gif');
   pic2.displayeditem:='yellowflask';
   pic2.finite:=true;
  end;

 if (pic2.invitem=26) and (pic3.paper=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=26) and (pic3.paper=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\paper.gif');
   pic2.displayeditem:='paper';
   pic2.finite:=true;
  end;

 if (pic2.invitem=27) and (pic3.waterflask=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=27) and (pic3.waterflask=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\flask2.gif');
   pic2.displayeditem:='waterflask';
   pic2.finite:=true;
  end;

 if (pic2.invitem=28) and (pic3.glass1=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=28) and (pic3.glass1=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\glass1.gif');
   pic2.displayeditem:='glass1';
   pic2.finite:=true;
  end;

 if (pic2.invitem=29) and (pic3.glass2=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=29) and (pic3.glass2=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\glass2.gif');
   pic2.displayeditem:='glass2';
   pic2.finite:=true;
  end;

 if (pic2.invitem=30) and (pic3.glass3=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=30) and (pic3.glass3=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\glass3.gif');
   pic2.displayeditem:='glass3';
   pic2.finite:=true;
  end;

 if (pic2.invitem=31) and (pic3.shieldbook2=false) then pic2.invitem:=pic2.invitem+1;
 if (pic2.invitem=31) and (pic3.shieldbook2=true) then
  begin
   invpic.Picture.loadfromfile('resources\inv\shieldbook2.gif');
   pic2.displayeditem:='shieldbook2';
   pic2.finite:=true;
  end;

until (cycles=1) or (finite=true);

inv_delay.enabled:=false;

end;

procedure TPic2.Book_aClick(Sender: TObject);
begin
 if (pic3.book3opened=false) and (pic2.book2open=false) and (pic2.book1open=false) then
  begin
   invPanel:=TTransparentPanel.Create(self);
   invPanel.Parent := Self;
   invPanel.Left := 72;
   invPanel.Top := 40;
   invPanel.Width:=640;
   invPanel.Height:=480;

   inventar1.FileName:='resources\books\book_d.avi';
   inventar1.Open;
   inventar1.Display:=invpanel;
   inventar1.DisplayRect:=invPanel.ClientRect;
   inventar1.play;

   pic3.book3opened:=true;
 end
else
if (pages=0) and (pic3.book3opened=false) then
 begin
  invpic.Enabled:=false;
  Bookplay('resources\books\book_a.avi');
 end
else
if pages=6 then
 begin
  invpic.Enabled:=false;
  Bookplay('resources\books\book_b.avi');
 end
end;

procedure TPic2.InvPicDblClick(Sender: TObject);
begin
 inv_delay.enabled:=false;
 if (book1open=false) and (book2open=false) and (displayeditem='book') then
  begin
   Bookdisplay('resources\books\2_028.jpeg');
   pages:=0;
   book1open:=true;
  end
else
  if (book1open=true) and (displayeditem='book') then
   begin
    if pages>=1 then fwpage.Free;
    if pages>=1 then bwpage.Free;
    book_a.free;
    book1open:=false;
   end
else
 if (book2open=false) and (book1open=false) and (displayeditem='book2') then
  begin
   Bookdisplay('resources\books\2_051.jpeg');
   pages:=6;
   book2open:=true;
  end
else
  if (book2open=true) and (displayeditem='book2') then
   begin
    if pages>=7 then fwpage.Free;
    if pages>=7 then bwpage.Free;
    book_a.free;
    book2open:=false;
   end
else
 if displayeditem='flask1' then
  begin
   VideoPlay('resources\anim\2_145.avi');
   status:=62;
   music1.Notify:=false;
   music1.pause;
   invpic.visible:=false;
   flask1:=false;
   inv_delay.enabled:=true;
  end
else
 if (pic3.book3open=false) and (pic2.book2open=false) and (pic2.book1open=false) and (pic2.displayeditem='shieldbook') then
  begin
   Bookdisplay('resources\books\2_063_a.jpeg');
   pic3.book3open:=true;
  end
else
if (pic3.book3open=true) and (pic2.displayeditem='shieldbook') then
 begin
  book_a.free;
  pic3.book3open:=false;
  pic3.book3opened:=false;
 end;
end;

procedure TPic2.delay_tuidownTimer(Sender: TObject);
begin
 delay_tuidown.Enabled:=false;
 voice1.FileName:='resources\audio\li_tui.avi';
 voice1.Open;
 voice1.play;
 //voice1.Notify:=true;
end;

procedure TPic2.voice1Notify(Sender: TObject);
begin
if status=63 then
 begin
  VideoPlay('resources\anim\2_129.avi');
  status:=64;
end;

if status=26 then
 begin
  CVideoPlay('resources\effects\tui_down.avi', 319, 42, 146, 185);
  status:=25;
  music1.Notify:=true;
  music1.play;
  voicefinished:=true;
 end;

if status=6 then
 begin
  keypad2.visible:=true;
   if length(combination)>=4 then combination:='';
   if combination='447' then
    begin
     if status=6 then
      begin
       keypad2.visible:=false;
       VideoPlay('resources\anim\2_144.avi');
       status:=27;
      end
    end
 end;

if (status=35) and (starpos=0) then
 begin
  VideoPlay('resources\anim\2_115.avi');
  status:=32;
 end
else
 if (status=35) and (starpos<>0) then
  begin
   VideoPlay('resources\anim\2_112.avi');
   status:=30;
  end;

if status=41 then
 begin
  panel.free;

  invpic.picture.loadfromfile('resources\inv\token.gif');
  invitem:=7;
  displayeditem:='token';

  image1.Picture.LoadFromFile('resources\books\2_049.jpeg');
 end;

if (status=48) and (throwcount<3) then
 begin
  panel.free;
  music1.Notify:=true;
  music1.pause;
  invpic.Visible:=true;
 end;

if (status=48) and (throwcount=3) then
 begin
  panel.free;
  VideoPlay('resources\anim\2_155.avi');
  status:=50;
  templeopen:=true;
 end
end;

procedure TPic2.InvPicClick(Sender: TObject);
begin
 inv_delay.Enabled:=true;
end;

procedure TPic2.k2btn1Click(Sender: TObject);
begin
 keypad2.Visible:=false;
 combination:=combination+'1';
 ButtonSound('resources\snd\btn1.avi');
end;

procedure TPic2.k2btn7Click(Sender: TObject);
begin
 keypad2.Visible:=false;
 combination:=combination+'7';
 ButtonSound('resources\snd\btn7.avi');
end;

procedure TPic2.k2btn2Click(Sender: TObject);
begin
 keypad2.Visible:=false;
 combination:=combination+'2';
 ButtonSound('resources\snd\btn2.avi');
end;

procedure TPic2.k2btn3Click(Sender: TObject);
begin
 keypad2.Visible:=false;
 combination:=combination+'3';
 ButtonSound('resources\snd\btn3.avi');
end;

procedure TPic2.k2btn4Click(Sender: TObject);
begin
 keypad2.Visible:=false;
 if combination='44' then combination:='4';
 if combination<>'4' then
  begin
   combination:='4';
  end
 else
  begin
   combination:='44';
  end;
 ButtonSound('resources\snd\btn4.avi');
end;

procedure TPic2.k2btn5Click(Sender: TObject);
begin
 keypad2.Visible:=false;
 combination:=combination+'5';
 ButtonSound('resources\snd\btn5.avi');
end;

procedure TPic2.k2btn6Click(Sender: TObject);
begin
 keypad2.Visible:=false;
 combination:=combination+'6';
 ButtonSound('resources\snd\btn6.avi');
end;

procedure TPic2.k2btn8Click(Sender: TObject);
begin
 keypad2.Visible:=false;
 combination:=combination+'8';
 ButtonSound('resources\snd\btn8.avi');
end;

procedure TPic2.k2btn9Click(Sender: TObject);
begin
 keypad2.Visible:=false;
 combination:=combination+'9';
 ButtonSound('resources\snd\btn9.avi');
end;

procedure TPic2.o_exitsensorDblClick(Sender: TObject);
begin
if status=30 then
  begin
   ButtonSound('resources\snd\447.avi');
   status:=35;
  end
else
if status=32 then
  begin
   VideoPlay('resources\anim\2_110.avi');
   status:=7;
   music1.Notify:=false;
   music1.stop;
   music1.close;
   o_exit:=true;
   o_exitsensor.visible:=false;
   centersensor.visible:=false;
   centersensor.visible:=true;
  end
end;

procedure TPic2.Image1DblClick(Sender: TObject);
begin
 if status=27 then
  begin
   VideoPlay('resources\anim\2_143.avi');
   status:=28;
   music1.Notify:=false;
   music1.stop;
   music1.close;
  end;

if status=40 then
  begin
   VideoPlay('resources\anim\2_139.avi');
   status:=41;
  end;
end;

procedure TPic2.TopSensorDblClick(Sender: TObject);
begin
 if (status=28) and (tokeninserted=true) then
  begin
   VideoPlay('resources\anim\2_072.avi');
   status:=33;
   boardsensor.Visible:=false;
   telesensor.Visible:=false;
  end
else
 if status=28 then
  begin
   VideoPlay('resources\anim\2_071.avi');
   status:=33;
   boardsensor.Visible:=false;
   telesensor.Visible:=false;
  end
end;

procedure TPic2.globesensorDblClick(Sender: TObject);
begin
 if status=29 then
  begin
   CVideoPlay('resources\effects\globe.avi', 418, 195, 129, 92);
   status:=34;
   if (medallion=false) and (medallionused=false) then firsttimemedallion:=true;   
  end
end;

procedure TPic2.book2sensorDblClick(Sender: TObject);
begin
 if status=29 then
  begin
   VideoPlay('resources\anim\2_122.avi');
   status:=29;
   if book2=false then firsttimebook2:=true;
   book2:=true;
   chairempty:=true;
  end
end;

procedure TPic2.telesensorDblClick(Sender: TObject);
begin
 if status=28 then
  begin
   VideoPlay('resources\anim\2_068.avi');
   status:=37;
   invpic.Visible:=false;
  end
end;

procedure TPic2.boardsensorDblClick(Sender: TObject);
begin
 if status=28 then
  begin
   VideoPlay('resources\anim\2_070.avi');
   status:=38;
   wheel_big.visible:=true;
   wheel_small.Visible:=false;
   boardsensor.Visible:=false;
   telesensor.Visible:=false;
  end
end;

procedure TPic2.fixbooksensorDblClick(Sender: TObject);
begin
if status=39 then
  begin
   VideoPlay('resources\anim\2_093.avi');
   status:=40;
   lenspocket.Visible:=false;
   fixbooksensor.Visible:=false;
  end
end;

procedure TPic2.lenspocketDblClick(Sender: TObject);
begin
if (status=39) and (lensempty=false) then
  begin
   VideoPlay('resources\anim\2_092.avi');
   status:=42;
   lenspocketclose.visible:=true;
   fixbooksensor.Visible:=false;
  end
else
if (status=39) and (lensempty=true) then
  begin
   VideoPlay('resources\anim\2_090.avi');
   fixbooksensor.visible:=true;
  end
else
if (status=42) and (lensempty=false) then
  begin
   VideoPlay('resources\anim\2_094.avi');
   status:=39;
   lens:=true;
   lensempty:=true;
   lenspocketclose.visible:=false;
  end
end;

procedure TPic2.lenspocketcloseDblClick(Sender: TObject);
begin
if (status=42) and (lensempty=false) then
  begin
   VideoPlay('resources\anim\2_095.avi');
   status:=39;
   lenspocketclose.Visible:=false;
   fixbooksensor.Visible:=true;
  end
end;

procedure TPic2.telesensorDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (source = InvPic) and (displayeditem='lens') then
  begin
   VideoPlay('resources\anim\2_067.avi');
   lensinserted:=true;
  end
end;

procedure TPic2.telesensorDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if Status=28 then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic2.wheel_smallClick(Sender: TObject);
begin
 turn_delay.Enabled:=true;
end;

procedure TPic2.turn_delayTimer(Sender: TObject);
begin
if status=28 then
  begin
   wheelPanel:=TTransparentPanel.Create(self);
   wheelPanel.Parent := Self;
   wheelPanel.Left :=182;
   wheelPanel.Top :=212;
   wheelPanel.Width:=36;
   wheelPanel.Height:=28;

   wheelplayer.FileName:='resources\effects\wheel_small.avi';
   wheelplayer.Open;
   wheelplayer.Display:=wheelPanel;
   wheelplayer.DisplayRect:=wheelPanel.ClientRect;
   wheelplayer.play;

   if starpos<=10 then starpos:=starpos+1 else starpos:=0;
  end
else
 if status=38 then
  begin
   wheelPanel:=TTransparentPanel.Create(self);
   wheelPanel.Parent := Self;
   wheelPanel.Left :=350;
   wheelPanel.Top :=267;
   wheelPanel.Width:=80;
   wheelPanel.Height:=80;

   wheelplayer.FileName:='resources\effects\wheel_big.avi';
   wheelplayer.Open;
   wheelplayer.Display:=wheelPanel;
   wheelplayer.DisplayRect:=wheelPanel.ClientRect;
   wheelplayer.play;

   if starpos<=10 then starpos:=starpos+1 else starpos:=0;
  end;

turn_delay.Enabled:=false;
end;

procedure TPic2.wheel_smallDblClick(Sender: TObject);
begin
 if status=28 then
  begin
   turn_delay.Enabled:=false;
   VideoPlay('resources\anim\2_070.avi');
   status:=38;
   wheel_big.visible:=true;
   wheel_small.Visible:=false;
   boardsensor.Visible:=false;
   telesensor.Visible:=false;   
  end
end;

procedure TPic2.wheel_bigDblClick(Sender: TObject);
begin
 if status=38 then
  begin
   turn_delay.Enabled:=false;
   VideoPlay('resources\anim\2_097.avi');
   status:=39;
   wheel_big.visible:=false;
   lenspocket.Visible:=true;
   fixbooksensor.Visible:=true;
  end
end;

procedure TPic2.tokensocketDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if Status=31 then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic2.tokensocketDragDrop(Sender, Source: TObject; X,
  Y: Integer);
begin
if (source = InvPic) and (displayeditem='token') and (starpos<>10) then
  begin
   VideoPlay('resources\anim\2_106.avi');
  end
 else
  if (source = InvPic) and (displayeditem='token') and (starpos=10) then
  begin
   VideoPlay('resources\anim\2_108.avi');
   tokeninserted:=true;
  end;
end;

procedure TPic2.laddersensorDblClick(Sender: TObject);
begin
exitswordchamber:=true;
if (status=31) and (tokeninserted=true) and (haveblanket=false) and (swordtaken=false) then
  begin
   VideoPlay('resources\anim\2_105.avi');
   status:=44;
  end
else
 if (status=31) and (tokeninserted=true) and (haveblanket=true) and (swordtaken=false) then
  begin
   VideoPlay('resources\anim\2_104.avi');
   status:=44;
  end
else
 if (status=31) and (tokeninserted=true) and (haveblanket=true) and (swordtaken=true) then
  begin
   VideoPlay('resources\anim\2_103.avi');
   status:=64;
  end
end;

procedure TPic2.blanketsensorDblClick(Sender: TObject);
begin
 if (status=44) and (blanket=false) then
  begin
   VideoPlay('resources\anim\2_131.avi');
   firsttimeblanket:=true;
   blanket:=true;
   haveblanket:=true;
  end
end;

procedure TPic2.cheat4Click(Sender: TObject);
begin
 invitem:=7;
 displayeditem:='token';
 invpic.Picture.loadfromfile('resources\inv\token.gif');
 token:=true;
 starpos:=10;
 key1:=true;
end;

procedure TPic2.picsensorDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if Status=4 then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic2.picsensorDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (source = InvPic) and (displayeditem='blanket') then
  begin
   VideoPlay('resources\anim\2_137.avi');
   blanketplaced:=true;
  end
end;

procedure TPic2.cheat3Click(Sender: TObject);
begin
 invitem:=9;
 displayeditem:='blanket';
 invpic.Picture.loadfromfile('resources\inv\blanket.gif');
 blanket:=true;
 haveblanket:=true;

 invitem:=4;
 displayeditem:='spear';
 invpic.Picture.loadfromfile('resources\inv\spear.gif');
 spear:=true;

 invitem:=3;
 displayeditem:='coins';
 invpic.Picture.loadfromfile('resources\inv\coins.gif');
 coins:=true;

 invitem:=5;
 displayeditem:='medallion';
 invpic.Picture.loadfromfile('resources\inv\medallion.gif');
 medallion:=true;

 invitem:=1;
 displayeditem:='book';
 invpic.Picture.loadfromfile('resources\inv\book.gif');
 book:=true;

 invitem:=6;
 displayeditem:='book2';
 invpic.Picture.loadfromfile('resources\inv\book2.gif');
 book2:=true;
end;

procedure TPic2.pic2sensorDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if Status=4 then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic2.pic2sensorDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (source = InvPic) and (displayeditem='spear') then
  begin
   VideoPlay('resources\anim\2_136.avi');
   spear:=false;
   inv_delay.Enabled:=true;
   firsttimespear2:=true;
  end
end;

procedure TPic2.waysensor1DblClick(Sender: TObject);
begin
if status=4 then
  begin
   VideoPlay('resources\anim\2_135.avi');
   status:=47;
  end
end;

procedure TPic2.torchsensorDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if (Status=48) or (status=50) then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic2.torchsensorDragDrop(Sender, Source: TObject; X,
  Y: Integer);
begin
if (source = InvPic) and (displayeditem='spear2') and (status=48) then
  begin
   VideoPlay('resources\anim\2_150.avi');
   havetorch:=true;
  end
 else
if (source = InvPic) and (displayeditem='spear2') and (status=50) then
  begin
   VideoPlay('resources\anim\2_149.avi');
   havetorch:=true;
  end
end;

procedure TPic2.windowsensorDragOver(Sender, Source: TObject; X,
  Y: Integer; State: TDragState; var Accept: Boolean);
begin
if Status=48 then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic2.cheat1Click(Sender: TObject);
begin
 offering:=true;
end;

procedure TPic2.doorsensorDblClick(Sender: TObject);
begin
 if (status=50) and (drawerempty=true) and (spear3=false) then
  begin
   VideoPlay('resources\anim\2_165.avi');
   status:=51;
  end
else
 if (status=50) and (drawerempty=false) then
  begin
   VideoPlay('resources\anim\2_185.avi');
   status:=51;
   invpic.Visible:=false;
  end
else
 if status=53 then
  begin
   VideoPlay('resources\anim\2_175.avi');
   status:=49;
  end
else
 if (status=50) and (drawerempty=true) and (spear3=true) then
  begin
   VideoPlay('resources\anim\2_164.avi');
   status:=58;
  end;
end;

procedure TPic2.cheat2Click(Sender: TObject);
begin
 drawerempty:=true;
end;

procedure TPic2.floorshelfsensorDblClick(Sender: TObject);
begin
 if status=51 then
  begin
   VideoPlay('resources\anim\2_174.avi');
   status:=52;
  end
 else
 if status=58 then
  begin
   VideoPlay('resources\anim\2_171.avi');
   status:=52;
  end;
end;

procedure TPic2.booksensor1DblClick(Sender: TObject);
begin
 if status=52 then
  begin
   VideoPlay('resources\anim\2_159.avi');
   status:=55;
   invpic.visible:=false;
  end;
end;

procedure TPic2.booksensor2DblClick(Sender: TObject);
begin
if status=52 then
  begin
   VideoPlay('resources\anim\2_160.avi');
   status:=56;
   invpic.visible:=false;
  end;
end;

procedure TPic2.booksensor3DblClick(Sender: TObject);
begin
if status=52 then
  begin
   VideoPlay('resources\anim\2_161.avi');
   status:=57;
   invpic.visible:=false;
  end;
end;

procedure TPic2.mystsensorDblClick(Sender: TObject);
begin
if status=52 then
  begin
   VideoPlay('resources\anim\2_148.avi');
   invpic.Visible:=false;
  end;
end;

procedure TPic2.lavasensorDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if Status=59 then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic2.lavasensorDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (source = InvPic) and (displayeditem='book') then
  begin
   VideoPlay('resources\anim\2_151.avi');
   booktolava:=booktolava+1;
   if booktolava=2 then status:=61;
  end
else
if (source = InvPic) and (displayeditem='book2') then
  begin
   VideoPlay('resources\anim\2_156.avi');
   booktolava:=booktolava+1;
   if booktolava=2 then status:=61;
  end
end;

procedure TPic2.statshowTimer(Sender: TObject);
begin
 spinedit1.value:=status;
end;

procedure TPic2.keysensor1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if Status=44 then
  begin
   if (Source = InvPic) then Accept := True;
  end
 else Accept:=false;
end;

procedure TPic2.keysensor1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (source = InvPic) and (displayeditem='key1') then
  begin
   music1.Notify:=false;
   music1.Pause;
   invpic.Visible:=false;
   VideoPlay('resources\anim\2_127.avi');
   status:=63;
   swordtaken:=true;
  end
end;

procedure TPic2.reportClick(Sender: TObject);
begin
 reporttimer.Enabled:= not reporttimer.Enabled;
end;

procedure TPic2.reporttimerTimer(Sender: TObject);
begin
 memo1.lines.Clear;
 if blanketsensor.visible=true then memo1.Lines.Add('blanketsensor');
 if boardsensor.visible=true then memo1.Lines.Add('boardsensor');
 if book2sensor.visible=true then memo1.Lines.Add('book2sensor');
 if booksensor.visible=true then memo1.Lines.Add('booksensor');
 if booksensor1.visible=true then memo1.Lines.Add('booksensor1');

 if booksensor2.visible=true then memo1.Lines.Add('booksensor2');
 if booksensor3.visible=true then memo1.Lines.Add('booksensor3');
 if bottom_sensor.visible=true then memo1.Lines.Add('bottom_sensor');
 if centersensor.visible=true then memo1.Lines.Add('centersensor');
 if coin_offering.visible=true then memo1.Lines.Add('coin_offering');

 if doorsensor.visible=true then memo1.Lines.Add('doorsensor');
 if drawersensor1.visible=true then memo1.Lines.Add('drawersensor1');
 if fixbooksensor.visible=true then memo1.Lines.Add('fixbooksensor');
 if floorshelfsensor.visible=true then memo1.Lines.Add('floorshelfsensor');
 if globesensor.visible=true then memo1.Lines.Add('globesensor');

 if keypad1.visible=true then memo1.Lines.Add('keypad1');
 if keypad2.visible=true then memo1.Lines.Add('keypad2');
 if keysensor1.visible=true then memo1.Lines.Add('keysensor1');
 if laddersensor.visible=true then memo1.Lines.Add('laddersensor');
 if lavasensor.visible=true then memo1.Lines.Add('lavasensor');

 if left_sensor.visible=true then memo1.Lines.Add('left_sensor');
 if lenspocket.visible=true then memo1.Lines.Add('lenspocket');
 if lenspocketclose.visible=true then memo1.Lines.Add('lenspocketclose');
 if mystsensor.visible=true then memo1.Lines.Add('mystsensor');
 if o_exitsensor.visible=true then memo1.Lines.Add('o_exitsensor');

 if pic2sensor.visible=true then memo1.Lines.Add('pic2sensor');
 if picsensor.visible=true then memo1.Lines.Add('picsensor');
 if right_sensor.visible=true then memo1.Lines.Add('right_sensor');
 if shelfsensor.visible=true then memo1.Lines.Add('shelfsensor');
 if spearsensor.visible=true then memo1.Lines.Add('spearsensor');

 if telesensor.visible=true then memo1.Lines.Add('telesensor');
 if tokensocket.visible=true then memo1.Lines.Add('tokensocket');
 if topsensor.visible=true then memo1.Lines.Add('topsensor');
 if torchsensor.visible=true then memo1.Lines.Add('torchsensor');
 if tuisensor.visible=true then memo1.Lines.Add('tuisensor');

 if vasesensor.visible=true then memo1.Lines.Add('vasesensor');
 if wallsensor.visible=true then memo1.Lines.Add('wallsensor');
 if wardrobe.visible=true then memo1.Lines.Add('wardrobe');
 if wardrobesensor.visible=true then memo1.Lines.Add('wardrobesensor');
 if waysensor1.visible=true then memo1.Lines.Add('waysensor1');

 if wheel_big.visible=true then memo1.Lines.Add('wheel_big');
 if wheel_small.visible=true then memo1.Lines.Add('wheel_small');
 if windowsensor.visible=true then memo1.Lines.Add('windowsensor');

end;

procedure TPic2.wheelplayerNotify(Sender: TObject);
begin
with Sender as TMediaPlayer do
   begin
     case Mode of
       mpStopped:
        begin
         wheelpanel.free;
         if (status=28) and (tokeninserted=true) and (starpos<>10) then
          begin
           VideoPlay('resources\anim\2_101.avi');
           status:=46;

           tokensocket.Visible:=false;
           wheel_small.visible:=true;
           telesensor.visible:=true;
           boardsensor.visible:=true;
           image1.Picture.LoadFromFile('resources\img\2_029.jpeg');
           tokeninserted:=false;
          end;

          if (status=38) and (tokeninserted=true) and (starpos<>10) then
          begin
           VideoPlay('resources\anim\2_101.avi');
           status:=45;
           image1.Picture.LoadFromFile('resources\img\2_039.jpeg');
           wheel_big.visible:=true;
           tokeninserted:=false;
          end;
        end
       end;
      Notify:=true;
     end;
    end;

procedure TPic2.windowsensorDragDrop(Sender, Source: TObject; X,
  Y: Integer);
begin
 if (displayeditem='coins') and (offering=true) then
  begin
   Recycle('resources\anim\2_152.avi');
  end
else
 if (displayeditem='coins') and (offering=false) then
  begin
   NoOffering;
  end
else
 if (displayeditem='medallion') and (offering=true) then
  begin
   Recycle('resources\anim\2_153.avi');
  end
else
 if (displayeditem='medallion') and (offering=false) then
  begin
   NoOffering;
  end
else
 if (displayeditem='scroll') and (offering=true) then
  begin
  Recycle('resources\anim\2_154.avi');
 end
else
 if (displayeditem='scroll') and (offering=false) then
  begin
   NoOffering;
  end
end;

procedure TPic2.cheat5Click(Sender: TObject);
begin
 book:=true;
 book2:=true;
end;

end.
