// xGetElementById r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xGetElementById(e)
{
  if (typeof(e) == 'string') {
    if (document.getElementById) e = document.getElementById(e);
    else if (document.all) e = document.all[e];
    else e = null;
  }
  return e;
}


/* ***** Begin ***************************************************** */
function fadeObject(id, c1, c2, s1, s2) {
  var self = this;
  this.id      = id;
  this.elem    = false;
  this.colour  = {
    stt: [parseInt(c1.substr(0, 2), 16), parseInt(c1.substr(2, 2), 16), parseInt(c1.substr(4, 2), 16)],
    end: [parseInt(c2.substr(0, 2), 16), parseInt(c2.substr(2, 2), 16), parseInt(c2.substr(4, 2), 16)],
    now: [parseInt(c1.substr(0, 2), 16), parseInt(c1.substr(2, 2), 16), parseInt(c1.substr(4, 2), 16)]
  };
  this.steps   = [s1, s2];
  this.dir     = false;
  this.active  = false;
  this.queue   = [];
  this.msg     = [];
  this.message = 0;
  function d2h(num) {
    num = Math.round(num);
    return ((num < 16) ? "0" : "") + num.toString(16);
  }
  this.fade = function(message, direction) {
    this.elem = xGetElementById(this.id);
	//alert(this.elem);
    this.queue.push([message, direction]);
    for (var x = 0; x < this.queue.length; x++) {
      for (var y = x + 1; y < this.queue.length; y++) {
        if (this.queue[x][0] == this.queue[y][0] && this.queue[x][1] != this.queue[y][1]) {
          this.queue.splice(x, 1);
          this.queue.splice(y - 1, 1);
        }
      }
    }
    if (!this.active) setTimeout(function() { self.fadeLoop(); }, 10);
  };
  this.fadeLoop = function() {
    if (!this.active && this.queue.length) {
      if (this.dir && this.message != this.queue[0][0]) this.queue.unshift([this.message, false]);
      var msg = this.queue.shift();
      if (this.msg[msg[0]]) {
        this.active = true;
        this.elem.innerHTML = this.msg[this.message = msg[0]];
        this.dir = msg[1];
      }
    }
    if (this.dir) {
      var c1 = this.colour.stt, c2 = this.colour.end, s = this.steps[0];
    } else var c1 = this.colour.end, c2 = this.colour.stt, s = this.steps[1];
    for (var x = 0, cnow = "", inc = 0; x < 3; x++) {
      this.colour.now[x] += inc = (c2[x] - c1[x]) / s;
      cnow += this.colour.now[x] = (inc < 0) ? Math.max(this.colour.now[x], c2[x]) : Math.min(this.colour.now[x], c2[x]);
    } this.elem.style.color = "#" + d2h(this.colour.now[0]) + d2h(this.colour.now[1]) + d2h(this.colour.now[2]);
    if (cnow == c2.join("")) {
      this.active = false;
      if (!this.queue.length) {
        if (!this.dir) {
          if (this.msg[0]) {
            this.queue.push([0, true]);
            setTimeout(function() { self.fadeLoop(); }, 10);
          } else this.elem.innerHTML = "&nbsp;";
        }
      } else setTimeout(function() { self.fadeLoop(); }, 10);
    } else setTimeout(function() { self.fadeLoop(); }, 10);
  };
  if (window.addEventListener) {
    window.addEventListener('load', function() { self.fade(0, true); }, false); 
  } else if (window.attachEvent)
    window.attachEvent('onload', function() { self.fade(0, true); });
}
/* ***** End ******************************************************* */

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 : 5000);

  // 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;
}

fader[0] = new fadeObject('testimonialFader', 'bbbbbb', '646464', 30, 30);
fader[0].msg[4] = "It is exciting to actually apply the principles of learning and games we detailed in our book \"Got Game.\" Our research shows that those who grew up playing video games have the potential to learn better and faster through games than other media. Hats off to Aeshen for helping us make our concept come to life.<BR/>  			<div style='font-size:12px; margin-left:25px; text-align:right;'>&bull; John Beck, President<BR>North Star Leadership Group</div>";
fader[0].msg[1] = "Aeshen has created several compelling Webcast series for us that educate users on how to use products in a zero to hero format. These webcasts have been viewed by 100,000 people over the last year and our customers have rated them very highly.<BR/>            			<div style='font-size:12px; margin-left:25px; text-align:right;'>&bull; Alan Le Marquand<BR>Technical Product Manager</div>";
fader[0].msg[2] = "Microsoft products are supported by high quality technical presentations designed to explain technical solutions and increase adoption. These presentations are taken directly to the customer, and are viewed by an estimated 200,000 customers monthly.  Aeshen makes the presenter's job easier by creating high-quality, compelling PowerPoint decks and fully scripted demonstrations that allow our team of presenters to focus on the delivery of the presentation.<BR>                			<div style='font-size:12px; margin-left:25px; text-align:right;'>&bull; Alan Le Marquand<BR>Technical Product Manager</div>";
fader[0].msg[3] = "To fulfill many of our content needs, we have called upon, and come to rely on, the depth, breadth, and consistency of the collaborative offerings provided by Aeshen. I&nbsp;can willingly attest to and highly recommend Aeshen.<BR />							<div style='font-size:12px; margin-left:25px; text-align:right;'>&bull; Roger Herrick, Strategist<BR>Intel Corporation</div>";
fader[0].msg[0] = "Aeshen has consistently delivered on its promise to produce high quality training that's relevant for today's developers. During 2003 and 2004, Aeshen created over ten days of technical training on Windows Server 2003, Smart Client, and .NET Connected (i.e., server- or client-side Web service solutions on the .NET Framework). That training included comprehensive demos and hands-on labs, as well as modules on real-life scenarios and software architecture. It is now being used to train over 6,000 developers in 25 countries around the world.<BR />                			<div style='font-size:12px; text-align:right;'>&bull; Stephen Lo, Developer & Platform Evangelism<BR>Microsoft Corporation</div>";

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