﻿function addCaption( oImgElem, bUseCaptionMarker ) {   // Insert Caption   var oCaptionElem = document.createElement("div");   oCaptionElem.className = "caption";    if( bUseCaptionMarker)   {     var oCaptionMarkerElem = document.createElement("div");     oCaptionMarkerElem.className = "caption-marker";     var oCaptionMarkerTextElem = document.createTextNode("");     oCaptionMarkerElem.appendChild(oCaptionMarkerTextElem);     oCaptionElem.appendChild(oCaptionMarkerElem );   }    var oCaptionTextElem = document.createElement("div");   oCaptionTextElem.className = "caption-text";   var oCaptionText = document.createTextNode( oImgElem.alt );   oCaptionTextElem.appendChild(oCaptionText );   oCaptionElem.appendChild(oCaptionTextElem);    if( oImgElem.getAttribute("copyright") != null )   {     var oCopyrightElem = document.createElement("div");     oCopyrightElem.className = "copyright";     var oCopyrightText = document.createTextNode(        oImgElem.getAttribute("copyright") );     oCopyrightElem.appendChild(oCopyrightText);     oCaptionElem.appendChild(oCopyrightElem );   }    if(oImgElem.nextSibling)      oImgElem.parentNode.insertBefore(oCaptionElem,       oImgElem.nextSibling);   else     oImgElem.parentNode.appendChild(oCaptionElem);    with(oImgElem.style)   {     oCaptionElem.style.width = (oImgElem.width+borderLeft+       borderRight+paddingLeft+paddingRight)+"px";   }    return true;  }  
