--alwaysOn_
alwaysOn_curPositionInRace =-1
alwaysOn_totalRacers = 1

alwaysOn_lastPositionInRace=0
alwaysOn_lastTotalRacers =0

alwaysOn_smOverlayData = {"SMOverlayGlide" ,"SMOverlayDragster", "SMOverlayScorch", "SMOverlayMammoth"}

alwaysOn_SMOverlay = 0
alwaysOn_OldSMOverlay = 0
alwaysOn_SMOverlayTimer = 0

alwaysOn_SMPulse1Value = 80
alwaysOn_SMPulse2Value = 75

alwaysOn_smImput = 0
alwaysOn_lastSmImput = -1

alwaysOn_weaponPosX = 434
alwaysOn_weaponPosY = { 24, 160 }

alwaysOn_weaponLockActive = 0
alwaysOn_wrongwayActive =0
alwaysOn_lowenergyActive =0

alwaysOn_curWeaponType = { 0, 0 }	--this one will be update from game
alwaysOn_lastWeaponType = { 0, 0 }
alwaysOn_addingWeapon = { 0, 0 }
alwaysOn_removingWeapon = { 0, 0 }
alwaysOn_removeWeaponName = { "", "" }

alwaysOn_weaponLockHitOn = 0

alwaysOn_CDlifesLost = 0
alwaysOn_CDblinkLifescounter = 0
alwaysOn_updateLifeOverlay = ""
alwaysOn_updateLifeOverlay_X = 199
alwaysOn_updateLifeOverlay_Y = 6

alwaysOn_font_hud_pos_enemy_X = 34
alwaysOn_font_hud_pos_enemy_Y = 39

alwaysOn_font_hud_pos_player_X = 26
alwaysOn_font_hud_pos_player_Y = 20

alwaysOn_font_hud_speed_X = 33
alwaysOn_font_hud_speed_Y = 256
alwaysOn_font_hud_speed2_Y = 120

alwaysOn_font_hud_time_X = 404
alwaysOn_font_hud_time_Y = 256

alwaysOn_smInputLeft_top_X = 1
alwaysOn_smInputLeft_top_Y = 149

alwaysOn_smInputLeft_bottom_X = 1
alwaysOn_smInputLeft_bottom_Y = 171

alwaysOn_smInputRight_top_X = 455
alwaysOn_smInputRight_top_Y = 149

alwaysOn_smInputRight_bottom_X = 455
alwaysOn_smInputRight_bottom_Y = 171

alwaysOn_weaponLock_frame_X = 176
alwaysOn_weaponLock_frame_Y = 2

alwaysOn_weaponLock_blockL_X = 232
alwaysOn_weaponLock_blockL_Y = 8
alwaysOn_weaponLock_blockR_X = 240
alwaysOn_weaponLock_blockR_Y = 8

alwaysOn_weaponLock_hit_X = 232 
alwaysOn_weaponLock_hit_Y = 4

function alwaysOn_updateHud()
	if alwaysOn_addingWeapon[1] == 0 and alwaysOn_removingWeapon[1] == 0 then	
		alwaysOn_curWeaponType[1] = alwaysOn_curWeaponType[1] +0	

		if alwaysOn_curWeaponType[1] == alwaysOn_lastWeaponType[1] then

		else
			if alwaysOn_curWeaponType[1] > 0 then
				alwaysOn_addWeapon(1)
			elseif alwaysOn_curWeaponType[1] == 0 then
				alwaysOn_removeWeapon(1)
			end			
		end
	end

	if alwaysOn_addingWeapon[2] == 0 and alwaysOn_removingWeapon[2] == 0 then	
		alwaysOn_curWeaponType[2] =alwaysOn_curWeaponType[2] +0	

		if alwaysOn_curWeaponType[2] == alwaysOn_lastWeaponType[2] then

		else
			if alwaysOn_curWeaponType[2] > 0 then
				alwaysOn_addWeapon(2)
			elseif alwaysOn_curWeaponType[2] == 0 then
				alwaysOn_removeWeapon(2)
			end			
		end
	end
	
	alwaysOn_curPositionInRace = alwaysOn_curPositionInRace+0
	alwaysOn_totalRacers = alwaysOn_totalRacers+0
	if alwaysOn_totalRacers == alwaysOn_lastTotalRacers then	
	else 
		cfunction("setFontOverlayText", "font_hud_pos_enemy", alwaysOn_totalRacers.."")
	end
	if alwaysOn_curPositionInRace == alwaysOn_lastPositionInRace then
	else 
		cfunction("setFontOverlayText", "font_hud_pos_player", alwaysOn_curPositionInRace.."")		
	end
	
	alwaysOn_lastSMState = alwaysOn_curSMState
	
	alwaysOn_lastPositionInRace = alwaysOn_curPositionInRace
	alwaysOn_lastTotalRacers = alwaysOn_totalRacers	
