local iArrowObj=-1;
skip = false;
function mini_create ()
    show_help_wnd=true;
    init_mini(true);
    create_mini(2,6,6,2147000000,0,"543210",1040,456789123,43,50,0,0);
    StartTimer(88821,0.5)
end;--1048

function SkipActions()
    finish_mini_game(true);
end;

function Buttons_T(sender,id)
   ButtonTreatment(id,10001,10002,10003,CloseBtnX,CloseBtnY,CloseWidth,CloseHeight,sender,"mayor_house",true)
   ButtonTreatment(id,10021,10022,10023,HelpBtnX,HelpBtnY,HelpWidth,HelpHeight,sender,"mayor_house",true,218,200,200)
   if skip then
    ButtonTreatment(id,10011,10012,10013,SkipBtnX,SkipBtnY,111,31,sender,"mayor_house",true)
   end;  
end; 

function gameinput (sender,id,attachedID)
CursorTreatment(id,sender,attachedID); 
Buttons_T(sender,id) 

  if sender == 30 then
      DeleteResource("seyf_kartina_05");
      DeleteResource("seyf_kartina_06");
      DeleteResource("seyf_kartina");
      DeleteResource("seyf_kartina_08");      
      DeleteResource("seyf_kartina_47");
      DeleteResource("vot_ono");         
    setcurentleaf("mayor_house",8,0); 
    if flags.safe_complete and not flags.safe_completeM then
    flags.safe_completeM=true;
      speciale_action(2,25);
      speciale_action(2,26);
      ActivateObject(26,true)      
      Set_Anim_Cur(26,2);
      StopEmiter("seyf_mayor")
      AddParticleToObject(26,"seyf_mayor",662,185);
      MoveEmiter("seyf_mayor",662,185);
      StartEmiter("seyf_mayor");          
    end;
    Block_Show_Cur(false);
    if flags.seyf_kartina then
    CreatePlashechka(900000,"247")
      if not flags.safe_completeM then
          flags.safe_completeM=true;
          speciale_action(2,25);
          speciale_action(2,26);
        end;
      ActivateObject(26,false)      
      Set_Anim_Cur(26,3);
      StopEmiter("seyf_mayor")
    end;
  return; end;
  
  if sender==37 then
    skip = true;
  return;end;
  
  if sender == 100 then
    StartTimer(88811,0.3);
  return; end;
  
  if sender == 36 then 
    if id == 88821 then
      
    return; end;    
    if id == 8882 then
        Block_Show_Cur(false)
        flags.seyf_kartina = true;
      clear_satelite_leaf("mayor_house");
    return; end;    
     
    if id == 88811 then
      Block_Show_Cur(false);
      if not flags.safe_complete then
      CreatePlashechka(900000,"218")
      return; end;
    return; end;

    if id == 8883 then
      playeffect("safe")    
      speciale_action(2,1007);
      speciale_action(2,obj.mernd.id,true);
      Set_Anim_Cur(obj.mernd.id,4)
      speciale_action(2,1006,true);
    return; end;  
  return; end;
  
  if sender == 10 then
    playeffect("miniok")    
    flags.safe_complete=true;
    StartTimer(8883,0.5);
    
    set_text(2002,"1012")
    HideSkip()
    HideHelp()
    speciale_action(2,2005)
    skip=false
  return; end;
  
  if sender==50 then
    StartTimer(8882,2);
    Block_Show_Cur(true)
  return;end;
  
  if sender == 1 then  
       if attachedID ~= -1 then
        RemObjFromMouse()
      end;   

    if id == obj.mernd.id then
      
      StoreObj(obj.merdn.id,id,"246",285,350,"vot_ono",323,217,400000)    
    return; end;
    
    if not flags.kamin_puzzle then
    CreatePlashechka(900000,"1009")
    return;end;
    if id == 1010 then     
      playeffect("btn")    
      check_mini_game_zamok(1040,0,2);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1015 then
      playeffect("btn")
      check_mini_game_zamok(1041,1,2);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1020 then 
      playeffect("btn")
      check_mini_game_zamok(1042,2,2);
      flags.press = true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1025 then
      playeffect("btn")
      check_mini_game_zamok(1043,3,2);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1030 then
      playeffect("btn")
      check_mini_game_zamok(1044,4,2);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1035 then
      playeffect("btn")
      check_mini_game_zamok(1045,5,2);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    ----------------
    if id == 1012 then
      playeffect("btn")
      check_mini_game_zamok(1040,0,1);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1017 then
      playeffect("btn")
      check_mini_game_zamok(1041,1,1);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1022 then
      playeffect("btn")
      check_mini_game_zamok(1042,2,1);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1027 then
      playeffect("btn")
      check_mini_game_zamok(1043,3,1);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1032 then
      playeffect("btn")
      check_mini_game_zamok(1044,4,1);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1037 then
      playeffect("btn")
      check_mini_game_zamok(1045,5,1);
      flags.press=true;      
      iArrowObj = id;
      speciale_action(2,id);
      speciale_action(2,id-1);
    return; end;
    if id == 1039 then
      playeffect("dvr")    
      speciale_action(2,1038,true);
      check_mini_game_zamok(1045,5,4);
    return; end;
  return; end; 
  
  if sender == 6 then
    if flags.press then
      speciale_action(2,iArrowObj);
      speciale_action(2,iArrowObj-1);
      flags.press=false;
    return; end;
  return; end;
 
  if sender == 16 then
    if id == 1038 then
      speciale_action(2,1038,true);
    return; end;
  return; end;

end;

function mini_delete ()

end;
function SheetSwitched(nCount)
end;