soundAndMusicScreen_curSel = 1

function soundAndMusicScreen_onLeftPressed()
	if soundAndMusicScreen_curSel == 1 then
		soundAndMusicScreen_soundVol = soundAndMusicScreen_soundVol - 1
		if soundAndMusicScreen_soundVol == -1 then 
			soundAndMusicScreen_soundVol = 0
		end
		cfunction("callCPPFunction", "setSoundVolume", "", soundAndMusicScreen_soundVol*11.1)
		cfunction("startSoundSample", "soundVolumeTest", 1, 100)
	else
		soundAndMusicScreen_musicVol = soundAndMusicScreen_musicVol - 1
		if soundAndMusicScreen_musicVol == -1 then 
			soundAndMusicScreen_musicVol = 0
		end			
		cfunction("callCPPFunction", "setMusicVolume", "", soundAndMusicScreen_musicVol*11.1)
		cfunction("startSoundSample", "soundVolumeTest", 1, 100)
	end		
	soundAndMusicScreen_setSoundBlocks()	
end

function soundAndMusicScreen_onRightPressed()
	if soundAndMusicScreen_curSel == 1 then
		soundAndMusicScreen_soundVol = soundAndMusicScreen_soundVol + 1
		if soundAndMusicScreen_soundVol == 10 then 
			soundAndMusicScreen_soundVol = 9
		end			
		cfunction("callCPPFunction", "setSoundVolume", "", soundAndMusicScreen_soundVol*11.1)
		cfunction("startSoundSample", "soundVolumeTest", 1, 100)
	else
		soundAndMusicScreen_musicVol = soundAndMusicScreen_musicVol + 1
		if soundAndMusicScreen_musicVol == 10 then 
			soundAndMusicScreen_musicVol = 9
		end
		cfunction("callCPPFunction", "setMusicVolume", "", soundAndMusicScreen_musicVol*11.1)
		cfunction("startSoundSample", "soundVolumeTest", 1, 100)
	end	
	soundAndMusicScreen_setSoundBlocks()	
end

function soundAndMusicScreen_setSoundBlocks()
	soundAndMusicScreen_soundVol = soundAndMusicScreen_soundVol+0
	soundAndMusicScreen_musicVol = soundAndMusicScreen_musicVol+0
	cfunction("showBitmapOverlay", "musicBlock1", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock2", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock3", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock4", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock5", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock6", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock7", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock8", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock9", 0, 100, 300,135)
	
	cfunction("showBitmapOverlay", "soundBlock1", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock2", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock3", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock4", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock5", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock6", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock7", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock8", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock9", 0, 100, 300,135)
	
	xPos = 290
	yPos = 110
	
	if soundAndMusicScreen_soundVol == 9 then
		cfunction("showBitmapOverlay", "soundBlock9", 1, 100, xPos,yPos)
		
	elseif soundAndMusicScreen_soundVol == 8 then	
		cfunction("showBitmapOverlay", "soundBlock8", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_soundVol == 7 then
		cfunction("showBitmapOverlay", "soundBlock7", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_soundVol == 6 then
		cfunction("showBitmapOverlay", "soundBlock6", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_soundVol == 5  then
		cfunction("showBitmapOverlay", "soundBlock5", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_soundVol == 4 then
		cfunction("showBitmapOverlay", "soundBlock4", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_soundVol == 3 then
		cfunction("showBitmapOverlay", "soundBlock3", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_soundVol == 2 then
		cfunction("showBitmapOverlay", "soundBlock2", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_soundVol == 1 then
		cfunction("showBitmapOverlay", "soundBlock1", 1, 100, xPos,yPos)
	end
	
	
	yPos = 135
	if soundAndMusicScreen_musicVol == 9 then
		cfunction("showBitmapOverlay", "musicBlock9", 1, 100, xPos,yPos)		
	elseif soundAndMusicScreen_musicVol == 8 then	
		cfunction("showBitmapOverlay", "musicBlock8", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_musicVol == 7 then
		cfunction("showBitmapOverlay", "musicBlock7", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_musicVol == 6 then
		cfunction("showBitmapOverlay", "musicBlock6", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_musicVol == 5  then
		cfunction("showBitmapOverlay", "musicBlock5", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_musicVol == 4 then
		cfunction("showBitmapOverlay", "musicBlock4", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_musicVol == 3 then
		cfunction("showBitmapOverlay", "musicBlock3", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_musicVol == 2 then
		cfunction("showBitmapOverlay", "musicBlock2", 1, 100, xPos,yPos)
	elseif soundAndMusicScreen_musicVol == 1 then
		cfunction("showBitmapOverlay", "musicBlock1", 1, 100, xPos,yPos)
	end	
end

function soundAndMusicScreen_onDownPressed()	
	if soundAndMusicScreen_curSel == 1 then
		soundAndMusicScreen_curSel = 2
		cfunction("setFontOverlayText", "menu_content", '\04'.."    "..lng_SOUND.."\n\n*  "..lng_MUSIC)
	else
		soundAndMusicScreen_curSel = 1
		cfunction("setFontOverlayText", "menu_content", '\04'.."*  "..lng_SOUND.."\n\n    "..lng_MUSIC)		
	end
	cfunction("startSoundSample", "move_sfx", 1, 100)		
end

function soundAndMusicScreen_onUpPressed()	
	if soundAndMusicScreen_curSel == 1 then
		soundAndMusicScreen_curSel = 2		
		cfunction("setFontOverlayText", "menu_content", '\04'.."    "..lng_SOUND.."\n\n*  "..lng_MUSIC)
	else
		soundAndMusicScreen_curSel = 1		
		cfunction("setFontOverlayText", "menu_content", '\04'.."*  "..lng_SOUND.."\n\n    "..lng_MUSIC)
	end
	cfunction("startSoundSample", "move_sfx", 1, 100)		
end

function soundAndMusicScreen_onCancelPressed()			
	soundAndMusicScreen_onSubmitPressed()	
end

function soundAndMusicScreen_afterWindowClose()
	cfunction("transitionToState", "pauseState")
end

function soundAndMusicScreen_onSubmitPressed()			
	cfunction("showFontOverlay", "menu_content", 0, 100, 100, 112)
	cfunction("showBitmapOverlay", "musicBlock1", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock2", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock3", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock4", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock5", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock6", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock7", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock8", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "musicBlock9", 0, 100, 300,135)

	cfunction("showBitmapOverlay", "soundBlock1", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock2", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock3", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock4", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock5", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock6", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock7", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock8", 0, 100, 300,135)
	cfunction("showBitmapOverlay", "soundBlock9", 0, 100, 300,135)

	cfunction("startSoundSample", "back_sfx", 1, 100)
		
	closePopupWindow("soundAndMusicScreen_afterWindowClose")	
		
end

function soundAndMusicScreen_onEnterState()	
	soundAndMusicScreen_curSel = 1
	openPopupWindow("soundAndMusicScreen_afterWindowOpen", 1.1)	
end

function soundAndMusicScreen_afterWindowOpen()	
	cfunction("showFontOverlay", "menu_content", 1, 100, 100, 112)
	cfunction("setFontOverlayText", "menu_content", '\04'.."*  "..lng_SOUND.."\n\n    "..lng_MUSIC)	
	soundAndMusicScreen_setSoundBlocks()
end

function soundAndMusicScreen_onLeaveState()				
end