end

function alwaysOn_removeWeapon(player)
	bGoOn = 1
	if alwaysOn_lastWeaponType[player]  == 1 then
		alwaysOn_removeWeaponName[player] = "hud_weapons_grenade"..player
	elseif alwaysOn_lastWeaponType[player] == 2 then
		alwaysOn_removeWeaponName[player] = "hud_weapons_flashbomb"..player	
	elseif alwaysOn_lastWeaponType[player] == 3 then
		alwaysOn_removeWeaponName[player] = "hud_weapons_foammissile"..player	
	elseif alwaysOn_lastWeaponType[player] == 4 then
		alwaysOn_removeWeaponName[player] = "hud_weapons_emp"..player		
	else
		cfunction("debugPrintF", "alwaysOn_removeWeaponIcon:: Wrong lastWeapon", alwaysOn_lastWeaponType[player])
		bGoOn = 0
	end
	if bGoOn == 1 then
		alwaysOn_removingWeapon[player] = alwaysOn_lastWeaponType[player]
		
		cfunction("scaleBitmapOverlay", alwaysOn_removeWeaponName[player], 1,1,5,5,300)
		cfunction("setOverlayDestination", alwaysOn_removeWeaponName[player], alwaysOn_weaponPosX-36, alwaysOn_weaponPosY[player]-36, 300)		
		cfunction("setTimer", 150, "alwaysOn_removeWeaponStartFade" .. player)
	end
end

function alwaysOn_removeWeaponStartFade1() 
	cfunction("fadeOverlay", alwaysOn_removeWeaponName[1], 100,0,150)
	cfunction("setTimer", 150, "alwaysOn_removeWeaponDone1")
end

function alwaysOn_removeWeaponDone1()
	alwaysOn_lastWeaponType[1] = 0
	alwaysOn_removingWeapon[1] = 0
end

function alwaysOn_removeWeaponStartFade2() 
	cfunction("fadeOverlay", alwaysOn_removeWeaponName[2], 100,0,150)
	cfunction("setTimer", 150, "alwaysOn_removeWeaponDone2")
end

function alwaysOn_removeWeaponDone2()
	alwaysOn_lastWeaponType[2] = 0
	alwaysOn_removingWeapon[2] = 0
end

function alwaysOn_goFinish()
	if flow_gameMode == gameTypesIds["ARCADE"] then
		cfunction("transitionToState", "arcadeResult")
	elseif flow_gameMode == gameTypesIds["TOURNAMENT"] then
		cfunction("transitionToState", "tournamentResult")
	elseif flow_gameMode == gameTypesIds["MULTIPLAYER"] then
		cfunction("transitionToState", "multiplayerResult")
	elseif flow_gameMode == gameTypesIds["CHALLENGE"] then
		cfunction("transitionToState", "challengeResult")
	elseif flow_gameMode == gameTypesIds["TUTORIAL"] then
		cfunction("transitionToState", "tutorialResult")
	elseif flow_gameMode == gameTypesIds["TIMETRIAL"] then
		cfunction("transitionToState", "timetrialResult")
	else
		cfunction("debugPrintF", "Wrong flow_gameMode in alwaysOn", flow_gameMode)	
	end
