function Timer(ncount, Param1)
	if not StopSheet then
		AlfingSheet();
		StopSheet=false;
	return;end;
return;end;

function SheetSwitched (ncount)
	StopSheet=true;
return;end;

function SelectRandom()
	if flags.loc3 then
		selectrandomobject(1.5,39);
	return;end;
    idObject=GetRandomObject();	
	if idObject==111 and (not flags.minicomplete3) then
		if GetActivCount()>1 then
			flags.HintCount=flags.HintCount+1;
			SelectRandom()		
		return;end;			
		selectrandomobject(1.5,22);
	return;end	
	selectrandomobject(1.5,idObject);
end;

function SelectRandomRadar(idObject)

	if idObject==111 and (not flags.minicomplete3) then
		
		selectrandomobject(1.5,22);
	return;end	
	selectrandomobject(1.5,idObject);
end;


function MessageFromMenu(nCount,Param1)
if Param1==2000029 then
	ScrollLeft();
return;end;
if Param1==2000030 then
	ScrollRight();
return;end;
showoptons(0);
return;end;

function gameinput (sender,obj_id,attachedID)
	if sender == 2 then
		MessageProc(sender,obj_id);
	return;end;
	if sender==12 or sender==26 then
		if flags.loc3 then
		if not flags.whole_darkness then
		if not flags.allobject3 then
		    flags.allobject3=true;
			if flags.loc1 and flags.loc2 and flags.loc3 then
				flags.levelcomplete=true;
				DarkScreen(true);
				ShowMenu(false);
			return; end;	
			CreateWindow(100,100,"199");
		return;end;	
		return;end;	
		return;end;
	return;end;

	if sender==16 then
		if obj_id==503 or obj_id==500 then
		   BlockCursor(false);
		return;end;
		if obj_id==501 then
		   if flags.levelcomplete then		        
				speciale_action(2,500,true,2);
				speciale_action(4,500);
				BlockCursor(true);
			return;end;
			BlockCursor(false);
		return;end;
		if obj_id==3 then
			CreateWindow(100,100,"197");
			BlockCursor(false);
		return;end;								
	return;end;
	
	if sender==15 then
		if obj_id==501 then
			BlockCursor(false);
			flags.whole_darkness=false;
			if flags.loc3 then
			if not flags.allobject3 then
				flags.allobject3=true;
				if flags.loc1 and flags.loc2 and flags.loc3 then
					flags.levelcomplete=true;
					DarkScreen(true);
					ShowMenu(false);
				return; end;	
				CreateWindow(100,100,"199");
			return;end;	
			return;end;			
		return;end;		
		if obj_id==503 then
			ShowMenu(true);
			BlockCursor(false);
			AddParticleToObject(13,"Gant",0,0);
			StartEmiter("Gant");
			MoveEmiter("Gant",801,553);	
			savegame(SaveLevel())
		return;end;
	return;end;		
	if pause_state then
		if sender==1 or sender==6 or sender==14 then
			pause_state=false;
			set_visible_object(11111,false);
		end;	
	return;end;	
	if sender == 1 then --кликнули левой кнопкой мыши на активный объект
		
	if attachedID==-1 then	

		if obj_id==101 then
			StartAnimation(101,0,6)
		return;end;

		if obj_id==103 then
		   StartAnimation(103,0,7)
		return;end;		
		if obj_id==501 then
			if flags.levelcomplete then
				delete_tree_leaf("Root","garage");
				delete_tree_leaf("Root","killer");
				delete_tree_leaf("Root","gym");
				delete_tree_leaf("Root","mini1");
				delete_tree_leaf("Root","mini2");
				delete_tree_leaf("Root","mini3");
				delete_tree_leaf("Root","mini");
				setnextlavel(15);
				loadlavel();	
				ShowMenu(false);
			return;end;	
			DarkScreen(false);
			speciale_action(2,503,true);
		return;end;			

		if obj_id==39 then
				setcurentleaf("killer",14,1);
				savegame(SaveLevel())
				SwitchToSheet("re");
			return; end;	
			
			if obj_id==13 then  --стол
			if not flags.minicomplete3 then 
				DarkScreen(true);
				playeffect("mini");
				add_free_leaf("Root","mini3",14,14);
				dofile("./data/14/14/res.lua");
				set_satelite_leaf("gym");
				dofile("data\\14\\14\\level.lua");
				mini_create();	
				for i=1001,1021,1 do
					speciale_action(2,i,true)
				end;
			return; end;		
			return;end;	
			
			if obj_id==111 then 
				collaps_obj(obj_id,0,0,10,1);
				playeffect("collaps");
				AddElement("gr",obj_id);
				SetAlfaSheet(2.5)
				setcolor(obj_id,0,0,0,0.5,1);
				MoveObjectToTree(obj_id); 
			return; end;
			
			if obj_id >= 0 and obj_id < 101 then --кликаем на активный объект
				playeffect("collaps");
		        collaps_obj(obj_id,0,0,10,1);
	        return 0; end
	return; end;			
	return; end;
	
	if sender==14 then
	StopSheet=true;
		if obj_id>0 then
			addObjectToMouse(obj_id);
		return; end;
	return; end;
	
	if sender==4 then
	if SLevel==1.0 then return;end;
		flags.loc3 = true;
	return; end;	
end
