
// Slider - slide div to right, change images and slide back to left

var autointerval = 5000				// delay (in milliseconds) between slides
var slidedelay = 40				// delay (in milliseconds) between slide iterations
var slideincr = 20				// number of px to slide each iteration
var size = 287					// width of sliding image
var limitr = 1000				// max right offset (i.e. right offset when fully visible)
var limitl = limitr - size			// min left offset (i.e. left offset when fully visible)
var movernum = 0				// feature/burst number
var moverlim = 4				// total number of features/bursts
var opacityincr = 0.1				// amount to increase burst opacity
var opacitydelay = 40				// delay (in illiseconds) between opacity changes
var moverid = 'mover'				// div to be moved
var staticid = 'static'				// div to contain background static feature 
var uburstid = 'uburst'				// div to show upper sunburst
var lburstid = 'lburst'				// div to show lower sunburst
var t1, t2, t3

var burst = new Array()
burst[0] = '/images/home/'
burst[1] = '1-orange-burst.gif'
burst[2] = '2-dark-blue-burst.gif'
burst[3] = '3-light-blue-burst.gif'
burst[4] = '4-gray-burst.gif'

var slider = new Array()
slider[0] = '/images/home/'
slider[1] = '1-orange-feature.gif'
slider[2] = '2-dark-blue-feature.gif'
slider[3] = '3-light-blue-feature.gif'
slider[4] = '4-gray-feature.gif'

var link = new Array()
link[0] = ''
link[1] = '/news.php?#news41'
link[2] = '/reasons_to_give.php'
link[3] = '/mitochondrial_dysfunction_and_familiar_diseases.php'
link[4] = '/foundation.php'

var title = new Array()
title[0] = ''
//title[1] = 'Save this Date. Attend the Foundation for Mitochondrial Medicine’s Hope Flies Catch the Cure Atlanta, November 5.'
//title[1] = 'Global Mitochondrial Disease Awareness Week September 18-24, 2011 - various educational, fundraising and advocacy events to increase awareness of mitochondrial disease.'
//title[1] = 'The Hope Flies Catch the Cure Special Appeal is a call to specifically fund patients for a functional brain MRI study at the Georgia State and Georgia Tech Joint Center of Advanced Brain Imaging.'
//title[1] = 'The Hope Flies Catch the Cure Special Appeal is a call to specifically fund patients for a functional brain MRI study.'
//title[1] = 'Son of Braves GM Wren battles mitochondrial disease and shares his story and involvement in Hope Flies Catch the Cure.'
title[1] = 'FMM Awards $50,000 Grant to Leading Netherlands Research Team.'
title[2] = 'Funding the Cures. We focus on accelerating the development of the most viable mitochondrial disease treatments and therapies.'
title[3] = 'Fueling Connections. Every day we’re learning how a cure for mitochondrial disease could impact more well known diseases.'
title[4] = 'Leading the Way. We’re supporting the first steps approved by the FDA to investigate mitochondrial disease treatments.'

function slide(e)
{ if (!e) var e = window.event;
  e.cancelBubble = true;
  if (e.stopPropagation) e.stopPropagation();
  clearInterval(autoslide)
  switcheroo() //start the sliding
}

function switcheroo()
{ statik.style.backgroundImage = 'url(' + slider[0] + slider[movernum] + ')' //set current image as bg
  mover.style.left = limitr + "px"		// reset width and offset of sliding image
  mover.style.width = 0
  movernum++					// point to new image
  if (movernum > moverlim) movernum = 1
  mover.style.backgroundImage = 'url(' + slider[0] + slider[movernum] + ')'
  mover.title = title[movernum]
  t1 = setTimeout("slideleft()",slidedelay)	// start sliding new image left over the bg image set above

  uburster.style.opacity = 0			// swap burst image and make transparent
  if (uburster.filters) {uburster.filters.alpha.opacity = 0}
  uburster.style.backgroundImage = 'url(' + burst[0] + burst[movernum] + ')'
  t2 = setTimeout("increaseopacity()",20)		// start increasing opacity of burst
}

function slideleft()
{ var left, width
  left = mover.offsetLeft - slideincr
  if (left > limitr) left = limitr
  if (left < limitl) left = limitl
  mover.style.left = left + "px"
  width = mover.offsetWidth + slideincr
  if (width > size) width = size
  mover.style.width = width + 'px'
  //alert('width: ' + mover.offsetWidth +'\nleft: ' + mover.offsetLeft)
  if (width < size) t1 = setTimeout("slideleft()",slidedelay)
  else startflash()
}

function increaseopacity()
{ var opacity, filter
  opacity = uburster.style.opacity
  opacity = parseFloat(opacity) + parseFloat(opacityincr)
  if (opacity > 1) opacity = 1
  filter = opacity * 100
  uburster.style.opacity = opacity
  if (uburster.filters) {uburster.filters.alpha.opacity = filter}
  if (opacity < 1) t3 = setTimeout("increaseopacity()",opacitydelay)
} 

function startflash()
{ flasher.style.display = 'block'
  setTimeout("endflash()",10)
}

function endflash()
{  flasher.style.display = 'none'}

function arrow(e)
{ if (!e) var e = window.event;
  e.cancelBubble = true;
  if (e.stopPropagation) e.stopPropagation();
  clearInterval(autoslide)
  location.href = link[movernum]
}