end

function alwaysOn_addWeapon(player)
	bGoOn = 1
	if alwaysOn_curWeaponType[player]  == 1 then
		alwaysOn_addWeaponName = "hud_weapons_grenade"..player
	elseif alwaysOn_curWeaponType[player] == 2 then
		alwaysOn_addWeaponName = "hud_weapons_flashbomb"..player		
	elseif alwaysOn_curWeaponType[player] == 3 then
		alwaysOn_addWeaponName = "hud_weapons_foammissile"..player		
	elseif alwaysOn_curWeaponType[player] == 4 then
		alwaysOn_addWeaponName = "hud_weapons_emp"..player		
	else
		cfunction("debugPrintF", "alwaysOn_addWeaponIcon:: Wrong currentWeapon", alwaysOn_curWeaponType[player])
		bGoOn = 0
	end
	if bGoOn == 1 then
		cfunction("showBitmapOverlay", "hud_weapons_emp"..player, 0,60,176,200)		
		cfunction("showBitmapOverlay", "hud_weapons_grenade"..player, 0,60,176,200)		
		cfunction("showBitmapOverlay", "hud_weapons_flashbomb"..player, 0,60,176,200)		
		cfunction("showBitmapOverlay", "hud_weapons_foammissile"..player, 0,60,176,200)		

		alwaysOn_addingWeapon[player] = alwaysOn_curWeaponType[player]
		cfunction("showBitmapOverlay", alwaysOn_addWeaponName, 1,0,alwaysOn_weaponPosX-36,alwaysOn_weaponPosY[player]-36)	
		cfunction("fadeOverlay", alwaysOn_addWeaponName, 0,100,150)
		cfunction("scaleBitmapOverlay", alwaysOn_addWeaponName, 5,5,1,1,300)
		cfunction("setOverlayDestination", alwaysOn_addWeaponName, alwaysOn_weaponPosX, alwaysOn_weaponPosY[player], 300)		
		cfunction("setTimer", 300, "alwaysOn_addWeaponDone"..player)
	end
end

function alwaysOn_addWeaponDone1()
	alwaysOn_lastWeaponType[1] = alwaysOn_addingWeapon[1]
	alwaysOn_addingWeapon[1] =0
end
function alwaysOn_addWeaponDone2()
	alwaysOn_lastWeaponType[2] = alwaysOn_addingWeapon[2]
	alwaysOn_addingWeapon[2] =0
end

function alwaysOn_dodgedWeapon(iType)
	cfunction("showBitmapOverlay", "hud_dodgeWeapon", 1,100,20,140)
	cfunction("fadeOverlay", "hud_dodgeWeapon", 100, 0, 2000)
	cfunction("setTimer", 2000, "alwaysOn_dodgeWeaponStayOff")
end

function alwaysOn_dodgeWeaponStayOff()
	cfunction("showBitmapOverlay", "hud_dodgeWeapon", 0,100,20,140)
end	

function alwaysOn_removeBars()
	cfunction("showBitmapOverlay", "blackPix1", 0,100, 0,-450)	
	cfunction("showBitmapOverlay", "blackPix2", 0,100, 0,222)
end


function alwaysOn_reloadData()
	alwaysOn_updateHud()	
	alwaysOn_onChangeSMInputIcons()
end

function alwaysOn_addIntroScreens()
	cfunction("showBitmapOverlay", "blackPix1", 1,100, 0,0,0)	
	cfunction("showBitmapOverlay", "blackPix2", 1,100, 0,240,0)	
	cfunction("scaleBitmapOverlay", "blackPix1", 1, 1, 480, 32,0)
	cfunction("scaleBitmapOverlay", "blackPix2", 1, 1, 480, 32,0)
	
end

