/* ***** 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 = this.elem || document.getElementById(this.id);
    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 ******************************************************* */




/* *****
 * User defined fade objects and messages
 */
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] = 0;


  // 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 : 15000);

  // 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[2] = new fadeObject('fade2', 'a9d500', 'ffffff', 50, 50);
  

  fader[2].msg[0] = "\"Greenfrog has a team of true professionals with incredible creative talent and pro-active client services. They can be trusted to consistently deliver on-target creative within deadlines and budget.\"<br /><br />ALEX MAGER, CLUB MED NORTH AMERICA";
  fader[2].msg[1] = "\"Greenfrog & Associates has played an instrumental role in marketing efforts to our network of business communities. Their creative work in the different advertising and graphic areas is not only creatively outstanding but also right on target with our audiences. Greenfrog & Associates has helped us reach our goals and will continue to play a role in our future growth. \"<br /><br />MICHAEL M. ADLER, ADLER GROUP, INC.";
  fader[2].msg[2] = "\"Greenfrog is the most creative organization that we have dealt with. Their ideas are excellent and their follow-up is superb. They have uncovered very qualified opportunities for us. There are very few companies out there that can provide the value package that Greenfrog offers with such a sincere concern for its clients' success. \"<br /><br />FRED BOMENY, LIFEXPAND INC.";
  fader[2].msg[3] =  "\"While everyone talks about Greenfrog's creativity, we would like to commend the people behind Greenfrog: Liliane Rique and staff always go the extra mile to accommodate us and are always very hands on and available, no matter the challenge. They're not only true professionals, they're genuine individuals. \"<br /><br />MAY CASTRO, GROVES PROPERTIES, INC.";
  fader[2].msg[4] = "\"Greenfrog & Associates successfully tackles all aspects of my company's marketing and advertising, consistently preserving the highest standard of work and creativity for our residential and commercial developments. They are always on point and respond quickly to changing market trends. \"<br /><br />OSCAR ROGER, ROGER DEVELOPMENT GROUP, INC.";
  fader[2].msg[5] = "\"Greenfrog is responsible for all the advertising and branding for our various entities. They have been able to take our vision and translate it into print, web and graphic content in a most amazing manner. This has been the best work I have had done in over 20 years as a serial entrepreneur. \"<br /><br />ROBERT L. ADDIE, ADDIEWELL INVESTMENTS, INC.";
  fader[2].msg[6] = "\"Greenfrog: on-target creative, efficient production and outstanding client service every time \"<br /><br />RODOLPHE LE GRAND, LES NOUVELLES ESTHÉTIQUES, AMERICAN EDITION";
  fader[2].msg[7] = "\"Awesome! You do such good work…\"<br /><br />TERRI KENNEDY, SHOW MANAGEMENT";


// Start this fader
setTimeout(function() { throb(2); }, 1000);

