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.loc5 then
		if not flags.loc4 then
			selectrandomobject(1.5,67);
		return;end;	
		selectrandomobject(1.5,66);
	return;end;
    idObject=GetRandomObject();
	selectrandomobject(1.5,idObject);
end;
function SelectRandomRadar(idObject)
	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.loc5 then
		if not flags.whole_darkness then
		if not flags.allobject5 then
		    flags.allobject5=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==35 then
		if obj_id==403 then
			StartAnimation(103,0,6)
		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==7 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.loc5 then
			if not flags.allobject5 then
				flags.allobject5=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);
		   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==401 then
		    playeffect("spring");
			StartAnimation(401,0,9)
		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==67 then
				if flags.firstloc4==true then
					BlockCursor(true)
					setcurentleaf("grimerka",3,3);
					
					SwitchToSheet("re");
					flags.firstloc4 = false;
					DarkScreen(true);
					speciale_action(2,503,true,3);
					speciale_action(4,503)
				return; end;	
				setcurentleaf("grimerka",3,3);
				savegame(SaveLevel())
				SwitchToSheet("re");
			return; end;

			if obj_id==66 then
				setcurentleaf("private_room",3,2);
				savegame(SaveLevel())
				SwitchToSheet("re");
				if flags.lamp then
					CreateWindow(100,100,"223")
				end;
			return; end;
			
			if obj_id==257 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==191 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); 
				flags.dies=true;
			return; end;			

			if obj_id > 0 and obj_id < 300 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.loc5 = true;
	return; end;		
end
