XML Gallery dynamic border?

Just thought I’d see if this is possible with the XML Photo Gallery.

  1. Is it possible to create a dynamic border for the loaded image depending on the size of the image being loaded?
  2. Is it possible to move the Y position of the caption text box depending on the height of the loaded image? ie if the image is 200 pixels high, then the text box should be positioned at 220 pixels.

The current code I have which loads the images then automatically scrolls through them is:

delay = 6000;
// -----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
link = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
link* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue; 
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("pid1.xml");
p = 0;
function preload(clip) {
picture.loadMovie(clip);
preloader._visible = true;
var temp = this.createEmptyMovieClip("temp", 9987);
temp.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader.preload_bar._xscale = 100*loaded/filesize;
if (filesize>4 && filesize == loaded) {
preloader._visible = false;
picture._alpha += 10;
if (picture._alpha>100) {
	picture._alpha = 100;
	slideshow();
	delete this.onEnterFrame;
}
}
picture.onRelease = function() {
getURL(link[p], "_blank");
}; 
};
}
function nextImage() {
if (p<(total-1)) {
p++;
fadeOut(image[p]);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
picture._alpha = 0;
fadeOut(image[0]);
desc_txt.text = description[0];
picture_num();
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
}
function fadeOut(clip) {
picture.onEnterFrame = function() {
this._alpha -= 20;
if (this._alpha<0) {
preload(clip);
delete this.onEnterFrame;
}
};
}

Any help greatly appreciated.