function chooseCardsMenu(originalBGImage)
	local ovImg=Image.load("images/menus/skin_choose_cards.png")
	
	local nbCards=nil
	local i=0
	local prop=nil
	local currentSelection=1
	local names=nil
	if cardsPreviews==nil then
		-- loading
		screen:blit(0, 0, originalBGImage, true)
		alert("loading")
		
		cardsPreviews={}
		names=getFolderList("images/cards")
		nbCards=tableLength(names)
		for i=1,nbCards do
			cardsPreviews[i]={}
			cardsPreviews[i]["num"]=i
			cardsPreviews[i]["previewImage"]=Image.load("images/cards/"..names[i].."/preview.png")
			prop=loadPropertiesFile("images/cards/"..names[i].."/cards.properties")
			cardsPreviews[i]["author"]=prop["author"]
			cardsPreviews[i]["name"]=prop["name"]
			cardsPreviews[i]["description"]=prop["description"]
			cardsPreviews[i]["copyright"]=prop["copyright"]
			cardsPreviews[i]["language"]=prop["language"]
			cardsPreviews[i]["folderName"]=names[i]
			if USERPREF["cards"]==names[i] then --this is what the user is using
				currentSelection=i
			end
		end
	else
		nbCards=tableLength(cardsPreviews)
		for i=1,nbCards do
			if USERPREF["cards"]==cardsPreviews[i]["folderName"] then --this is what the user is using
				currentSelection=i
			end
		end
	end
	
	drawCardsMenu(originalBGImage, currentSelection, nbCards, 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=nbCards
			end
			drawCardsMenu(originalBGImage, currentSelection, nbCards, ovImg)
		elseif inputFirstPress("right") or inputIsRepeating("right") then
			if currentSelection<nbCards then
				currentSelection=currentSelection+1
			else
				currentSelection=1
			end
			drawCardsMenu(originalBGImage, currentSelection, nbCards, ovImg)
		elseif inputFirstPress("l") or inputIsRepeating("l") then
			if currentSelection>3 then --1+4
				currentSelection=currentSelection-3
			else
				currentSelection=1
			end
			drawCardsMenu(originalBGImage, currentSelection, nbCards, ovImg)
		elseif inputFirstPress("r") or inputIsRepeating("r") then
			if currentSelection<nbCards-2 then
				currentSelection=currentSelection+3
			else
				currentSelection=nbCards
			end
			drawCardsMenu(originalBGImage, currentSelection, nbCards, ovImg)
		end
		
		--selection
		if inputFirstPress("cross") or inputFirstPress("circle") then
			alert("loading...")
			selectCards(cardsPreviews[currentSelection]["folderName"])
			return "changed"
		end
		
		--usual inputs
		if inputFirstPress("start") then
			return "quitMenu"
		end
		
		if inputFirstPress("square") then
			return "cancel"
		end
		
		
	end
end

function drawCardsMenu(originalBGImage, currentSelection, nbCards, ovImg)
	local xref=90
	local yref=50
	
	screen:blit(0, 0, originalBGImage, true)
	screen:blit(0, 0, ovImg, true)
	
	screen:blit(xref, yref+15, cardsPreviews[currentSelection]["previewImage"], true)
	printBicolor(screen, xref+270, yref, currentSelection.."/"..nbCards, black, white)
	printBicolor(screen, xref, yref, cardsPreviews[currentSelection]["name"], black, white)
	
	printBicolor(screen, xref+170, yref+30, "Author:", black, white)
	printBicolor(screen, xref+180, yref+40, cardsPreviews[currentSelection]["author"], black, white)
	
	printBicolor(screen, xref+170, yref+60, "Language:", black, white)
	printBicolor(screen, xref+180, yref+70, cardsPreviews[currentSelection]["language"], black, white)
	
	printU(screen, xref, yref+177, cardsPreviews[currentSelection]["copyright"], white, false, "default", 8, 8, 8, black)
	
	printWithCR(screen, xref, yref+109, cardsPreviews[currentSelection]["description"], white, 8, black)
	
	screen.flip()
	screen.waitVblankStart()
end





