function mini_create()
  init_mini(true)
  create_mini(8128);
end


Block_Show_Cur(true)


StartTimer(timerID,0.7,"unBlock_Show_Cur")

local t = 0.5

local selected = nil

function gameinput (sender,obj_id,attachedID)
  MiniInterfaceHandler(sender, obj_id);
  sendersProcessing(sender, obj_id, attachedID);
  if wrongItemWarning(sender, obj_id, attachedID, "kuskiMedveda_3_14") then
    return
  end
  if sender==1 then
    if obj_id >= 1 and obj_id <= 12 then
      if flags.medvedActive then
        if not selected then
          selected = obj_id
          setcolor(state[selected],0.7,0.7,0.7,1)
        else
          if obj_id == selected then
            setcolor(state[selected],1,1,1,1)
            selected = nil
          else              -- sosednie segmenty
            local d = selected - obj_id
            if d == -1 or d == 11 then
              setcolor(state[selected],1,1,1,1)
              swap(obj_id,selected,t)
              selected = nil
            elseif d == 1 or d == -11 then
              setcolor(state[selected],1,1,1,1)
              swap(selected,obj_id,t)
              selected = nil
            else
              setcolor(state[selected],1,1,1,1)
              selected = obj_id
              setcolor(state[selected],0.7,0.7,0.7,1)
            end
            checkMini()
          end
        end
      else
        if obj.kuskiMedveda_3_14 and attachedID == obj.kuskiMedveda_3_14.id then
          removeFromMouse()
          UnStoreObj(obj.kuskiMedveda_3_14.id)
          playeffect("sector")
          Block_Show_Cur(true)
          StartTimer(timerID,2.6,"unBlock_Show_Cur")
          speciale_action(2,32,true,0.5)
          speciale_action(2,24,true,0.5)
          speciale_action(2,26,true,0.5)
          flags.medvedActive = true
          for i=1,12 do
            setCursor(i,3)
          end
          StartTimer(45631,0.7,"func1")  

        else
          CreatePlashechka("639")
        end
      end
    end
  end
  if sender == 8 then
    setcolor(state[selected],1,1,1,1)
    selected = nil
  end
  if sender == 10 then
    for i=1,12 do
      ActivateObject(i,false)
      SetAlfa(i,0.01,1,1)
    end
    playeffect("mini_complete")
    -- Block_Show_Cur(true)
    speciale_action(2,14,true,1)
    StartTimer(timerID,2,"CloseSatelite")
    neighbors.Medved.lock = true
  end
end

function func1()
  speciale_action(2,32,true,0.5)
  speciale_action(2,24,true,0.5)
  speciale_action(2,26,true,0.5)  
  okay()
  StartTimer(45631,0.7,"swapping")      
  miniCreate()
end;

function checkMini()
  for i=1,12 do
    if state[i] ~= i + 20 then
      return
    end
  end
  finish_mini_game(true)
end