function alwaysOn_showSMOverlay()
	alwaysOn_SMOverlay = alwaysOn_SMOverlay + 0
	if alwaysOn_SMOverlay > 0 and alwaysOn_SMOverlayTimer == 0 then
		cfunction("fadeOverlay", alwaysOn_smOverlayData[alwaysOn_SMOverlay], 0, alwaysOn_SMPulse1Value, 500)		
		cfunction("setTimer", 500, "alwaysOn_SMPulse1")
		alwaysOn_SMOverlayTimer = 1
		alwaysOn_OldSMOverlay = alwaysOn_SMOverlay
	end	
	if alwaysOn_SMOverlay == 0 and alwaysOn_SMOverlayTimer > 0 then
		cfunction("showBitmapOverlay", alwaysOn_smOverlayData[alwaysOn_OldSMOverlay], 1, alwaysOn_SMPulse1Value,0,0)
		cfunction("fadeOverlay", alwaysOn_smOverlayData[alwaysOn_OldSMOverlay], alwaysOn_SMPulse1Value, 0, 500)		
		alwaysOn_SMOverlayTimer = 0
	end
end

function alwaysOn_SMPulse1()
	alwaysOn_SMOverlay = alwaysOn_SMOverlay + 0
	if alwaysOn_SMOverlay > 0 then
		cfunction("showBitmapOverlay", alwaysOn_smOverlayData[alwaysOn_SMOverlay], 1, alwaysOn_SMPulse1Value,0,0)		
		cfunction("scaleBitmapOverlay", alwaysOn_smOverlayData[alwaysOn_SMOverlay], 1, 1, 2, 2, 500)
		cfunction("setOverlayDestination", alwaysOn_smOverlayData[alwaysOn_SMOverlay], -240, -136, 500)
		cfunction("setTimer", 500, "alwaysOn_SMPulse1")
	end
end

function alwaysOn_SMPulse2()
	alwaysOn_SMOverlay = alwaysOn_SMOverlay + 0
	if alwaysOn_SMOverlay > 0 then
		cfunction("setTimer", 500, "alwaysOn_SMPulse1")
	end
end

smInputYOffset = 10

function alwaysOn_onChangeSMInputIcons()
	if alwaysOn_smImput == alwaysOn_lastSmImput then
	
	else

		--cfunction("debugPrintF", "alwaysOn_smImput: "..alwaysOn_smImput, alwaysOn_smImput)
		cfunction("showBitmapOverlay", "hud_smInputLeft_top", 0, 100,alwaysOn_smInputLeft_top_X, alwaysOn_smInputLeft_top_Y)		
		cfunction("showBitmapOverlay", "hud_smInputLeft_bottom", 0, 100,alwaysOn_smInputLeft_bottom_X, alwaysOn_smInputLeft_bottom_Y)		
		cfunction("showBitmapOverlay", "hud_smInputRight_top", 0, 100,alwaysOn_smInputRight_top_X, alwaysOn_smInputRight_top_Y)
		cfunction("showBitmapOverlay", "hud_smInputRight_bottom", 0, 100,alwaysOn_smInputRight_bottom_X, alwaysOn_smInputRight_bottom_Y)

		if alwaysOn_smImput == 0 then

		elseif alwaysOn_smImput == 1 then
			cfunction("showBitmapOverlay", "hud_smInputLeft_top", 1, 100,alwaysOn_smInputLeft_top_X, alwaysOn_smInputLeft_top_Y)		
		elseif alwaysOn_smImput == 2 then
			cfunction("showBitmapOverlay", "hud_smInputRight_top", 1, 100,alwaysOn_smInputRight_top_X, alwaysOn_smInputRight_top_Y)
		elseif alwaysOn_smImput == 11 then
			cfunction("showBitmapOverlay", "hud_smInputLeft_top", 1, 100,alwaysOn_smInputLeft_top_X, alwaysOn_smInputLeft_top_Y)		
			cfunction("showBitmapOverlay", "hud_smInputLeft_bottom", 1, 100,alwaysOn_smInputLeft_bottom_X, alwaysOn_smInputLeft_bottom_Y)		
		elseif alwaysOn_smImput == 12 then
			cfunction("showBitmapOverlay", "hud_smInputRight_top", 1, 100,alwaysOn_smInputRight_top_X, alwaysOn_smInputRight_top_Y)
			cfunction("showBitmapOverlay", "hud_smInputRight_bottom", 1, 100,alwaysOn_smInputRight_bottom_X, alwaysOn_smInputRight_bottom_Y)
		elseif alwaysOn_smImput == 13 or alwaysOn_smImput == 14 then
			cfunction("showBitmapOverlay", "hud_smInputRight_top", 1, 100,alwaysOn_smInputRight_top_X, alwaysOn_smInputRight_top_Y)
			cfunction("showBitmapOverlay", "hud_smInputLeft_top", 1, 100,alwaysOn_smInputLeft_top_X, alwaysOn_smInputLeft_top_Y)
		end

		alwaysOn_lastSmImput = alwaysOn_smImput
	end
	
