counter = 0;
press_button = false;

corova = false;
dog = false;
fish = false;
man = false;
back=false
was_press_button=false
apparat_corova = false;
apparat_fish = false;
apparat_dog = false;
apparat_man = false;

function SkipActions()
    finish_mini_game(true);
end;

skip = false;
function mini_create ()
    show_help_wnd=true;
    init_mini(true);
    
    create_mini(8128);
    StartTimer(88821,0.5)
end;

function Buttons_T(sender,id)
   ButtonTreatment(id,10001,10002,10003,CloseBtnX,CloseBtnY,CloseWidth,CloseHeight,sender,"laborator",true)
   ButtonTreatment(id,10021,10022,10023,HelpBtnX,HelpBtnY,HelpWidth,HelpHeight,sender,"laborator",true,52,200,150)
   if skip then
    ButtonTreatment(id,10011,10012,10013,SkipBtnX,SkipBtnY,111,31,sender,"laborator",true)
   end; 
end;
function gameinput (sender,id,attachedID)
CursorTreatment(id,sender,attachedID);
Buttons_T(sender,id)
 
  if sender == 100 then
    StartTimer(88811,0.3);
  return; end;
  if sender==26 then
    may_play=true
  return;end;  
  if sender == 36 then 
    if id == 88811 then
      CreatePlashechka(900000,"52")
      Block_Show_Cur(false);
    return; end;
    if id == 88850 then      
      Block_Show_Cur(false);

      clear_satelite_leaf("laborator"); 
      UnStoreObj(obj.scrtng.id);
      finish_mini_game(true);
    return; end;
  return; end;
  
  if sender == 30 then
  objectid = 0;
      DeleteResource("dnk_05");
      DeleteResource("dnk_37");     
      DeleteResource("dnk_all");
    setcurentleaf("laborator",2,0);     
    if hint then
      flags.GlobalHint = false;
    end;
    Block_Show_Cur(false);    
    if flags.mini_dnk then
        speciale_action(2,14);
        AddParticleToObject(14,"p6",228,348);
        MoveEmiter("p6",228,348);
        StartEmiter("p6");     
        Set_Anim_Cur(14,2)
        CreatePlashechka(900000,"53")
        IfTableClose()
    return; end;
  return; end;
  
  if sender==37 then
    skip = true;
  return;end;
  
  if sender == 10 then    
    playeffect("miniok")
    Block_Show_Cur(true);
    HideSkip()
    HideHelp()
    StartTimer(88850,0.5);
    flags.mini_dnk = true;
  return; end;
 
  if sender == 1  and may_play then   
  
        if attachedID ~= -1 then
        RemObjFromMouse()
      end;  

    if id == 1017 then --взяли корову
      corova = true; dog = false; fish = false; man =false;
      speciale_action(2,1014);
      speciale_action(2,1017);
      add_to_mouse(1014);
      mousepressed = true;
      objectid = id;
    return; end;
    if id == 1019 then --рыба
      corova = false; dog = false; fish = true; man =false;
      speciale_action(2,1013);
      speciale_action(2,1019);
      add_to_mouse(1013);
      mousepressed = true;
      objectid = id;
    return; end;
    if id == 1021 then --собака
      corova = false; dog = true; fish = false; man =false;
      speciale_action(2,1012);
      speciale_action(2,1021);
      add_to_mouse(1012);
      mousepressed = true;
      objectid = id;
      -- addObjectToMouse(1012);
    return; end;
    if id == 1023 then -- чел
      corova = false; dog = false; fish = false; man = true;
      speciale_action(2,1011);
      speciale_action(2,1023);
      add_to_mouse(1011);
      mousepressed = true;
      objectid = id;
    return; end;
    
    if id == 1010 then
    if not press_button    then
        BlockCursor(true)
        speciale_action(2,1035,true);
    end;
      playeffect("probirka")
      if apparat_corova then
        apparat_corova = false; apparat_fish = false; apparat_dog = false; apparat_man = false;
        speciale_action(2,1010);
        speciale_action(2,1009);
        apparat_corova = false;
        speciale_action(2,1017);
        SetObjectPosition(1014,784,269);
        if was_press_button then
          was_press_button=false
          Set_Anim_Cur(1017,3)     
          ActivateObject(1017,false);
          speciale_action(2,1033);
          speciale_action(2,1040);
        end;

      return; end;
      if apparat_man then
        apparat_corova = false; apparat_fish = false; apparat_dog = false; apparat_man = false;
        speciale_action(2,1010);
        speciale_action(2,1008);
        apparat_man = false;
        speciale_action(2,1023);
        SetObjectPosition(1011,696,163);
        if was_press_button then
            was_press_button=false
            ActivateObject(1023,false);
                  Set_Anim_Cur(1023,3)     
            speciale_action(2,1031);
            speciale_action(2,1042);
         end;

      return; end;
      if apparat_dog then
        apparat_corova = false; apparat_fish = false; apparat_dog = false; apparat_man = false;
        speciale_action(2,1010);
        speciale_action(2,1007);
        apparat_dog = false;
        speciale_action(2,1021);
        SetObjectPosition(1012,728,192);
        if was_press_button then
            was_press_button=false
          ActivateObject(1021,false);
                Set_Anim_Cur(1021,3)     
          speciale_action(2,1032);
          speciale_action(2,1041);
          end;

      return; end;
      if apparat_fish then
        apparat_corova = false; apparat_fish = false; apparat_dog = false; apparat_man = false;
        speciale_action(2,1010);
        speciale_action(2,1006);
        apparat_fish = false;
        speciale_action(2,1019);
        SetObjectPosition(1013,761,226);
        if was_press_button then
          was_press_button=false
          ActivateObject(1019,false);
                Set_Anim_Cur(1019,3)     
          speciale_action(2,1030);
          speciale_action(2,1039);
          end;

      return; end;
      return; end;

    
    if id == 1035 then
      if not press_button then
      speciale_action(2,1035,true);
      BlockCursor(true)
      if apparat_man or apparat_dog or apparat_fish or apparat_corova then

        playeffect("dnk")
        was_press_button=true
        if apparat_fish then
          speciale_action(2,1030,true);
          speciale_action(2,1039,true);
        return; end;
        if apparat_man then
          speciale_action(2,1031,true);
          speciale_action(2,1042,true);
        return; end;
        if apparat_dog then
          speciale_action(2,1032,true);
          speciale_action(2,1041,true);
        return; end;
        if apparat_corova then
          speciale_action(2,1033,true);
          speciale_action(2,1040,true);
        return; end;
      return; end;    
      back=true
    return; end;
    
    return; end;
  return; end;
  
  if sender == 16 then
      if id==1035 then
        Block_Show_Cur(false)
        press_button=false
        -- if back then
            -- back=false
            -- speciale_action(2,1035,true); --скрывается
        -- end;        
    end;
    if id == 1039 then
      counter = counter + 1;
      if counter == 4 then
        StartTimer(88850,0.5);
      return; end;
    return; end;
    if id == 1042 then
      counter = counter + 1;
      if counter == 4 then
        StartTimer(88850,0.5);
      return; end;
    return; end;
    if id == 1041 then
      counter = counter + 1;
      if counter == 4 then
        StartTimer(88850,0.5);
      return; end;
    return; end;
    if id == 1040 then
      counter = counter + 1;
      if counter == 4 then
        StartTimer(88850,0.5);
      return; end;
    return; end;
  return; end;
   if sender==44 then
    AboutItem(obj_id)
  return;end;  
  
  if sender==15 then
    if id==1035 then
        Block_Show_Cur(false)
        press_button=true
        if back then
            back=false
            speciale_action(2,1035,true); --скрывается
            BlockCursor(true)
        end;
    end;
  return;end;

  if sender == 8129 and mousepressed and objectid>0  then    
    if id >= 417 and id <= 551 and attachedID >= 214 and attachedID <= 248 and (not apparat_corova and not apparat_dog and not apparat_fish and not apparat_man) then        
        speciale_action(2,1010);
        playeffect("probirka")
          RemoveFromMouse(objectid);
          mousepresed=false;
          objectid=0;
        ClearCursor()
        if  press_button then
            speciale_action(2,1035,true);
            BlockCursor(true)
        end;
          if corova then
            speciale_action(2,1009);
            apparat_corova = true;          
          speciale_action(2,1014);    
            SetObjectPosition(1014,784,269);
          
          return; end;
          if dog then          
            speciale_action(2,1007);
            apparat_dog = true;
            speciale_action(2,1012);    
            SetObjectPosition(1012,728,192);

          return; end;
          if fish then    
            speciale_action(2,1006);
            apparat_fish = true;
            speciale_action(2,1013);    
            SetObjectPosition(1013,761,226);

          return; end;
          if man then
            speciale_action(2,1008);
            apparat_man = true;
            speciale_action(2,1011);    
            SetObjectPosition(1011,696,163);

          return; end;      
    return; end;
    RemoveFromMouse(objectid);
    mousepresed=false;
    objectid=0;
    if corova then

      speciale_action(2,1017);
      speciale_action(2,1014);
      SetObjectPosition(1014,784,269);
    return; end;
    if dog then      

      speciale_action(2,1021);
      speciale_action(2,1012);
      SetObjectPosition(1012,728,192);

    return; end;
    if fish then
      speciale_action(2,1019);
      speciale_action(2,1013);
      SetObjectPosition(1013,761,226);
    return; end;
    if man then
      speciale_action(2,1023);
      speciale_action(2,1011);
      SetObjectPosition(1011,696,163);
    return; end;
  return; end;
end;

function mini_delete ()

end;
function SheetSwitched(nCount)
end;