function spot (element, destination) {
  // specify destination as #{name} or #{id} only if element not <A>

  var match, destId, destElements, destElement

  if (!destination && !element.href) return

  // a specified destination overrides elements href

  if (!destination)
    destination = element.href

  match = destination.match ( /#(.+?)$/ )

  if (!match) return

  destId = match [1];

  destElement = document.getElementById (destId)

  if (!destElement) {
    destElements = document.getElementsByName (destId)
    if (destElements && destElements.length>0)
      destElement = destElements[0]
  }

  if (!destElement) return

  if (destElement.transition)
    destElement.transition.doStop()

  destElement.style.backgroundColor = spot.onColor
  destElement.transition = new spot.transition (destElement, 40, 1000)

  destElement = null
}

spot.onColor = '#DDDD99'
spot.onColor = '#FF3333'
spot.offColor ='#FFFFFF'

spot.transition = function (obj, steps, duration) {
  this.obj = obj
  this.from = spot.onColor.substr(1)
  this.to = spot.offColor.substr(1)
  this.steps = steps
  this.interval = duration / steps;
  this.step = 0

  var thisObj = this
  this.timerId = setInterval ( function () { thisObj.doStep () }, this.interval )

}

spot.transition.prototype.doStop = function ()
{
  clearInterval (this.timerId)
  this.obj.transition = null
  this.obj = null
}

spot.transition.prototype.doStep = function () {
  var from  = this.from
  var   to  = this.to
  var step  = this.step
  var steps = this.steps

  var r0 = parseInt (from.substr(0,2),16)  // base 16
  var g0 = parseInt (from.substr(2,2),16)
  var b0 = parseInt (from.substr(4,2),16)

  var r1 = parseInt (  to.substr(0,2),16)
  var g1 = parseInt (  to.substr(2,2),16)
  var b1 = parseInt (  to.substr(4,2),16)

  var r = Math.floor (r0 * ((steps-step)/steps) + r1 * (step/steps))
  var g = Math.floor (g0 * ((steps-step)/steps) + g1 * (step/steps))
  var b = Math.floor (b0 * ((steps-step)/steps) + b1 * (step/steps))

  this.obj.style.backgroundColor = 'rgb('+r+','+g+','+b+')'

  this.step ++

  if ( this.step > this.steps )
    this.doStop()
}





function setAClickHandlers() {
	var tags, i, node, re

	re = /#(.+?)$/

	if (document.getElementsByTagName) {
		tags = document.getElementsByTagName('A')
		for (i=0; i<tags.length; i++) {
			element = tags[i]
			if (element.href && element.href.match ( re ) ) {
				element.onclick = function () { spot (this) }
			}
		}
	}
}





function setImgClickHandlers() {
	var tags, i, element, re

	re = /minus.png$/

	if (document.getElementsByTagName) {
		tags = document.getElementsByTagName('IMG')
		for (i=0; i<tags.length; i++) {
			element = tags[i]
			element.alt = "Click to collapse"
			if (element.src && element.src.match ( re ) )
				element.onclick = function () { toggle (this) }
    }
  }
}

function toggle (element) {
  var id, contentElement, mode

  if (!document.getElementById) return

  id = element.parentNode.id.replace(/_H/,"_DIV")
  contentElement = document.getElementById (id)

  if (!contentElement) return

  mode = (contentElement.style.display == "none") ? "block" : "none"

  contentElement.style.display = mode

  if (mode == "none") {
    element.src = "plus.png"
    element.alt = "Click to expand"
  }
  else {
    element.src = "minus.png"
    element.alt = "Click to collapse"
  }
}




function sesug03init() {
	setAClickHandlers()
  setImgClickHandlers()
}