function chooseRanksIconsMenu(originalBGImage)
	local ovImg=Image.load("images/menus/skin_choose_rankIcons.png")
	
	local nbIcons=nil
	local i=0
	local prop=nil
	local currentSelection=1
	local names=nil
	if ranksPreviews==nil then
		-- loading
		screen:blit(0, 0, originalBGImage, true)
		alert("loading")
		
		ranksPreviews={}
		names=getFolderList("images/icons/ranks")
		nbIcons=tableLength(names)
		for i=1,nbIcons do
			ranksPreviews[i]={}
			ranksPreviews[i]["num"]=i
			ranksPreviews[i]["p"]=Image.load("images/icons/ranks/"..names[i].."/president.png")
			ranksPreviews[i]["vp"]=Image.load("images/icons/ranks/"..names[i].."/vice_president.png")
			ranksPreviews[i]["n"]=Image.load("images/icons/ranks/"..names[i].."/neutral.png")
			ranksPreviews[i]["va"]=Image.load("images/icons/ranks/"..names[i].."/vice_asshole.png")
			ranksPreviews[i]["a"]=Image.load("images/icons/ranks/"..names[i].."/asshole.png")
			prop=loadPropertiesFile("images/icons/ranks/"..names[i].."/ranksIcons.properties")
			ranksPreviews[i]["author"]=prop["author"]
			ranksPreviews[i]["name"]=prop["name"]
			ranksPreviews[i]["description"]=prop["description"]
			ranksPreviews[i]["copyright"]=prop["copyright"]
			ranksPreviews[i]["language"]=prop["language"]
			ranksPreviews[i]["folderName"]=names[i]
			if USERPREF["ranksIcons"]==names[i] then --this is what the user is using
				currentSelection=i
			end
		end
	else
		nbIcons=tableLength(ranksPreviews)
		for i=1,nbIcons do
			if USERPREF["ranksIcons"]==ranksPreviews[i]["folderName"] then --this is what the user is using
				currentSelection=i
			end
		end
	end
			
	drawRanksIconsMenu(originalBGImage, currentSelection, nbIcons, ovImg)
	
	while true do
		updateInputs(Controls.read())
		

		--specific inputs
		if inputFirstPress("left") or inputIsRepeating("left") then
			if currentSelection>1 then
				currentSelection=currentSelection-1
			else
				currentSelection=nbIcons
			end
			drawRanksIconsMenu(originalBGImage, currentSelection, nbIcons, ovImg)
		elseif inputFirstPress("right") or inputIsRepeating("right") then
			if currentSelection<nbIcons then
				currentSelection=currentSelection+1
			else
				currentSelection=1
			end
			drawRanksIconsMenu(originalBGImage, currentSelection, nbIcons, ovImg)
		elseif inputFirstPress("l") or inputIsRepeating("l") then
			if currentSelection>3 then --1+4
				currentSelection=currentSelection-3
			else
				currentSelection=1
			end
			drawRanksIconsMenu(originalBGImage, currentSelection, nbIcons, ovImg)
		elseif inputFirstPress("r") or inputIsRepeating("r") then
			if currentSelection<nbIcons-2 then
				currentSelection=currentSelection+3
			else
				currentSelection=nbIcons
			end
			drawRanksIconsMenu(originalBGImage, currentSelection, nbIcons, ovImg)
		end
		
		--selection
		if inputFirstPress("cross") or inputFirstPress("circle") then
			alert("loading...")
			selectRanksIcons(ranksPreviews[currentSelection]["folderName"])
			return "changed"
		end
		
		
		--drawing
		
		
		
		--usual inputs
		if inputFirstPress("start") then
			return "quitMenu"
		end
		
		if inputFirstPress("square") then
			return "cancel"
		end
		
		
	end
end

function drawRanksIconsMenu(originalBGImage, currentSelection, nbIcons, ovImg)
	local xref=90
	local yref=95

	screen:blit(0, 0, originalBGImage, true)
	screen:blit(0, 0, ovImg, true)
	printBicolor(screen, xref+270, yref-3, currentSelection.."/"..nbIcons, black, white)
	printBicolor(screen, xref, yref-3, ranksPreviews[currentSelection]["name"], black, white)
	printBicolor(screen, xref+95, yref+15, "Author:", black, white)
	printBicolor(screen, xref+180, yref+15, ranksPreviews[currentSelection]["author"], black, white)
	printBicolor(screen, xref+95, yref+25, "Language:", black, white)
	printBicolor(screen, xref+180, yref+25, ranksPreviews[currentSelection]["language"], black, white)
	printWithCR(screen, xref, yref+45, ranksPreviews[currentSelection]["description"], white, 8, black)
	printU(screen, xref, yref+88, ranksPreviews[currentSelection]["copyright"], white, false, "default", 8, 8, 8, black)
	
	
	screen:blit(xref, yref+15, ranksPreviews[currentSelection]["p"], true)
	screen:blit(xref+15, yref+15, ranksPreviews[currentSelection]["vp"], true)
	screen:blit(xref+30, yref+15, ranksPreviews[currentSelection]["n"], true)
	screen:blit(xref+45, yref+15, ranksPreviews[currentSelection]["va"], true)
	screen:blit(xref+60, yref+15, ranksPreviews[currentSelection]["a"], true)
	
	
	
	screen.flip()
	screen.waitVblankStart()
end







