I've used some code drawn from this other question here on SO: Math: Ease In, ease Out a displacement using Hermite curve with time constraint
I've since minified the 5 animation interpolation functions and it's certainly less easy to read.
Here's an approach that works just fine - make sure you update the image sources to reflect valid images.
Basically, we call a function that will fade out the target element in 500ms, using 50 steps. Once this is done, we change the source of the image and then fade it back in again. Once this is done, we set a timeout of 3 seconds before we start all over again.
<!DOCTYPE html>
<html>
<head>
<script>
///////////////////////////////////////////////////////////////////////////////////////////function cubicHermite(a,b,d,e,c){var g=a*a,f=g*a;return(2*f-3*g+1)*b+(f-2*g+a)*e+(-2*f+3*g)*d+(f-g)*c}
function interp(a,b,d,e,c){var g,f;f=e/(a/2+b+d/2);g=f*a/2;f*=b;return result=c<=a?cubicHermite(c/a,0,g,0,f/b*a):c<=a+b?g+f*(c-a)/b:cubicHermite((c-a-b)/d,g+f,e,f/b*d,0)}
function linear(a){return a}
function cubic(a){return interp(0.35,0.3,0.35,1,a)}
function doAnim(a,b,d,e){var c=a/b;setTimeout(function(){doAnimStep(0,b,c,d,e)},c)}
function doAnimStep(a,b,d,e,c){a<=b?(setTimeout(function(){doAnimStep(a,b,d,e,c)},d),e(a/b),a++):void 0!=c&&null!=c&&c()}
///////////////////////////////////////////////////////////////////////////////////////////function animFadeIn(elem, callback)
{
doAnim(250,20,function(raw){elem.style.opacity=cubic(raw)},callback);
}
function animFadeOut(elem, callback)
{
doAnim(500,50,function(raw){elem.style.opacity=1-cubic(raw)},callback);
}
///////////////////////////////////////////////////////////////////////////////////////////
window.addEventListener('load', onDocLoaded, false);
function onDocLoaded()
{
slideChange();
}
var imgNames = ["img/girl.png", "img/redbaron.png"];
var imgNum = 0;
function slideChange()
{
animFadeOut(document.images.slide, afterSlideFadedOut);
function afterSlideFadedOut()
{
document.images.slide.src = imgNames[imgNum];
imgNum++;
if (imgNum > imgNames.length-1)
imgNum=0;
animFadeIn(document.images.slide, afterSlideFadedIn);
}
function afterSlideFadedIn()
{
setTimeout(slideChange, 3000);
}
}
</script>
</head>
<body>
<img name="slide" width="300" height="269" />
</body>
</html>