function Timer(ncount, Param1)
     if not StopSheet then
          AlfingSheet();
          StopSheet=false;
     return;end;
return;end;
function SheetSwitched (ncount)
     StopSheet=true;
return;end;
function papuga()
     playeffect("papuga");
return;end;
function gameinput (sender,obj_id,attachedID)
    if sender == 100 then
  if flags.comx then
    speciale_action(2,12121,true);
    add_free_leaf("map10",9,101);
    set_satelite_leaf("antikvar");
    DoFile(9,101)
    flags.comx= false;
    flags.comx1= true;
  return;end;
  return;end;
  if sender == 12 then
      if obj_id==22 then
      AddElement("gr",obj_id);
      SetAlfaSheet(2.5)
      setcolor(obj_id,0,0,0,0.5,1);
      MoveObjectToTree(obj_id);
      flags.korm=true;
       end;
      if obj_id==117 then
      AddElement("gr",117);
      CreateWindow(150,250,"207",207,nil,250,30);
      SetAlfaSheet(2.5)
      MoveObjectToTree(117);
      flags.coin=true;
       end;
      if obj_id==116 then
      AddElement("gr",116);
      SetAlfaSheet(2.5)
      MoveObjectToTree(116);
       end;
      if obj_id==32 then
      AddElement("gr",obj_id);
      SetAlfaSheet(2.5)
      setcolor(obj_id,0,0,0,0.5,1);
      MoveObjectToTree(obj_id);
      flags.tryapka=true;
       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 == 35 then
    if obj_id ==200 then
      StartAnimation(200,0,4)
    return;end;
  return;end;
  if sender == 2 then
       RemoveFromMouse(object);
    MessageProc(sender,obj_id);
  return;end;
    if sender==26 then
      if obj_id ==5 then
        flags.levelcomplete=true;
        DarkScreen(true);
        ShowMenu(false)
      return; end;  
      if obj_id ==207 and flags.all9 then
        CreateWindow(150,250,"399",5,nil,250,30);
      return; end;
      if obj_id ==208 then
        CreateWindow(150,250,"204",nil,nil,250,30);
      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;
         -- растемнилось

    return;end;     
    if obj_id==503 then --название уровня
        BlockCursor(false);
      if whole_darkness then
         --затемнилось
      return;end;  
      AddParticleToObject(25,"kletka",892,399);
      MoveEmiter("kletka",892,399);
      if not flags.parrot then
        StartEmiter("kletka");
      end;
      -- AddParticleToObject(117,"coin",883,596);
      -- MoveEmiter("coin",883,596);
      -- if not flags.coin then
        -- StartEmiter("coin");
      -- end;      
      -- проявление меню вывод собщений в начале уровня ----
      ShowMenu(true);
      savegame(SaveLevel());
        --CreateWindow(100,100,"197");       
      ------
    return;end;
  return;end;
    if pause_state then
    if sender==1 or sender==6 or sender==14 then
      pause_state=false;
      --set_visible_object(11111,false);
    end;  
  return;end;
  if sender == 1 then --кликнули левой кнопкой мыши на активный объект
    if flags.parrot and (not flags.buyer) then 
      if obj_id~=60 then
        CreateWindow(150,250,"198",nil,nil,250,30);
      end;
    end;
    if obj_id==501 then
      if flags.levelcomplete then
        if attachedID==-1 then
          delete_tree_leaf("Root","antikvar");-- Добавляет лист в дерево 
          
          setnextlavel(10);
          loadlavel();  
        return; end;
      return;end;        
    DarkScreen(false);
    whole_darkness=false;
    SetAlfa(503,1,0,1);
    return;end;      
  if obj_id==22 then
    if attachedID==-1 then
      collaps_obj(obj_id,0,0,10,0);
      playeffect("20");

    return;end;
  return; end;
  if obj_id==32 then
    if attachedID==-1 then
      collaps_obj(obj_id,0,0,10,0);
      playeffect("20");

    return;end;
  return; end;
    if obj_id==25 then   
  if not flags.parrot then

      if flags.parrot1 then
        if attachedID==32 then         
          RemoveFromMouse(attachedID);
          SetAlfaSheet(2.0)
          DeleteElement("gr",attachedID);
          Set_Cursor(25,3);
          speciale_action(2,23);
          flags.parrot=true;
          StopEmiter("kletka")
           CreateWindow(150,250,"209",nil,"anti",250,30);
        return;end;  
        if  (attachedID~=32) and (attachedID>-1) then 
        RemoveFromMouse(attachedID);
          CreateWindow(150,250,"200",nil,nil,250,30); 
        return; end;  
        if attachedID==-1 then        
          CreateWindow(150,250,"202",nil,nil,250,30);
        return; end;        
      return; end;
      if attachedID==22 then         
        RemoveFromMouse(attachedID);
        SetAlfaSheet(2.0)
        DeleteElement("gr",attachedID);
        speciale_action(2,100);
        speciale_action(2,24);  
        flags.parrot1=true;            
      return;end;  
      if  (attachedID~=22) 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;
  -- CreateWindow(150,250,"204",nil,nil,250,30);
  return; end;
  if obj_id==60 then
    if flags.parrot and (not flags.buyer) then  
      if attachedID==114 then          --заменить на объект визитка
        RemoveFromMouse(attachedID);
        SetAlfaSheet(2.0)
        DeleteElement("gr",attachedID);
        Set_Cursor(60,3);
        speciale_action(2,60);
        flags.buyer=true;
        ShowMenu(false);
        frame=0;
        add_free_leaf("comics",9,50);
        set_satelite_leaf("antikvar");
        DoFile(9,50)
      return;end;  
      if  (attachedID~=114) and (attachedID>-1) then 
        RemoveFromMouse(attachedID);
        CreateWindow(150,250,"200",nil,nil,250,30);
      return; end;  
      if attachedID==-1 then        
        CreateWindow(150,250,"205",nil,nil,250,30);
      return; end;        
    return; end;      
  return;end;  
  if flags.buyer then

  if obj_id==117 then
    if attachedID==-1 then
      collaps_obj(117,0,0,10,0);
      playeffect("20");


    return;end;
  return; end;
  if obj_id==116 then
    if attachedID==-1 then
      collaps_obj(116,0,0,10,0);
      -- CreateWindow(150,250,"207",nil,nil,250,30);
      playeffect("20");

      -- flags.coin=true;
    return;end;
  return; end;

    if obj_id==8 then
      if attachedID==-1 then
        if not flags.minicomplete45 then
          add_free_leaf("Root","mini45",0,55);
          set_satelite_leaf("antikvar");
          DoFile(0,55)
          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==6 then
    if not flags.parrot then 
    RemoveFromMouse(object);
      CreateWindow(150,250,"208",208,"anti",250,30);
    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==4 then
  -- WriteToConsole("sender = 4, lev.9.0".." "..sender.."\n")
    flags.all9= true;
    CreateWindow(150,250,"399",5,nil,250,30);
  return; end;  
------------------------------------------------------------------------------------------------------------------  

end
function SelectRandom()
  idObject=GetRandomObject();
  if not flags.buyer then
    if not flags.korm then
      selectrandomobject(1.5,22);
     end;
    if not flags.tryapka then
      selectrandomobject(1.5,32);
     end;
    if flags.korm and flags.tryapka then
      if (not flags.parrot) then
      selectrandomobject(1.5,25);
     end;
   end;
   selectrandomobject(1.5,60);
   end;
  if flags.buyer then
  selectrandomobject(1.5,idObject);
  end;
end;
function SelectRandomRadar(idObject)
  selectrandomobject(1.5,idObject);
end;
