function SheetSwitched (ncount)
     StopSheet=true;
return;end;
function Timer(ncount, Param1)
     if not StopSheet then
          AlfingSheet();
          StopSheet=false;
     return;end;
return;end;
function gameinput (sender,obj_id,attachedID)
  if sender == 2 then
    RemoveFromMouse(object);
    MessageProc(sender,obj_id);
  return;end;
  if sender == 100 then
    if flags.comx then
      speciale_action(2,12121,true);
      flags.comx= false
      flags.comx1= true;
      add_free_leaf("map3",2,101);
      set_satelite_leaf("hotel");
      DoFile(2,101)
    return;end;
  return;end;
     if sender==36 then          
          if obj_id==9999 then
               if not StopSheet then
                    AlfingSheet();
                    StopSheet=false;
               return;end;
          return;end;                    
     return;end;
     if sender==15 then          
    if obj_id==444 then
      savegame(SaveLevel());
    return; end;                    
     return;end;
  if sender==12 then
    if obj_id==26 then
      AddElement("gr",26);
      setcolor(26,0,0,0,0.5,1);
      MoveObjectToTree(26);
    end;
    if obj_id==1656 then
      AddElement("gr",1656);
      setcolor(1656,0,0,0,0.5,1);
      MoveObjectToTree(1656);
    end;
    if flags.objects then
       if flags.minicomplete33 then
        CreateWindow(150,250,"380",5,nil,250,30); 
       return;end;    
    end;
  return;end;
  if sender==35 then
    if obj_id== 210 then
      StartAnimation(210,0,3)  
    return;end;
    if obj_id== 201 then
      StartAnimation(201,0,4)  
    return;end;
  return;end;
  if sender==26 then
    if obj_id==11 and flags.objects then
      CreateWindow(150,250,"380",5,nil,250,30);
    return;end;  
    if obj_id==55 then
      CreateWindow(150,250,"255",nil,nil,250,30);
    return;end;  
    if obj_id==5 then
      if flags.objects then
        flags.levelcomplete=true;
        DarkScreen(true);
        ShowMenu(false)
        flags.objects= false;
      return;end;
    return;end;
  return;end;
  if sender==33 then
    BlockCursor(false);
    if obj_id==501 then -- тёмная плашка
      BlockCursor(false);
      if whole_darkness then
         if flags.levelcomplete then
          SetAlfa(500,0,1,1);
          speciale_action(4,500);
          BlockCursor(true);
        return;end;      
      return;end;
      whole_darkness=false;
      AddParticleToObject(6,"Zvezd",381,126);
      MoveEmiter("Zvezd",381,126);
      if not flags.access then
        StartEmiter("Zvezd"); 
      end;
    return;end;     
    if obj_id==503 then --название уровня
        BlockCursor(false);
      if whole_darkness then return;end;      
        ShowMenu(true);
        CreateWindow(150,250,"315",nil,nil,250,30);              
        savegame(SaveLevel());
      return;end;
    return;end;
  if pause_state then
    if sender==1 or sender==6 or sender==14 then
      pause_state=false;
    end;  
  return;end;
  if sender == 1 then --кликнули левой кнопкой мыши на активный объект
    if obj_id==501 then
      if flags.levelcomplete then
        delete_tree_leaf("Root","hotel");-- Добавляет лист в дерево 
        setnextlavel(3);
        loadlavel();
      return;end;        
      DarkScreen(false);
      whole_darkness=false;
      SetAlfa(503,1,0,1);
    return;end;
    if obj_id==53 then
      CreateWindow(150,250,"254",54,"0054",250,30); 
    return; end;  
    if obj_id==444 then
      speciale_action(2,444,true);  
      collaps_obj(26,0,0,10,0);
      playeffect("20");
    return; end;
    if obj_id==6 then
      if not flags.access then       
        if attachedID == 106 then  --воздействуем спичками
          playeffect("pojar");
          RemoveFromMouse(attachedID);
          DeleteElement("gr",attachedID);  
          Set_Cursor(6,3);
          flags.access = true;  
          speciale_action(2,5);
          speciale_action(2,53,true);
          StopEmiter("Zvezd"); 
          frame=1;
          add_free_leaf("comics1",2,51);
          set_satelite_leaf("hotel");
          DoFile(2,51)
          ShowMenu(false);      
        return; end;     
        if attachedID ~= 106 then
          RemoveFromMouse(attachedID);
          CreateWindow(150,250,"203",nil,nil,250,30); 
        return; end;
      return; end;
    return; end;
    if flags.access then
      if obj_id==50 then --шкаф с ключами
        if not flags.minicomplete33 then --шкаф с ключами
          if attachedID == 26 then
            playeffect("29");
            RemoveFromMouse(attachedID);           
            add_free_leaf("Root","mini33",0,43);-- Добавляет чистый лист
            set_satelite_leaf("hotel");
            DoFile(0,43)
            mini_create();
            flags.nohints=true;
          return; end;
          if (attachedID ~= 26) and (attachedID>-1) then
            RemoveFromMouse(attachedID);
            CreateWindow(150,250,"200",nil,nil,250,30); 
          return; end;          
          if attachedID == -1 then
            CreateWindow(150,250,"201",nil,nil,250,30); 
          return; end;                         
        return; end;
      return; end;
      if obj_id==42  then --ресепшн
        if attachedID == -1 then
          if not flags.minicomplete9 then --ресепшн
            playeffect("29");
            add_free_leaf("Root","mini9",0,19);
            set_satelite_leaf("hotel");
            DoFile(0,19)
            mini_create();
            flags.nohints=true;
          return; end;      
        return; end;
      return; end;
      if obj_id > 0 and obj_id < 200 and attachedID == -1 then --кликаем на активный объект
        playeffect("20");
        collaps_obj(obj_id,0,0,10,1);
      return 0; end
    return; end;  
  return; end;
  if sender==14 then
    if obj_id>0 then
      StopSheet=true;
      object=obj_id
      addObjectToMouse(obj_id);
    return; end;
  return; end;  
  if sender==6 then
        if not flags.access then
      RemoveFromMouse(object);
      CreateWindow(150,250,"250",55,"0054",250,30); 
    return; end;
  return; end;    
  ---------------------------------------На сцене отработали все объекты-------------------------
  if sender==4 then
     flags.objects=true
  return; end;  
end
function SelectRandom()
  if not flags.access then
    selectrandomobject(1.5,6);
  return;end;
idObject=GetRandomObject();
  if not flags.minicomplete9 and idObject==26 then
    selectrandomobject(1.5,42);
  return; end;
  if idObject==1656  and (not flags.minicomplete33)then
    selectrandomobject(1.5,50);
  return; end;
selectrandomobject(1.5,idObject);
end;
function SelectRandomRadar(idObject)
  if idObject==26 then
      selectrandomobject(1.5,42);
  return;end;  
  if idObject==1656 then
      selectrandomobject(1.5,50);
  return;end;  
  selectrandomobject(1.5,idObject);
end;
