--------------------------------------------------------------------------------
function PreloadSounds()
    LoadMusic("menu_music",         "data/Music/menu_music")
    
    LoadMusic("music_2",            "data/Music/music_2")
    LoadMusic("music_3",            "data/Music/music_3")
    LoadMusic("music_4",            "data/Music/music_4")

    LoadSound("internoise_sea",     "data/Sound/internoise_sea")
    LoadSound("wrong_click",        "data/Sound/wrong_click")
    LoadSound("button_press",       "data/Sound/button_press")
    LoadSound("button_menu_over",   "data/Sound/button_menu_over")
    LoadSound("opening_window",     "data/Sound/opening_window")
    LoadSound("item_found",         "data/Sound/item_found")
    LoadSound("wrong_click",        "data/Sound/wrong_click")
    LoadSound("photo",              "data/Sound/photo")
    LoadSound("sms_open",           "data/Sound/sms_open")
    LoadSound("mouse_punish",       "data/Sound/mouse_punish")
    LoadSound("hint",               "data/Sound/hint")
    LoadSound("success_mini_game",  "data/Sound/success_mini_game")
    
    LoadSound("01_move_box",        "data/Sound/01_move_box")
    LoadSound("01_move_bag",        "data/Sound/01_move_bag")
    LoadSound("01_call_phone",      "data/Sound/01_call_phone")
    LoadSound("01_tv_set_work",     "data/Sound/01_tv_set_work")
    
    LoadSound("01_mg_card_rotate",  "data/Sound/01_mg_card_rotate")
    LoadSound("01_mg_card_wrong",   "data/Sound/01_mg_card_wrong")
    
    LoadSound("02_catch_bottle",    "data/Sound/02_catch_bottle")
    LoadSound("02_open_bottle",     "data/Sound/02_open_bottle")
    
    LoadSound("03_move_cushion",    "data/Sound/03_move_cushion")
    LoadSound("03_cut_scissors",    "data/Sound/03_cut_scissors")
    LoadSound("03_boil_coffee",     "data/Sound/03_boil_coffee")
    LoadSound("03_input_changer_telefon", "data/Sound/03_input_changer_telefon")
    
    LoadSound("04_clear_sand",      "data/Sound/04_clear_sand")
    LoadSound("04_open_suitcase",   "data/Sound/04_open_suitcase")
    
    LoadSound("05_strike_lamp",     "data/Sound/05_strike_lamp")
    LoadSound("05_electric_light",  "data/Sound/05_electric_light")
    LoadSound("05_opening_door",    "data/Sound/05_opening_door")
    LoadSound("05_fall_oxygen_cylinder",    "data/Sound/05_fall_oxygen_cylinder")
    
    LoadSound("05_mg_gear_set",     "data/Sound/05_mg_gear_set")
    LoadSound("05_mg_gear_rotate",  "data/Sound/05_mg_gear_rotate")
    LoadSound("05_mg_open",         "data/Sound/05_mg_open")
    
    LoadSound("06_explosion_safe",  "data/Sound/06_explosion_safe")
    LoadSound("06_cast_dart",       "data/Sound/06_cast_dart")
    LoadSound("06_scare_lizard",    "data/Sound/06_scare_lizard")
    
    LoadSound("06_mg_move_1",       "data/Sound/06_mg_move_1");
    LoadSound("06_mg_move_2",       "data/Sound/06_mg_move_2");
    LoadSound("06_mg_move_3",       "data/Sound/06_mg_move_3");
    LoadSound("06_mg_open",         "data/Sound/06_mg_open");
    LoadSound("06_mg_weight_set",   "data/Sound/06_mg_weight_set");
    
    LoadSound("07_make_electricity","data/Sound/07_make_electricity")
    LoadSound("07_make_bucket",     "data/Sound/07_make_bucket")
    LoadSound("07_push_barrel",     "data/Sound/07_push_barrel")
    LoadSound("07_noise_bird",      "data/Sound/07_noise_bird")
    LoadSound("07_mg_move",         "data/Sound/07_mg_move")   
    
    LoadSound("08_pick_up_boat",    "data/Sound/08_pick_up_boat")
    
    LoadSound("09_collect_saw",     "data/Sound/09_collect_saw");
    LoadSound("09_fall_anvil",      "data/Sound/09_fall_anvil");
	
	LoadSound("10_propeller",   	"data/Sound/10_propeller");
    LoadSound("10_door", 			"data/Sound/10_door");
	
    LoadSound("11_insert_lever",    "data/Sound/11_insert_lever");
	LoadSound("11_use_lever",	    "data/Sound/11_use_lever");
	
    LoadSound("12_hack",		    "data/Sound/12_hack")	
    LoadSound("12_stair",		    "data/Sound/12_stair")
    
    LoadSound("13_fall_head",		"data/Sound/13_fall_head")
    LoadSound("13_open_door",		"data/Sound/13_open_door")
    
    LoadSound("14_send_away_snake",	"data/Sound/14_send_away_snake")
    LoadSound("14_open_door_in_box","data/Sound/14_open_door_in_box")
    
    LoadSound("15_clear_alga",	    "data/Sound/15_clear_alga")
    LoadSound("15_punch_out_boat",	"data/Sound/15_punch_out_boat")
    LoadSound("15_smash_helmet",	"data/Sound/15_smash_helmet")
    
    LoadSound("16_hang_up_hook",	"data/Sound/16_hang_up_hook")
    LoadSound("16_insert_lever",	"data/Sound/16_insert_lever")
    LoadSound("16_press_lever",	    "data/Sound/16_press_lever")
    LoadSound("16_use_sticky_tape",	"data/Sound/16_use_sticky_tape")
    
    LoadSound("17_on_start",	    "data/Sound/17_on_start")
    LoadSound("17_cut_rope",	    "data/Sound/17_cut_rope")
    
    LoadSound("18_use_spray",		"data/Sound/18_use_spray")
    LoadSound("18_open_box",		"data/Sound/18_open_box")
    LoadSound("18_set_up_ladder",	"data/Sound/18_set_up_ladder")
	
	LoadSound("19_after_bulb",		"data/Sound/19_after_bulb")
    LoadSound("19_bulb",			"data/Sound/19_bulb")
    LoadSound("19_minigame_complete", "data/Sound/19_minigame_complete")
	LoadSound("19_sun",				"data/Sound/19_sun")
	
	LoadSound("19_mg_wrong_click",  "data/Sound/19_mg_wrong_click")
	LoadSound("19_mg_click",        "data/Sound/19_mg_click")
	LoadSound("19_mg_circle_rotate","data/Sound/19_mg_circle_rotate")
	LoadSound("19_mg_highlight",    "data/Sound/19_mg_highlight" )
	LoadSound("19_fire",		    "data/Sound/19_fire" )
	
	LoadSound("20_cup", 			"data/Sound/20_cup")
	LoadSound("20_hammer", 			"data/Sound/20_hammer")
	
	LoadSound("21_open",			"data/Sound/21_open")
	
	LoadSound("22_catch_key",		"data/Sound/22_catch_key")
    LoadSound("22_open_door",		"data/Sound/22_open_door")
	LoadSound("22_use_handaxe",		"data/Sound/22_use_handaxe")
	LoadSound("22_mg_rotate",		"data/Sound/22_mg_rotate")
	
	LoadSound("23_noise_jungle_water","data/Sound/23_noise_jungle_water")
	LoadSound("23_fire",			"data/Sound/23_fire")
	LoadSound("23_insert_squares",	"data/Sound/23_insert_squares")	
	LoadSound("23_insert_torch",	"data/Sound/23_insert_torch")
	LoadSound("23_move_tooth",		"data/Sound/23_move_tooth")
	LoadSound("23_open_gate",		"data/Sound/23_open_gate")
	LoadSound("23_press_lions_head","data/Sound/23_press_lions_head")
	LoadSound("23_rotate_square",	"data/Sound/23_rotate_square")	
	
	LoadSound("24_gear", 			"data/Sound/24_gear")
	LoadSound("24_remove_bag", 		"data/Sound/24_remove_bag")
	LoadSound("24_remove_cartridges","data/Sound/24_remove_cartridges")
	LoadSound("24_remove_cover", 	"data/Sound/24_remove_cover")
	LoadSound("24_move_off_door", 	"data/Sound/24_move_off_door")
	LoadSound("24_mg_click_in_counter","data/Sound/24_mg_click_in_counter")
	LoadSound("24_mg_open",         "data/Sound/24_mg_open")
	
	LoadSound("25_drawer", 			"data/Sound/25_drawer")
	LoadSound("25_explosion", 		"data/Sound/25_explosion")
	LoadSound("25_medikit", 		"data/Sound/25_medikit")
	LoadSound("25_place_dynamite", 	"data/Sound/25_place_dynamite")
	LoadSound("25_remove_box_cover","data/Sound/25_remove_box_cover")
	
	LoadSound("27_pipe1",			"data/Sound/27_pipe_1")
	LoadSound("27_pipe2",			"data/Sound/27_pipe_2")
	LoadSound("27_pipe3",			"data/Sound/27_pipe_3")
	LoadSound("27_carriage",		"data/Sound/27_carriage")
	LoadSound("27_column",			"data/Sound/27_column")
	LoadSound("27_water",			"data/Sound/27_water")
	LoadSound("27_mg_pipe_rotate",	"data/Sound/27_mg_pipe_rotate")
	
	LoadSound("28_move_curtain",	"data/Sound/28_move_curtain")
	LoadSound("28_cut_sword",	    "data/Sound/28_cut_sword")
	LoadSound("28_open_chest",	    "data/Sound/28_open_chest")
	LoadSound("28_insert_artefact",	"data/Sound/28_insert_artefact")
	LoadSound("28_circle_rotate",   "data/Sound/28_circle_rotate")
	
	LoadSound("29_sarcophagus",		"data/Sound/29_sarcophagus")
	LoadSound("29_torch_back_left",	"data/Sound/29_torch_back_left")
	LoadSound("29_torch_back_right","data/Sound/29_torch_back_right")
	LoadSound("29_torch_front_left","data/Sound/29_torch_front_left")
	LoadSound("29_torch_front_right","data/Sound/29_torch_front_right")
	LoadSound("29_input_artefact",  "data/Sound/29_input_artefact")
	
	LoadSound("30_break_off_wall",  "data/Sound/30_break_off_wall")
	LoadSound("30_insert_wheel",    "data/Sound/30_insert_wheel")
	LoadSound("30_use_ram",         "data/Sound/30_use_ram")
	LoadSound("30_use_rope",        "data/Sound/30_use_rope")
	
	LoadSound("31_input_crystal",   "data/Sound/31_input_crystal")
	
	LoadSound("32_square",			"data/Sound/32_square")
	LoadSound("32_lever",			"data/Sound/32_lever")
	LoadSound("32_sarcophagus",		"data/Sound/32_sarcophagus")
	LoadSound("32_fountain",		"data/Sound/32_fountain")
	
	LoadSound("33_input_cristall",	"data/Sound/33_input_cristall")	
	LoadSound("33_put_all_cristall","data/Sound/33_put_all_cristall")
	LoadSound("33_open_door",       "data/Sound/33_open_door")
	
	LoadSound("34_cut_shield",      "data/Sound/34_cut_shield")
	LoadSound("34_mg_take_part",    "data/Sound/34_mg_take_part")
	LoadSound("34_mg_insert_part",  "data/Sound/34_mg_insert_part")
	
	LoadSound("35_noise_in_door",   "data/Sound/35_noise_in_door")
	LoadSound("35_pour_water",      "data/Sound/35_pour_water")
	LoadSound("35_input_artefact",  "data/Sound/35_input_artefact")
	LoadSound("35_use_hammer",      "data/Sound/35_use_hammer")
	LoadSound("35_use_pliers",      "data/Sound/35_use_pliers")
	
	LoadSound("36_move_portal",     "data/Sound/36_move_portal")
	LoadSound("36_run_portal",      "data/Sound/36_run_portal")
	LoadSound("36_suck_money_1",    "data/Sound/36_suck_money_1")
	LoadSound("36_suck_money_2",    "data/Sound/36_suck_money_2")
	LoadSound("36_mg_rotate",       "data/Sound/36_mg_rotate")
	LoadSound("36_mg_rotate_wrong", "data/Sound/36_mg_rotate_wrong")
	LoadSound("36_mg_move",         "data/Sound/36_mg_move")
end
--------------------------------------------------------------------------------
currentMusicTrack = nil;
previousMusicTrack = nil;
--------------------------------------------------------------------------------
function PlayAmbientMusic(musicTrack, fade)
    if currentMusicTrack ~= musicTrack then
        if currentMusicTrack then
            StopMusic(currentMusicTrack, fade or false)
        end
        
        currentMusicTrack = musicTrack
        
        if currentMusicTrack then
            PlayMusic(currentMusicTrack, fade or false)
        end
    end
end
--------------------------------------------------------------------------------
function StopCurrentMusicTrack(fade)
    StopMusic(currentMusicTrack, fade or false)
end
--------------------------------------------------------------------------------
function PlayRandomAmbientMusic()
    local i, level = GetCurLevelId(play_field:GetName())
    local name_track = SelectRandom('music_2', 'music_4')
    if  level == 5 or 
        level == 19 
    then
        name_track = 'music_3'
    end
    
    PlayAmbientMusic(name_track, true)
end
--------------------------------------------------------------------------------
function MakeSoundEntity(soundName)
    local result = CreateSoundEntity(soundName)
    result:AttachTo(play_field)
    return result
end
--------------------------------------------------------------------------------
