// JavaScript Document
var fader = new Array();

var hash = new Array();
function throb(item) {

  // If the hash array does not have an entry for this item, initialise it at 2
  if (!hash[item]) hash[item] = 2;

  // Send a fade command, using the hash array to tell us what parameters we should use
  fader[item].fade(Math.floor(hash[item] / 2), !(hash[item] % 2));

  // Call this function again for this same item after a certain amount of time
  setTimeout(function() { throb(item); }, (hash[item] % 2) ? 100 : 6000);

  // If we have exceeded the number of messages in this fader, start over again at 2
  if (++hash[item] > fader[item].msg.length * 2 - 1) hash[item] = 2;
}

function newquote(item) {

  // If the hash array does not have an entry for this item, initialise it at 2
  if (!hash[item]) hash[item] = 2;

  // Send a fade command, using the hash array to tell us what parameters we should use
  fader[item].fade(Math.floor(hash[item] / 2), !(hash[item] % 2));

  // Call this function again for this same item after a certain amount of time
  setTimeout(function() { newquote(item); }, (hash[item] % 2) ? 100 : 150000000);

  // If we have exceeded the number of messages in this fader, start over again at 2
  if (++hash[item] > fader[item].msg.length * 2 - 1) hash[item] = 2;
}

function next(item) {
	if (!hash[item]) hash[item] = 2;
	
	//fade out
	fader[item].fade(Math.floor(hash[item] / 2), !(hash[item] % 2));
	if (++hash[item] > fader[item].msg.length * 2 - 1) hash[item] = 2;
	
	//fade in
	fader[item].fade(Math.floor(hash[item] / 2), !(hash[item] % 2));
	if (++hash[item] > fader[item].msg.length * 2 - 1) hash[item] = 2;
}

function back(item) {
	if (!hash[item]) hash[item] = 2;
	
	//fade out
	fader[item].fade(Math.floor(hash[item] / 2) - 1, (hash[item] % 2));
	if (--hash[item] <= 2) hash[item] = fader[item].msg.length * 2;
	
	//fade in
	fader[item].fade(Math.floor(hash[item] / 2) - 1, !(hash[item] % 2));
	if (--hash[item] <= 2) hash[item] = fader[item].msg.length * 2;
}




fader[0] = new fadeObject('ticker', 'f7f7f7', '23589e', 30, 30);
fader[0].msg[0] = 'DLC creators win MacArthur Foundation Young Innovator award. (<a href="http://www.dmlcompetition.net/winnerDetail.php?x=ddc" target="_blank">more...</a>)';
fader[0].msg[1] = 'DLC creators win MacArthur Foundation Young Innovator award. (<a href="http://www.dmlcompetition.net/winnerDetail.php?x=ddc" target="_blank">more...</a>)';
fader[0].msg[2] = 'John Seely Brown endorses the DLC. (<a href="http://www.youtube.com/watch?v=jNwCGWXK6YU#t=32m45s" target="_blank">more...</a>)';
fader[0].msg[3] = 'Brown University Library endorses DLC with poster at ACRL.';
fader[0].msg[4] = 'Miami University to host DLC in spring 2010';
fader[0].msg[5] = 'Hanover College to host DLC in spring 2010';
fader[0].msg[6] = 'Purdue University to host DLC in spring 2010';

// Start this fader
setTimeout(function() { throb(0); }, 1000);