function isIE5dot0() {
 return (navigator.userAgent.toLowerCase().indexOf("msie 5.0") != -1);
}

function toggleSize(oImg) {
 var sImgSrc = oImg.src;
 var sImgSize = sImgSrc.charAt(sImgSrc.length - 5);
 var sNewImgSrc;
 var sNewImgAlt;

 if (sImgSize == 'l' && isIE5dot0()) {
 return false;
 }

 var sNewImgSrc = sImgSrc.substr(0, sImgSrc.length - 5);
 if (sImgSize == 's') {
 sNewImgSrc += 'l';
 sNewClass = 'imgLarge';
 } else if (sImgSize == 'l') {
 sNewImgSrc += 's';
 sNewClass = 'imgSmall';
 }
 sNewImgSrc += sImgSrc.substr(sImgSrc.length - 4, sImgSrc.length);

 var oNewImg = new Image();
 oNewImg.refImg = oImg;
 oNewImg.onload = function() {
 this.refImg.width = this.width;
 this.refImg.height = this.height;
 }
 oNewImg.src = sNewImgSrc;

 toggleCaption(oImg, sImgSize == 's');

 oImg.src = sNewImgSrc;
 oImg.className = sNewClass;
}

function toggleCaption(oImg, bShow) {

 var oSpan = null;

 // remove existing caption
 if (bShow == false) {
 if (oImg.nextSibling.tagName == 'SPAN') {
 oImg.parentNode.removeChild(oImg.nextSibling);
 }
 } else if (bShow == true) {
 // show caption
 var oCaptionTextElem, oCaptionText;
 oCaptionTextElem = document.createElement("span");
 oCaptionTextElem.className = "caption";

 oCaptionText = document.createTextNode(oImg.alt);

 oCaptionTextElem.appendChild(oCaptionText);

 oSpan = oImg.parentNode.insertBefore(oCaptionTextElem, oImg.nextSibling);
 }

 return oSpan;
}