end

function alwaysOn_onSetBehindTime(f)
	cfunction("showFontOverlay", "font_hud_behind", 1,100, 200,50)
	cfunction("setFontOverlayText", "font_hud_behind", f)
end

function alwaysOn_afterStatesAreSetInit()	
	if flow_gameMode == gameTypesIds['CHALLENGE'] then
		if flow_challengeId == challengeModes['CRITICALDAMAGE'] then
			cfunction("showBitmapOverlay", "CD_lifes", 1,100, 188,5, 128, 64)
			
			if alwaysOn_CDlifesLost > 0 then
				alwaysOn_updateLifeOverlay = "CD_cross1"
				alwaysOn_updateLifeOverlay_X = 199
				cfunction("showBitmapOverlay", alwaysOn_updateLifeOverlay, 1,100,alwaysOn_updateLifeOverlay_X, alwaysOn_updateLifeOverlay_Y)
			end
			if alwaysOn_CDlifesLost > 1 then
				alwaysOn_updateLifeOverlay = "CD_cross2"
				alwaysOn_updateLifeOverlay_X = 227
				cfunction("showBitmapOverlay", alwaysOn_updateLifeOverlay, 1,100,alwaysOn_updateLifeOverlay_X, alwaysOn_updateLifeOverlay_Y)
			end
			if alwaysOn_CDlifesLost == 3 then
				alwaysOn_updateLifeOverlay = "CD_cross3"
				alwaysOn_updateLifeOverlay_X = 255
				cfunction("showBitmapOverlay", alwaysOn_updateLifeOverlay, 1,100,alwaysOn_updateLifeOverlay_X, alwaysOn_updateLifeOverlay_Y)
			end
		end		
	end
	
	if flow_gameMode == gameTypesIds['CHALLENGE'] or flow_gameMode == gameTypesIds['TUTORIAL'] or flow_gameMode == gameTypesIds['TIMETRIAL'] then
		cfunction("showFontOverlay", "font_hud_pos_player", 0,100,alwaysOn_font_hud_pos_player_X,alwaysOn_font_hud_pos_player_Y)
		cfunction("showFontOverlay", "font_hud_pos_enemy", 0,100,alwaysOn_font_hud_pos_enemy_X,alwaysOn_font_hud_pos_enemy_Y)
		cfunction("showBitmapOverlay", "hud_position", 0, 100, 7,6,77,116)
	end
end

