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.lamp then
		selectrandomobject(1.5,87);
	return;end;
	    selectrandomobject(1.5,90);
end;

function SelectRandomRadar(idObject)
	 selectrandomobject(1.5,90);	
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.loc4 then
		if not flags.whole_darkness then
		if not flags.allobject4 then
		    flags.allobject4=true;
			if flags.loc1 and flags.loc2 and flags.loc3 and flags.loc4 and flags.loc5 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==1 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.loc4 then
			if not flags.allobject4 then
				flags.allobject4=true;
				if flags.loc1 and flags.loc2 and flags.loc3 and flags.loc4 and flags.loc5 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
		   BlockCursor(false);
		   ShowMenu(true);
				AddParticleToObject(90,"Mirror",0,0);
				StartEmiter("Mirror");
				MoveEmiter("Mirror",295,155);
	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 obj_id==90 then
		if not flags.lamp then
		if not flags.light then
			if attachedID==257 then
				playeffect("attach");
				RemoveFromMouse(attachedID);
				DeleteElement("gr",attachedID);
				collaps_obj(104,0,0,10,1);
				AddElement("gr",104);
				SetAlfaSheet(2.5)
				setcolor(104,0,0,0,0.5,1);
				MoveObjectToTree(104); 
				StopEmiter("Mirror")
				speciale_action(2,58,true);
				speciale_action(2,57);
				speciale_action(2,90,true);
				speciale_action(2,89);
				Set_Cursor(90,3);
				CreateWindow(100,100,"223")
				flags.lamp=true;
			return; end;
			if attachedID~=257 and attachedID>-1 then
				CreateWindow(100,100,"200");     
			return; end;
			if attachedID ==-1 then		
				CreateWindow(100,100,"217");  
			return; end;
		return;end;
		return;end;
		return;end;

	if attachedID==-1 then	
		
			if obj_id==401 then
				StartAnimation(401);
			return;end;
	
	
			if obj_id==501 then
				if flags.levelcomplete then
					delete_tree_leaf("Root","kab_direktor");
					delete_tree_leaf("Root","azart_room");
					delete_tree_leaf("Root","private_room");
					delete_tree_leaf("Root","grimerka");
					delete_tree_leaf("Root","kulisi");
					delete_tree_leaf("Root","mini1");
					delete_tree_leaf("Root","mini2");
					delete_tree_leaf("Root","mini3");
					delete_tree_leaf("Root","mini");
					delete_tree_leaf("Root","mini4");
					delete_tree_leaf("Root","mini5");
					delete_tree_leaf("Root","mini6");		
					delete_tree_leaf("Root","mini7");
					setnextlavel(4);
					loadlavel();
				return;end;	
				DarkScreen(false);
				speciale_action(2,503,true);
			return;end;
			
			if obj_id==87 then	
				setcurentleaf("kulisi",3,4);
				savegame(SaveLevel())
				SwitchToSheet("re");
			return; end;
		
			if obj_id >= 0 and obj_id < 400 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.loc4 = true;
	return; end;		
end
