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

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

function IvySound()
	playeffect("leaf");
return;end;

function SelectRandom()
	if flags.all then
		if not flags.minicomplete1 then
		if not flags.brush then
		    selectrandomobject(1.5,40);
		return;end;
		if not flags.powder then
			selectrandomobject(1.5,43);	
		return;end;			
			selectrandomobject(1.5,44);
		return;end;
	return;end;
    idObject=GetRandomObject();
	if idObject==46  and  (not flags.minicomplete) then
		if GetActivCount()>1 then
			flags.HintCount=flags.HintCount+1;
			SelectRandom()		
		return;end;			
		if not flags.filament then
		    selectrandomobject(1.5,36);
		return;end;
		if not flags.needle then
			selectrandomobject(1.5,33);	
		return;end;		
			selectrandomobject(1.5,9);	
	return;end;			
	selectrandomobject(1.5,idObject);
end;

function SelectRandomRadar(idObject)

	if idObject==46  and  (not flags.minicomplete) then			
		if not flags.filament then
		    selectrandomobject(1.5,36);
		return;end;
		if not flags.needle then
			selectrandomobject(1.5,33);	
		return;end;		
			selectrandomobject(1.5,9);	
	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.levelcomplete then
		    DarkScreen(true);
			ShowMenu(false);
		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,"198");
			BlockCursor(false);
		return;end;					
	return;end;
	
	if sender==15 then
		if obj_id==501 then
			BlockCursor(false);
			flags.whole_darkness=false;
			if flags.minitext1 then
				CreateWindow(100,100,"203");
				flags.minitext1=false
				savegame(SaveLevel())
			return;end;
		   if flags.levelcomplete then
				DarkScreen(true);
			return;end;			
		return;end;		
		if obj_id==503 then
			ShowMenu(true);
			BlockCursor(false);
			AddParticleToObject(9,"Panno",0,0);
			AddParticleToObject(44,"Diary",0,0);
			AddParticleToObject(46,"Paper",0,0);	
			MoveEmiter("Panno",936,249);
			MoveEmiter("Diary",925,474);
			MoveEmiter("Paper",469,451);
			StartEmiter("Panno")
			StartEmiter("Diary")
			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==9 then
			if attachedID==-1 or attachedID==33 or attachedID==36 then	
			
				if not flags.minicomplete then
					if flags.filament and flags.needle then
						RemoveFromMouse(attachedID);	
						DeleteElement("gr",33);
						DeleteElement("gr",36);						
						playeffect("mini");
						DarkScreen(true);
						add_free_leaf("Root","mini",9,11);
						dofile("./data/9/11/res.lua");
						set_satelite_leaf("stefani");
						dofile("data\\9\\11\\level.lua");
						mini_create();
						speciale_action(2,1033,true);
						for i=1001,1031,1 do
							speciale_action(2,i,true);
						end;
					return; end;
					CreateWindow(100,100,"201");
				return; end;
			return; end;	
			return; end;			

			if obj_id==44 then
			if attachedID==-1 or attachedID==40 or attachedID==43  then	
				
				if not flags.minicomplete1 then
					if flags.powder and flags.brush then
						RemoveFromMouse(attachedID);
						DarkScreen(true);
						DeleteElement("gr",40);
						DeleteElement("gr",43);
						playeffect("mini");
						add_free_leaf("Root","mini1",9,12);
						dofile("./data/9/12/res.lua");
						set_satelite_leaf("stefani");
						dofile("data\\9\\12\\level.lua");
						mini_create();
						speciale_action(2,1001,true);
						speciale_action(2,1009,true);
						speciale_action(2,1015,true);
						speciale_action(2,1011,true);
						speciale_action(2,1014,true);
						speciale_action(2,1012,true);
						speciale_action(2,1013,true);
					return; end;
					CreateWindow(100,100,"201");
				return; end;
			return; end;	
			return; end;	
			
		if attachedID==-1 then		

		if obj_id==501 then
			if flags.levelcomplete then
				delete_tree_leaf("Root","stefani");
				delete_tree_leaf("Root","mini1");
				delete_tree_leaf("Root","mini");
				setnextlavel(10);
				loadlavel();
			return;end;	
			DarkScreen(false);
			speciale_action(2,503,true);
		return;end;	
			
			if obj_id==39 then
				collaps_obj(obj_id,0,0,10,1);
				playeffect("collaps");
				setcolor(obj_id,0,0,0,0.5,1);
				CreateWindow(100,100,"202");
			return; end;

			if obj_id==43 then 
			    flags.powder=true;
				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==40 then 
				flags.brush=true;
				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==33 then 
				collaps_obj(obj_id,0,0,10,1);
				playeffect("collaps");
				flags.needle=true;
				AddElement("gr",obj_id);
				SetAlfaSheet(2.5)
				setcolor(obj_id,0,0,0,0.5,1);
				MoveObjectToTree(obj_id); 
			return; end;				
			
			if obj_id==36 then 
				collaps_obj(obj_id,0,0,10,1);
				playeffect("collaps");
				flags.filament=true;
				AddElement("gr",obj_id);
				SetAlfaSheet(2.5)
				setcolor(obj_id,0,0,0,0.5,1);
				MoveObjectToTree(obj_id); 
			return; end;

			if obj_id==46 then 
				collaps_obj(obj_id,0,0,10,1);
				playeffect("collaps");
				setcolor(obj_id,0,0,0,0.5,1);
				CreateWindow(100,100,"204");
				flags.paper=true;
				StopEmiter("Paper");
			return; end;
			
			if obj_id > 0 and obj_id < 57 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
	    flags.all=true;
	    if flags.minicomplete1 then
			flags.levelcomplete=true;
			
		return; end;		
	return; end;		
end
