var qinit = 1500, qwait = 6500, qfadefreq = 35, qfadeincr = .2, qtimer, qno

function quotefade(q)
{ if (isNaN(q) || q > qmax) { qno = 1 }else{ qno = q }
  document.getElementById('home_quotes').style.backgroundImage = 'url(../images/home/quotebg' + qno + '.jpg)'
  obj = document.getElementById("home_story_" + qno)
  obj.style.display = "block"
  obj = document.getElementById("home_quote_" + qno)
  obj.style.opacity = 0
  if (obj.filters) { obj.filters.alpha.opacity = 0 }
  obj = document.getElementById("home_tagline_" + qno)
  obj.style.opacity = 0
  if (obj.filters) { obj.filters.alpha.opacity = 0 }
  qtimer = window.setTimeout(qfadeinquote, qinit)
}

function qfadeinquote()
{ var obj, opac
  obj = document.getElementById("home_quote_" + qno)
  opac = parseFloat(obj.style.opacity) + parseFloat(qfadeincr)
  obj.style.opacity = opac
  if (obj.filters) { obj.filters.alpha.opacity = (opac * 100) }
  if (obj.style.opacity < 1) { qtimer = window.setTimeout(qfadeinquote, qfadefreq) }
  else { qtimer = window.setTimeout(qfadetotag, qwait) }
}

function qfadetotag()
{ var obj, opac
  obj = document.getElementById("home_quote_" + qno)
  opac = parseFloat(obj.style.opacity) - parseFloat(qfadeincr)
  obj.style.opacity = opac
  if (obj.filters) { obj.filters.alpha.opacity = (opac * 100) }
  obj = document.getElementById("home_tagline_" + qno)
  opac = parseFloat(obj.style.opacity) + parseFloat(qfadeincr)
  obj.style.opacity = opac
  if (obj.filters) { obj.filters.alpha.opacity = (opac * 100) }
  if (obj.style.opacity < 1) { qtimer = window.setTimeout(qfadetotag, qfadefreq) }
}

function nextquote ()
{ window.clearTimeout(qtimer)
  obj = document.getElementById("home_quote_" + qno)	// hide current quote/tagline image
  obj.style.opacity = 0
  if (obj.filters) { obj.filters.alpha.opacity = 0 }
  obj = document.getElementById("home_tagline_" + qno)
  obj.style.opacity = 0
  if (obj.filters) { obj.filters.alpha.opacity = 0 }
  obj = document.getElementById("home_story_" + qno)
  obj.style.display = "none"
 qno++							// increment quote number and start fade process
  quotefade(qno)
}