rather than $$ITEM_FILEINDIV you should create the link using the base file name (e.g. 'movie_' + num + '.html')
for "num", you could use another array that will store the movie numbers, or get the last index of the "pic" array. I do not know how this can be done in JS actually, but there should be a way to get the last index of an array. If not, you have to do a "numbers" array built like the pic array I guess.
var title = new Array();
$$ITEM_BEGIN
title[$$ITEM_NUMBER] = "$$ITEM_ORIGINALTITLE";
$$ITEM_END
var url = new Array();
$$ITEM_BEGIN
url[$$ITEM_NUMBER] = "$$ITEM_URL";
$$ITEM_END