local fFirstClick=true;
skip = false;

function SkipActions()

	SkipMini();
	finish_mini_game(true);
	playeffect("miniok")
    flags.expert = true;
	flags.help_zakluch = true;
	skip=false
	HideHelp()
	set_text(2002,"1012")
		for i=1050,1065,1 do
	 --   Set_Anim_Cur(i,4)
	 setcolor(i,1,1,1,1)
	end;	
	speciale_action(2,10011)
	Block_Show_Cur(true);
    StartTimer(8881,2);
end;

function mini_create ()
    show_help_wnd=true;
    init_mini(true);
    mini_puzzle=true
    create_mini(19,16,20,85,98,357,564,1050,3,8,0,-1,false);
    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,51,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
    StartTimer(88811,0.3);
  return; end;
  
  if sender == 36 then    
    if id == 88811 then
      Block_Show_Cur(false);
      CreatePlashechka(900000,"51")
    return; end;
    if id == 8881 then
      Block_Show_Cur(false);
      mini_have_to_close=true;     
    return; end;
  return; end;
  
  if sender == 30 then   
  objectid = 0;
  mini_puzzle=false
      DeleteResource("border_2_12");
      DeleteResource("fon1_2_12"  );     
      DeleteResource("klochki"    );  
    setcurentleaf("laborator",2,0);    
    if  flags.expert then
    CreatePlashechka(900000,"3042")
    Block_Show_Cur(false);    
    IfTableClose()
    speciale_action(2,19)
    AddParticleToObject(19,"p5",184,216);
    MoveEmiter("p5",184,216);
    StartEmiter("p5");  
end;    
  return; end;
  
  if sender==37 then
    skip = true;
  return;end;
  
  if sender == 10 then   
--messagebox("sfsdf")  
    playeffect("miniok")
    flags.expert = true;
    flags.help_zakluch = true;
    skip=false
    HideHelp()
    set_text(2002,"1012")
    speciale_action(2,10011)
    Block_Show_Cur(true);
    StartTimer(8881,2);
  return; end;
 
  if sender == 1 then   
        if attachedID ~= -1 then
        RemObjFromMouse()
      end;  

--------------    
    if id >= 1050 and id <= 1065 then --нажимаем на часть
    if not flags.help_zakluch then
      if mousepresed then
      RemoveFromMouse(objectid);
      mousepresed=false
   EndMoving(objectid)
      end;
      add_to_mouse(id);
      mousepresed=true;
      objectid=id;
  BeginMoving(objectid)
    return; end   
      clear_satelite_leaf("laborator"); 
      finish_mini_game(true);
      UnStoreObj(obj.zakl.id);        
    return; end       
  return; end;      

  if sender == 5 then --Отпустили левую кнопку мышки    
    if flags.help_zakluch then
      DeleteResource("border_2_12");
      DeleteResource("ztm_2_12"   );
      DeleteResource("fon1_2_12"  );     
      DeleteResource("fon2_2_12"  );
      DeleteResource("klochki"    );
      clear_satelite_leaf("laborator"); 
      finish_mini_game(true);
      UnStoreObj(obj.zakl.id);    
    return;end;
   return;end;
	if sender == 6 then --Отпустили левую кнопку мышки    
    if mousepresed==true then
      playeffect("paper")
      RemoveFromMouse(objectid);
	  EndMoving(objectid)
      if check_mini_game_puzzle(objectid) then
        Set_Anim_Cur(objectid,3)
      end;
      mousepresed=false;
      objectid=0;
    end
  return; end;
end;

function MessageFromMinigame()
end;

function mini_delete ()

end;
function SheetSwitched(nCount)
end;