function alwaysOn_onEnterState()	
	alwaysOn_addingWeapon[1] = 0
	alwaysOn_addingWeapon[2] = 0 
	alwaysOn_removingWeapon[1] = 0
	alwaysOn_removingWeapon[2] = 0
	alwaysOn_lastPositionInRace =-1
	alwaysOn_lastTotalRacers =-1
	alwaysOn_dropWeaponEffectOn = 0
	alwaysOn_lastSmImput = -1
	
	
	
	if alwaysOn_wrongwayActive == 1 then
		cfunction("showBitmapOverlay", "hud_wrongway", 1,60,(480-256)/2,95)
		alwaysOn_wrongwayGoOn()
		
	end
	
	if alwaysOn_lowenergyActive == 1 then
		cfunction("showBitmapOverlay", "LE_lowenergy", 1, 60, 181, 3)
		alwaysOn_lowenergyGoOn()
	end
	
	
	cfunction("showFontOverlay", "font_hud_pos_player", 1,100,alwaysOn_font_hud_pos_player_X,alwaysOn_font_hud_pos_player_Y)		
	cfunction("showFontOverlay", "font_hud_pos_enemy", 1,100,alwaysOn_font_hud_pos_enemy_X,alwaysOn_font_hud_pos_enemy_Y)	
	
	cfunction("showFontOverlay", "font_hud_speed", 1,100,alwaysOn_font_hud_speed_X,alwaysOn_font_hud_speed_Y)	
	if flow_gameMode == gameTypesIds["MULTIPLAYER"] then
		cfunction("showFontOverlay", "font_hud_speed2", 1,100,alwaysOn_font_hud_speed_X,alwaysOn_font_hud_speed2_Y)	
	end
	cfunction("showFontOverlay", "font_hud_time", 1,100,alwaysOn_font_hud_time_X,alwaysOn_font_hud_time_Y)	

	cfunction("showBitmapOverlay", "hud_position", 1, 100, 7,6,77,116)
	cfunction("showBitmapOverlay", "hud_time", 1, 100,464,252,19,29)
	cfunction("showBitmapOverlay", "hud_statemorph", 1,100, 412,7,77,117)
	cfunction("showBitmapOverlay", "hud_speed", 1,100, 4, 218,77,116)
	if flow_gameMode == gameTypesIds["MULTIPLAYER"] then
		cfunction("showBitmapOverlay", "hud_statemorph2", 1,100, 412,143,77,117)
		cfunction("showBitmapOverlay", "hud_speed2", 1,100, 4, 82,77,116)
	end
	alwaysOn_reloadData()
	alwaysOn_afterStatesAreSetInit()
end



function alwaysOn_onLeaveState()	
	cfunction("showFontOverlay", "font_hud_behind", 0,100, 200,50)
	cfunction("showBitmapOverlay", "hud_wrongway", 0,0,428,140)
	if flow_gameMode == gameTypesIds["CHALLENGE"] then
		cfunction("showBitmapOverlay", "LE_lowenergy", 0, 100, 181, 3)
		cfunction("showBitmapOverlay", "CD_lifes", 0,100, 188,5)
		cfunction("showBitmapOverlay", "CD_cross1", 0,100,0, 0)
		cfunction("showBitmapOverlay", "CD_cross2", 0,100,0, 0)
		cfunction("showBitmapOverlay", "CD_cross3", 0,100,0, 0)
	end
end


function alwaysOn_setWeaponLockDistance(fDist)
	
	if alwaysOn_weaponLockActive == 0 then
		cfunction("debugPrintF", "alwaysOn_setWeaponLockDistance called but weaponLock is not active", 0)
	else
		--cfunction("debugPrintF", "alwaysOn_setWeaponLockDistance", fDist)
		if fDist > 0 then
			cfunction("showBitmapOverlay", "hud_weaponLock_hit", 0,100,alwaysOn_weaponLock_hit_X, alwaysOn_weaponLock_hit_Y)
			cfunction("showBitmapOverlay", "hud_weaponLock_blockL", 1,100,alwaysOn_weaponLock_blockL_X - fDist, alwaysOn_weaponLock_blockL_Y)
			cfunction("showBitmapOverlay", "hud_weaponLock_blockR", 1,100,alwaysOn_weaponLock_blockR_X + fDist, alwaysOn_weaponLock_blockR_Y)
		else 
			cfunction("showBitmapOverlay", "hud_weaponLock_blockL", 0,100,alwaysOn_weaponLock_blockL_X,alwaysOn_weaponLock_blockL_Y)
			cfunction("showBitmapOverlay", "hud_weaponLock_blockR", 0,100,alwaysOn_weaponLock_blockR_X,alwaysOn_weaponLock_blockR_Y)
			if alwaysOn_weaponLockHitOn == 0 then
				alwaysOn_weaponLockHitOn = 1
				cfunction("showBitmapOverlay", "hud_weaponLock_hit", 1,100,alwaysOn_weaponLock_hit_X, alwaysOn_weaponLock_hit_Y)
			else
				alwaysOn_weaponLockHitOn = 0
				cfunction("showBitmapOverlay", "hud_weaponLock_hit", 0,100,alwaysOn_weaponLock_hit_X, alwaysOn_weaponLock_hit_Y)
			end
		end
	end
