  function so_init() {
    img1 = document.getElementById("img1");
    img2 = document.getElementById("img2");
    img1.src = 'http://www.barnesvillehospital.com/images/ps/'+imageurls[1];
    img2.src = 'http://www.barnesvillehospital.com/images/ps/'+imageurls[1];
    img1.xOpacity = 1;
    img2.xOpacity = 0;
    current = 1;
    switchpic();
  }

  function switchpic() {
    imgpt++;
    if (imgpt > imgct) { imgpt = 1; }
    switch (current) {
      case 0:  alert("so_init was not run!"); return;
      case 1:  img2.src = 'http://www.barnesvillehospital.com/images/ps/'+imageurls[imgpt]; break;
      case 2:  img1.src = 'http://www.barnesvillehospital.com/images/ps/'+imageurls[imgpt]; break;
      default: alert("Invalid image id!");    return;
    }
    setTimeout(so_xfade,5000);
  }

  function so_xfade() {
    if (current == 1) {
      img1.xOpacity -= .05;
      img2.xOpacity += .05;
      setOpacity(img1);
      setOpacity(img2);

      if(img1.xOpacity <= 0) {
        img1.xOpacity = 0;
        img2.xOpacity = 1;
        current = 2;
        switchpic();
      } else { setTimeout(so_xfade,100); }
    } else { // current == 2
      img1.xOpacity += .05;
      img2.xOpacity -= .05;
      setOpacity(img1);
      setOpacity(img2);

      if(img2.xOpacity <= 0) {
        img1.xOpacity = 1;
        img2.xOpacity = 0;
        current = 1;
        switchpic();
      } else { setTimeout(so_xfade,100); }
    }
  } // so_fade

  function setOpacity(obj) {
    if (obj.xOpacity >= 1) { obj.xOpacity = 1; }
    if (obj.xOpacity <= 0) { obj.xOpacity = 0; }
    obj.style.opacity = obj.xOpacity;
    obj.style.MozOpacity = obj.xOpacity;
    obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
  }

  function existsID(e) { if (gbID(e) == undefined) { return false; } else { return true; } }
  function showID(e) { if (existsID(e)) { gbID(e).style.display = ''; } }
  function hideID(e) { if (existsID(e)) { gbID(e).style.display = 'none'; } }
  function gbID(e) { if ((e == "") || e == null) { return undefined; } else { return document.getElementById(e); } }

