local currentNotesIndex = nil;

--------------------------------------------------------------------------------
function ShowMusicNotesScreen(notesIndex)

	currentNotesIndex = notesIndex;

    local guiControlsZOffset = 20;
	local scrollZOffset = 200;

	local screen = CreateScreen();
	screen:SetName('MusicNotesScreen');
	screen:SetLayer(POPUP_WINDOWS_LAYER + scrollZOffset);

	local bg = screen:CreateAnimation('data/Texture/Scenes/Common/fade.png');
	bg:SetHotSpot(512.0/2.0, 384.0/2.0);
	bg:SetPosXY(512, 384);
	bg:SetPosZ(-1);
	bg:SetScale(2.0);
	bg:SetOpacity(0.75);

	local bg = screen:CreateAnimation('data/Texture/GUI/Extras/PageMusic/notesScreenBack'..tostring(notesIndex)..'.png');
	bg:SetHotSpot(765.0/2.0, 664.0/2.0);
	bg:SetPosXY(512, 384);
	bg:SetPosZ(0);

	do
		local button = MakeButton(660, 535, 200, 90);
		button:DisableIfHidden(true);
   	    button:GetCaption():SetFont(BUTTONS_FONT);
   		button:GetCaption():SetScale(0.8);
   		button:SetZ(guiControlsZOffset + 10);

   		button:AttachTo(screen);
   		button:SetAction('OnSaveNotes');
   		button:SetSpriteUp('ButtonSaveNotes');
  		button:SetSpriteOver('ButtonSaveNotesOver');
   		button:SetSpriteDown('ButtonSaveNotesDown');
   		button:SetActionSound('Menu_button_click');
	end
   	do
   	    local CloseButton = MakeButton(1024.0/2.0, 768.0/2.0, 1024, 768);
		CloseButton:DisableIfHidden(true);
   	    CloseButton:GetCaption():SetFont(BUTTONS_FONT);
   		CloseButton:GetCaption():SetScale(0.8);
   		CloseButton:SetZ(guiControlsZOffset);

   		CloseButton:AttachTo(screen);
   		CloseButton:SetAction('PopCurrentPopUpScreen');
   		CloseButton:SetActionSound('Menu_button_click');
   	end

    PopUpScreensMgr:Push(screen, false);
end

function OnSaveNotes()
	assert(currentNotesIndex);

	local notesSource = {
		{'data/Texture/GUI/Extras/PageMusic/Notes/track_01_notes.mid',
		 'data/Texture/GUI/Extras/PageMusic/Notes/track_01_notes_page1.jpg',
		 'data/Texture/GUI/Extras/PageMusic/Notes/track_01_notes_page2.jpg'},

		{'data/Texture/GUI/Extras/PageMusic/Notes/track_02_notes.mid',
		 'data/Texture/GUI/Extras/PageMusic/Notes/track_02_notes.jpg'},

		{'data/Texture/GUI/Extras/PageMusic/Notes/track_03_notes.mid',
		 'data/Texture/GUI/Extras/PageMusic/Notes/track_03_notes.jpg'}
	};
	local notesDestination = {
		{'Edgar Allan Poe - '..GetString('EXTRACONTENT_SCR_1ST_TACK_NAME')..'_Notes.mid',
		 'Edgar Allan Poe - '..GetString('EXTRACONTENT_SCR_1ST_TACK_NAME')..'_Notes_Page1.jpg',
		 'Edgar Allan Poe - '..GetString('EXTRACONTENT_SCR_1ST_TACK_NAME')..'_Notes_Page2.jpg'},

		{'Edgar Allan Poe - '..GetString('EXTRACONTENT_SCR_2ND_TACK_NAME')..'_Notes.mid',
		 'Edgar Allan Poe - '..GetString('EXTRACONTENT_SCR_2ND_TACK_NAME')..'_Notes.jpg'},

		{'Edgar Allan Poe - '..GetString('EXTRACONTENT_SCR_3RD_TACK_NAME')..'_Notes.mid',
		 'Edgar Allan Poe - '..GetString('EXTRACONTENT_SCR_3RD_TACK_NAME')..'_Notes.jpg'}
	};

	ShowResourceSavingConfirmationScreen('EXTRACONTENT_SOUNDTRACK_NOTES_SAVE_TEXT', 
										 notesSource[currentNotesIndex],
										 notesDestination[currentNotesIndex]);
end