end

function alwaysOn_activateWeaponLock(iType)
	cfunction("showBitmapOverlay", "hud_weaponLock_frame", 1,100,alwaysOn_weaponLock_frame_X,alwaysOn_weaponLock_frame_Y)
	alwaysOn_weaponLockActive = 1
	--cfunction("showFontOverlay", "font_hud_weaponLockText", 1,100,25,150)	
	--cfunction("setFontOverlayText", "font_hud_weaponLockText", "999")
	
end

function alwaysOn_deactivateWeaponLock()
	cfunction("showBitmapOverlay", "hud_weaponLock_frame", 0,100,alwaysOn_weaponLock_frame_X,alwaysOn_weaponLock_frame_Y)
	cfunction("showBitmapOverlay", "hud_weaponLock_hit", 0,100,alwaysOn_weaponLock_hit_X, alwaysOn_weaponLock_hit_Y)
	cfunction("showBitmapOverlay", "hud_weaponLock_blockL", 0,100,alwaysOn_weaponLock_blockL_X,alwaysOn_weaponLock_blockL_Y)
	cfunction("showBitmapOverlay", "hud_weaponLock_blockR", 0,100,alwaysOn_weaponLock_blockR_X,alwaysOn_weaponLock_blockR_Y)
	alwaysOn_weaponLockActive=0
	--cfunction("showFontOverlay", "font_hud_weaponLockText", 0,100,200,210)	
end

function alwaysOn_activateWrongWay()
	--cfunction("debugPrintF", "alwaysOn_activateWrongWay", 0)
	cfunction("showBitmapOverlay", "hud_wrongway", 1,0,(480-256)/2,95)
	alwaysOn_wrongwayActive = 1
	cfunction("fadeOverlay", "hud_wrongway", 0, 100, 1000)
	cfunction("setTimer", 1000, "alwaysOn_wrongwayGoOff")
end

function alwaysOn_wrongwayGoOff()
	--cfunction("debugPrintF", "alwaysOn_wrongwayGoOff", 0)
	if alwaysOn_wrongwayActive == 1 then
		cfunction("fadeOverlay", "hud_wrongway", 100, 60, 500)	
		cfunction("setTimer", 500, "alwaysOn_wrongwayGoOn")
	else
		cfunction("fadeOverlay", "hud_wrongway", 100, 0, 500)	
		cfunction("setTimer", 500, "alwaysOn_wrongwayStayOff")
	end
end

function alwaysOn_wrongwayGoOn()
	--cfunction("debugPrintF", "alwaysOn_wrongwayGoOn", 0)
	cfunction("fadeOverlay", "hud_wrongway", 60, 100, 500)	
	cfunction("setTimer", 500, "alwaysOn_wrongwayGoOff")
end

function alwaysOn_wrongwayStayOff()
	--cfunction("debugPrintF", "alwaysOn_wrongwayStayOff", 0)
	cfunction("showBitmapOverlay", "hud_wrongway", 0,0,428,140)
end

function alwaysOn_deactivateWrongWay()	
	--cfunction("debugPrintF", "alwaysOn_deactivateWrongWay", 0)
	alwaysOn_wrongwayActive = 0
end


function alwaysOn_activateLowEnergy()
	--cfunction("debugPrintF", "alwaysOn_activateLowEnergy", 0)
	if alwaysOn_lowenergyActive == 0 then
		cfunction("showBitmapOverlay", "LE_lowenergy", 1, 0, 181, 3)
		alwaysOn_lowenergyActive = 1
		cfunction("fadeOverlay", "LE_lowenergy", 0, 100, 1000)
		cfunction("setTimer", 1000, "alwaysOn_lowenergyGoOff")
	end
