var imageFunction = function (request, xml){ img = $('largeimg'); img.effects({duration: 1000}).start({'opacity':[1,0]}) var response = xml.documentElement; $('largeimg').replaceWith(new Asset.image(response.getElementsByTagName("imagepath")[0].firstChild.nodeValue, {id: 'largeimg', title: 'largeimg', onload: $('largeimg').effects({duration: 1000}).start({'opacity':[0,1]})}); $('caption').setHTML(response.getElementsByTagName("imagecaption")[0].firstChild.nodeValue); }