local fFirstClick=true;
skip = false;

function SkipActions()
    for i=1006,1012,1 do
        SetObjectPosition(i,symbXreal[i],symbYreal[i])
    end;
    flags.help_stol_pismo = true;
    flags.mini_pismo = true;    
    finish_mini_game(true);
end;

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,220,200,200)
   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
     neighbors.comics5.lock=false;  
    LoadLocation("comics5");
    StartTimer(88811,0.1);
  return; end;
  
  if sender == 36 then

    if id == 88811 then
      Block_Show_Cur(false);
      CreatePlashechka(900000,"220")
    return; end;


    if id == 8881 then    
      AddGlobalFade(7778778,0)
      SetAlfa(7778778,0,1,0.5)    
      StartTimer(88888,1)

    return; end;
    if id==88888 then
      Block_Show_Cur(false);
      clear_satelite_leaf("laborator"); 
      UnStoreObj(obj.med.id);    
    return;end;
  return; end;
  
  if sender == 30 then 
  objectid = 0;
      DeleteResource("harugma");
      DeleteResource("border1");
      DeleteResource("parts");
      DeleteResource("fon1"   );         
      DeleteResource("minicomplete");      
        setcurentleaf("laborator",2,0);    
        Block_Show_Cur(false);    
    --    set_visible_object(400000,true)
    if flags.mini_pismo then
            Set_Anim_Cur(11,3);
            flags.lab=true
            tocomics2=true
      nexttutorial=false
            WaitRender()
    return; end;
    -- if obj.med~=nil then
        -- set_visible_object(obj.med.id,true)
    -- end;
  return; end;
  
  if sender==37 then
    skip = true;
  return;end;
  
  if sender == 10 then    
    playeffect("miniok")
    HideSkip()
    HideHelp()
    speciale_action(4,1005);
    speciale_action(2,1005,true);
    flags.help_stol_pismo = true;
    flags.mini_pismo = true;
    skip=false
    Block_Show_Cur(true)
    
    StartTimer(8881,2);    
  return; end;
 
  if sender == 1 then 
       if attachedID ~= -1 then
        RemObjFromMouse()
      end; 
    if id > 1005 and id < 1013 and not flags.mini_pismo then
      if not symbonplace[id] and objectid==0 then
          add_to_mouse(id);
          mousepresed=true;
          objectid=id;
      end;
    return; end;
  return; end; 
 
    if sender==8129 then
        if objectid~=0 then
             RemoveFromMouse(objectid);
             playeffect("probirka");         
            if id>=(symbXreal[objectid]-luft) 
            and id<=(symbXreal[objectid]+symbwidth[objectid]+luft)
            and attachedID>=(symbYreal[objectid]-luft)
            and attachedID<=(symbYreal[objectid]+symbheight[objectid]+luft) 
            and currlayer==symblayer[objectid]
            then
                setcolor(objectid,0.8,0.8,0.8,1);
                symbonplace[objectid]=true
             --   Set_Anim_Cur(objectid,3)
                SetObjectPosition(objectid,symbXreal[objectid],symbYreal[objectid])
                el_count=el_count+1
            else
                SetObjectPosition(objectid,symbXpict[objectid],symbYpict[objectid])
            end;
            objectid=0
            if el_count==3 then
                currlayer=2
            end;
            if el_count==5 then
                currlayer=3
            end;   
            if el_count==6 then
                currlayer=4
            end;        
            err_game=false            
            for i=1006,1012,1 do
               if not symbonplace[i] then
                    err_game=true
               end;
            end;
            if not err_game then
                finish_mini_game(true)
            end;
        end;
    end;
 
end;

function mini_delete ()

end;
function SheetSwitched(nCount)
end;