if (document.getElementById && document.createElement  && imgObjArray.length)
{
  var idx = 0  
  var globaltimeout 
  function setImage()
    {
      for (var i = 0; i < ctrlArray.length; i++) {ctrlArray[i].className = ''}
      
      mainimage.src =  imagepath + this.imgObj.imgsrc
      mainimage.setAttribute('alt',this.imgObj.alt)
      mainimage.setAttribute('title',this.imgObj.title)
      
      var targetLink = mainimage.parentNode
      if (this.imgObj.href != '')
        {
          targetLink.href = this.imgObj.href
          targetLink.onclick = function(){window.location = this.href}
          targetLink.className = 'pointerhand'
        }
      else
        {
          targetLink.href = null;
          targetLink.onclick = null;
          targetLink.className = 'nonpointer';
        }
        
      idx = this.idx
      this.className = 'curImg' ;
      clearTimeout(globaltimeout)
      //globaltimeout = setTimeout(stepThru,8000) 
      //alert(this.imgObj.toFullString())          
    }
  
  var container = document.getElementById('outercontainer')
  var mainimage = document.getElementById('mainimg')
  var ctrlArray = new Array();
  
  var controller = document.createElement('DIV')        
  controller.setAttribute('id','controller')
  container.appendChild(controller)
  
  var controlBG = document.createElement('DIV')        
  controlBG.setAttribute('id','controllerBG')
  container.appendChild(controlBG)
  
  container.appendChild(controller)
  var lk,lkTxt,thispath,imgObj
  for (i=0,j=1; i < imgObjArray.length; i++,j++)
    {
      imgObj = imgObjArray[i]
      lk = document.createElement('A')
      lkTxt = document.createTextNode(j)
      lk.appendChild(lkTxt);
      lk.setAttribute('title',imgObj.title);
      lk.imgObj = imgObj
      lk.onclick = setImage
      lk.idx = i
      controller.appendChild(lk)
      ctrlArray[ctrlArray.length] = lk
    }
  
  function pickRandom()
    {
      idx = Math.floor(imgObjArray.length * Math.random())
      ctrlArray[idx].onclick()
      globaltimeout = setTimeout(stepThru,8000)            
    }
    
  function stepThru()
    {
      idx++
      if (idx == imgObjArray.length) {idx = 0}
      ctrlArray[idx].onclick() 
      globaltimeout = setTimeout(stepThru,8000)
    }
  window.onload = pickRandom
}

function enumerateProperties()
  {
    var pString = this + '\n\nProperties:\n---------------\n';
    for (property in this)
      {
        if (typeof this[property] == 'function') 
          {
            {pString += property + ': (function)\n';}
          }
        else
        
          {pString += property + ': ' + this[property] + '\t\t\tType: ' + typeof this[property] + '\n';}
      }
    return pString
  }
  Object.prototype.toFullString = enumerateProperties