    function FormatCaptions(tagName) {
      var txt="";
      var x,s,i;
      var spantxt=new Array();

      if (x=document.all) {
        for (s in x) {
          if (x[s].name == tagName) {
            if (x[s].innerHTML) {
              spantxt.push(altText(x[s].innerHTML));
              x[s].innerHTML=briefText(x[s].innerHTML);
            } else {
              spantxt.push();
            }
          }
        }

        i=document.getElementById("photos").getElementsByTagName("img");
        for (s in i) {
          if (spantxt[s]) {
            i[s].alt=spantxt[s];
            i[s].title=spantxt[s];
          }
        }
      } else if (x=document.getElementsByName(tagName)) {
        for (s in x) {
          if (x[s].innerHTML) {
            spantxt.push(altText(x[s].innerHTML));
            x[s].innerHTML=briefText(x[s].innerHTML);
          } else {
            spantxt.push();
          } 
        }

        i=document.getElementById("photos").getElementsByTagName("img");
        for (s in i) {
          if (spantxt[s]) {
            i[s].alt=spantxt[s];
            i[s].title=spantxt[s];
          }
        } 
      }
    }

  // briefText(txt) shortens captions using javascript to save space.  Formatting may be off if javascript is not supported.
    function briefText(txt) {
      var lines=2; // Maximum number of lines
      var chars=35; // Characters per line
      var copy=new Array();
      var dots=0;
      var x,y;
      var z=new Array();
      var k,l,m,n;

    // Check Number of Lines
      var arr=txt.split(/<br>/i);

      while ((arr.length > 0) && (dots != 1)) {
        x=arr.shift();

        if (((k=x.indexOf("<",0)) != -1) && ((l=x.indexOf(">",k)) != -1) && ((m=x.indexOf("<",l)) != -1) && ((n=x.indexOf(">",m)) != -1)) {
          z.push(x.substring(k,l+1));
          z.push(x.substring(m,n+1));

          x=x.substring(0,k) + "<>" + x.substring(l+1,m) + "<>" + x.substring(n+1);
        }

        if (copy.length < lines) {
          if (x.length < chars) {
            // Do Nothing special
          } else if (x.length < (lines - copy.length) * chars) {
            lines=lines - Math.floor((x.length/chars));
          } else {
            x=x.substr(0,(lines - copy.length) * chars);
            y=x.lastIndexOf(" ");

            if (y != -1) {
              x=x.substr(0,y) + "...";
            }

            dots=1;
          }

          while (z.length > 0) {
            var zz=z.shift();
            x=x.replace(/<>/,zz);
          }

          copy.push(x);
        } else {
          copy[copy.length-1]=copy[copy.length-1] + "...";
          dots=1;
        }
      }

      return copy.join("<br />");
    }

  // altText(txt) replaces the alt and title properties in the img tags with meaningful information
    function altText(txt) {
      var lines=5; // Maximum number of lines
      var chars=75; // Characters per line
      var copy=new Array();
      var dots=0;
      var x,y;
      var z=new Array();
      var k,l,m,n;

    // Check Number of Lines
      var arr=txt.split(/<br>/i);

      while ((arr.length > 0) && (dots != 1)) {
        x=arr.shift();

        if (((k=x.indexOf("<",0)) != -1) && ((l=x.indexOf(">",k)) != -1) && ((m=x.indexOf("<",l)) != -1) && ((n=x.indexOf(">",m)) != -1)) {
          z.push(x.substring(k,l+1));
          z.push(x.substring(m,n+1));

          x=x.substring(0,k) + "<>" + x.substring(l+1,m) + "<>" + x.substring(n+1);
        }

        if (copy.length < lines) {
          if (x.length < chars) {
            // Do Nothing special
          } else if (x.length < (lines - copy.length) * chars) {
            lines=lines - Math.floor((x.length/chars));
          } else {
            x=x.substr(0,(lines - copy.length) * chars);
            y=x.lastIndexOf(" ");

            if (y != -1) {
              x=x.substr(0,y) + "...";
            }

            dots=1;
          }

          x=x.replace(/<>/g,"");

          copy.push(x);
        } else {
          copy[copy.length-1]=copy[copy.length-1] + "...";
          dots=1;
        }
      }

      return copy.join("\r\n");
    }