end

function alwaysOn_lowenergyGoOff()
	--cfunction("debugPrintF", "alwaysOn_lowenergyGoOff", 0)
	if alwaysOn_lowenergyActive == 1 then
		cfunction("fadeOverlay", "LE_lowenergy", 100, 60, 500)	
		cfunction("setTimer", 500, "alwaysOn_lowenergyGoOn")
	else
		cfunction("fadeOverlay", "LE_lowenergy", 100, 0, 500)	
		cfunction("setTimer", 500, "alwaysOn_lowenergyStayOff")
	end
end

function alwaysOn_lowenergyGoOn()
	--cfunction("debugPrintF", "alwaysOn_lowenergyGoOn", 0)
	cfunction("fadeOverlay", "LE_lowenergy", 60, 100, 500)	
	cfunction("setTimer", 500, "alwaysOn_lowenergyGoOff")
end

function alwaysOn_lowenergyStayOff()
	--cfunction("debugPrintF", "alwaysOn_lowenergyStayOff", 0)
	if alwaysOn_lowenergyActive == 0 then
		cfunction("showBitmapOverlay", "LE_lowenergy", 0,0,181,3)
	end
end

function alwaysOn_deactivateLowEnergy()	
	--cfunction("debugPrintF", "alwaysOn_deactivateLowEnergy", 0)
	alwaysOn_lowenergyActive = 0
end

function alwaysOn_CDupdateLifes()
	if alwaysOn_CDlifesLost == 1 then
		alwaysOn_updateLifeOverlay = "CD_cross1"
		alwaysOn_updateLifeOverlay_X = 199
	elseif alwaysOn_CDlifesLost == 2 then
		alwaysOn_updateLifeOverlay = "CD_cross2"
		alwaysOn_updateLifeOverlay_X = 227
	elseif alwaysOn_CDlifesLost == 3 then
		alwaysOn_updateLifeOverlay = "CD_cross3"
		alwaysOn_updateLifeOverlay_X = 255
	end
	
	alwaysOn_updateLifeOverlay_Y = 6
	
	cfunction("showBitmapOverlay", alwaysOn_updateLifeOverlay, 1,0,alwaysOn_updateLifeOverlay_X - 13, alwaysOn_updateLifeOverlay_Y - 13)
	cfunction("fadeOverlay", alwaysOn_updateLifeOverlay, 0,100,150)
	cfunction("scaleBitmapOverlay", alwaysOn_updateLifeOverlay, 2,2,1,1,300)
	cfunction("setOverlayDestination", alwaysOn_updateLifeOverlay, alwaysOn_updateLifeOverlay_X, alwaysOn_updateLifeOverlay_Y, 300)
	alwaysOn_CDblinkLifescounter = 6
	cfunction("setTimer", 300, "alwaysOn_CDblinkLifesOff")
end

function alwaysOn_CDblinkLifesOn()
	--cfunction("debugPrintF", "alwaysOn_CDblinkLifesOn", 0)
	cfunction("showBitmapOverlay", alwaysOn_updateLifeOverlay, 1,100,alwaysOn_updateLifeOverlay_X, alwaysOn_updateLifeOverlay_Y)
	alwaysOn_CDblinkLifescounter = alwaysOn_CDblinkLifescounter -1
	if alwaysOn_CDblinkLifescounter > 0 then
		cfunction("setTimer", 100, "alwaysOn_CDblinkLifesOff")
	end
end

function alwaysOn_CDblinkLifesOff()
	--cfunction("debugPrintF", "alwaysOn_CDblinkLifesOff", 0)
	cfunction("showBitmapOverlay", alwaysOn_updateLifeOverlay, 0,100,alwaysOn_updateLifeOverlay_X, alwaysOn_updateLifeOverlay_Y)
	cfunction("setTimer", 100, "alwaysOn_CDblinkLifesOn")
end
