mousepressed = false;
reset = false;


skip = false;

function SkipActions()
    SetObjectPosition(1009,556,165)
    SetObjectPosition(1010,667,165)
    SetObjectPosition(1011,778,165)
    SetObjectPosition(1006,112,165)
    SetObjectPosition(1007,223,165)
    SetObjectPosition(1008,334,165)
    finish_mini_game(true);
end;

function mini_create ()
    show_help_wnd=true;
    init_mini(true);
    
    create_mini(37,7,112,165,111,213,1006);
    check_mini_game_Holes(0);
    StartTimer(88821,0.5)
--    CreateWindow1(100,100,"58",nil,nil,200,200,nil,nil,nil);
end;

function Buttons_T(sender,id)
    ButtonTreatment(id,10001,10002,10003,CloseBtnX,CloseBtnY,CloseWidth,CloseHeight,sender,"mayor_portal",true)
    ButtonTreatment(id,10021,10022,10023,HelpBtnX,HelpBtnY,HelpWidth,HelpHeight,sender,"mayor_portal",true,58,200,200)
   if skip then
        ButtonTreatment(id,10011,10012,10013,SkipBtnX,SkipBtnY,111,31,sender,"mayor_portal",true)
   end;  
end; 
function gameinput (sender,id,attachedID)
   CursorTreatment(id,sender,attachedID); 
   Buttons_T(sender,id)
  
  if sender == 100 then
    neighbors.mayor_yard.lock=false;
    LoadLocation("mayor_yard");
    StartTimer(88811,1);
  return; end;
  
  if sender == 36 then    
    if id == 88811 then
      Block_Show_Cur(false);
      CreatePlashechka(900000,"58")
    return; end;
    if id == 88850 then      
      Block_Show_Cur(false);
      flags.portal_lock = true;
      clear_satelite_leaf("mayor_portal");
      finish_mini_game(true);      
    return; end;

  return; end;
  
  if sender == 30 then 
      DeleteResource("portal_lock1");
      DeleteResource("portal_lock2");
      DeleteResource("portal_lock3");
      DeleteResource("portal_lock4");
      DeleteResource("portal_lock5");
      DeleteResource("portal_lock6");
      DeleteResource("portal_lock7");
      DeleteResource("portal_lock8");
      DeleteResource("portal_lock9");
      DeleteResource("portal_lock18");
      DeleteResource("portal_svet");     
    setcurentleaf("mayor_portal",5,0);     
    Block_Show_Cur(false);    
    if flags.portal_lock then
      playeffect("gate")
       Block_Show_Cur(true);
      flags.help_mayor_zamok = true;
      CreatePlashechka(900000,"59")
      speciale_action(2,4,true,4);
      speciale_action(2,8,true,4);
      ActivateObject(5,false);
      Set_Anim_Cur(5,3);
      speciale_action(2,11);
      Set_Anim_Cur(11,14);
      StopEmiter("polka");
      WaitRender()
    return; end;
  return; end;
  
    if (not flags.minikeys_complete) then    
        if sender==35  then
        if id==1052 and not mvis then
            mvis=true
            setcolor(id,1,0.6,0.6,0.7);
        end;
        if id>=1006 and id<=1011 then

            i=hlsGetValidMove();
            if not visible then
            visible=true;
                if i~=-1 then        
                    SetObjectPosition(1015,Fields[i+1],161)
                    speciale_action(2,1015)
                end;
                if i==-1 then        
                    SetObjectPosition(1015,-500,162)
                    speciale_action(2,1015)
                end;
            end;       
        end;
        end;
        if sender==39 then
            if mvis then
                mvis=false
                setcolor(1052,1,1,1,1);
            end;        
            if (not flags.minikeys_complete) then
                if visible then
                    visible=false;        
                    speciale_action(2,1015)
                end;                
            end;
        end;
   end; 
  
  if sender==37 then
    skip = true;
  return;end;
  
  if sender == 10 then    
    playeffect("miniok")
    HideSkip()
    HideHelp()
    Block_Show_Cur(true);
    flags.minikeys_complete=true;
    speciale_action(2,1018,true,3)    
    speciale_action(2,1052,true,1.5)    
    StartTimer(88850,2.5);
  return; end;
 
  if sender == 6 then
    if reset then
      speciale_action(2,1012);
      reset = false;
    return; end;
    
    if mousepressed == true then
      RemoveFromMouse(object);    
      playeffect("keyins")
      check_mini_game_Holes(object);
      mousepressed = false;
      object = 0;
    return;end;    

  return; end;
 
  
  if sender == 1 then
    if visible then 
        visible=false;
        speciale_action(2,1015)
    end;
            
       if attachedID ~= -1 then
        RemObjFromMouse()
      end;     
 
    if id == 1052 then      
      check_mini_game_Holes(0);
      speciale_action(2,1012);
      reset = true;
    return; end;
    
    if id >= 1006 and id <= 1011 then
      mousepressed = true;
      add_to_mouse(id);
      object = id;
    return; end;
    

  return; end;

end;

function mini_delete ()

end;
function SheetSwitched(nCount)
end;