Help needed with dynamic gallery

Hello everybody!

I need help with a dynamic flash gallery im trying to create. As an example, im using vman’s gallery, found here: http://www.kirupa.com/forum/showthread.php?t=79236&page=3&pp=15&highlight=gallery+folders

i have a movieclip that has two frames,on the first frame i have AS that loads the folder names(the folders hold pics) in and displays them as buttons, this i got done…

Now on the second frame i have a containerMC wich should hold the pics, when you press the folder button, it should load the pics from that loader. Also on the second frame i have back and next buttons. Basically the gallery looks like the kirupa basic photo gallery: http://www.kirupa.com/developer/mx/photogallery.htm

i need that those pics would be kind of thumbs to display a much larger pic…
and i got lost in the code, so i could need some advice…

count_folders = new LoadVars ();
count_folders.onLoad = function (success) {
	if (success) {
		folder_array = this.foldernames.split (",");
		folder = folder_array[0];
		for (i = 0; i < folder_array.length - 1; i++) {
			_root.textButton_MC.attachMovie ("textbutton", "textbutton" + i, i, {_x:startX, _y:startY});
			buttonName = folder_array*;
			_root.textButton_MC["textbutton" + i].showText.text = buttonName;
			_root.textButton_MC["textbutton" + i].folderName = buttonName;
			_root.textButton_MC["textbutton" + i].onRelease = function () {
				_root.folder = this.folderName;
			};
			startY = (cnt % numColumns == 0) ? 0 : startY + _root.textButton_MC["textbutton" + i]._height + 10;
			//startX = (cnt % numColumns == 0) ? startX + _root.textButton_MC["textbutton" + i]._width : startX;
		};
	}
};
count_folders.sendAndLoad ("http://localhost/galerii/foldercounter.php", count_folders, "POST");

changeGallery = function () {
	count_thumbs = new LoadVars ();
	count_thumbs.folder = folder;
	count_thumbs.onLoad = function (ok) {
		if (ok) {
			i = 0;
			cnt = 1;
			startX = 0;
			startY = 0;
			//_root.thumbMC._y = 10;
			//_root.thumbMC._x = 17;
			thumb_array = this.filenames.split (",");
			_root.picNum = thumb_array[0];
			_root.arrayLength = thumb_array.length - 2;
			_root.containerMC.loadPic (folder + "/pildid/" + thumb_array[0]);
			for (i = 0; i < thumb_array.length - 1; i++) {
				_root["file" + i] = thumb_array*;
				filename = thumb_array*;
				//thumbMC.thumbScroller.thumbHolder["box" + i].container.loadMovie ("Gigs/" + folder + "/thumbs/" + filename);
				//thumbMC.thumbScroller.thumbHolder["box" + i].targPic = filename;
				//thumbMC.thumbScroller.thumbHolder["box" + i].targNum = i;
				//thumbMC.thumbScroller.thumbHolder["box" + i].onRelease = function () {
					containerMC.loadPic (folder + "/pildid/" + this.targPic);
					_root.current = this.targNum;
					_root.galleriesUp = 0;
					_root.picNum = this.targPic;
				};
			}
		}
	};
	_root.containerMC.loadPic (folder + "/pildid/" + _root.picNum);
	count_thumbs.sendAndLoad ("http://localhost/galerii/thumbcounter2.php", count_thumbs, "POST");

_root.back.onRelease = function () {
	if (current == 0) {
		containerMC.loadPic (folder + "/pildid/" + [file0]);
		current = 0;
		//cur_img.text = current;
	} else {
		current = current - 1;
		containerMC.loadPic (folder + "/pildid/" + _root["file" + current]);
	}
};
_root.next.onRelease = function () {
	if (current == arrayLength) {
		containerMC.loadPic (folder + "/pildid/" + _root["file" + current]);
		current = arrayLength;
	} else {
		current = current + 1;
		containerMC.loadPic (folder + "/pildid/" + _root["file" + current]);
	}
};
stop();