function rotateText(el, textGroup) {
  setOpacity(el, 0);
  var t = rotateText.texts[textGroup];
  var t = t[Math.floor(Math.random() * (t.length - 1))];
  el.innerHTML = t;
  unfadeText(el, textGroup);
}
rotateText.texts = {
  quotes: [
    "<img src='/wp-content/themes/custom/images/postquote.png'>The PSM team is self-driven and possesses a strong ability to lead our marketing efforts.",
    "<img src='/wp-content/themes/custom/images/postquote.png'>PSM knows the intricacies of the legal industry and how to market it.",
    "<img src='/wp-content/themes/custom/images/postquote.png'>We have truly valued your creative ideas, insight into the market, and ability to motivate and organize people.",
    "<img src='/wp-content/themes/custom/images/postquote.png'>PSM has the creative ideas and the ability to motivate others to carry out those ideas.",
    "<img src='/wp-content/themes/custom/images/postquote.png'>PSM helped me frame a short and concise summary of my practice that has been well received by clients and prospects.",
    "<img src='/wp-content/themes/custom/images/postquote.png'>You were able to identify new areas/ways of looking at things and the final product was very well received by our clients."
  ],
  authors: [
    "President, Technology Consulting Firm <img style='float:right; margin-top:-5px;' src='/wp-content/themes/custom/images/postquote-end.png'>",
    "Partner, Minneapolis Law Firm <img style='float:right; margin-top:-5px;' src='/wp-content/themes/custom/images/postquote-end.png'>",
    "Partner, Minneapolis Law Firm <img style='float:right; margin-top:-5px;' src='/wp-content/themes/custom/images/postquote-end.png'>",
    "Association Executive <img style='float:right; margin-top:-5px;' src='/wp-content/themes/custom/images/postquote-end.png'>",
    "Partner, Minneapolis Law Firm <img style='float:right; margin-top:-5px;' src='/wp-content/themes/custom/images/postquote-end.png'>",
	"President, Benefits Consulting Firm <img style='float:right; margin-top:-5px;' src='/wp-content/themes/custom/images/postquote-end.png'>"
  ],
};

function setOpacity(el, value) {
  el.style.opacity = value / 100;
  el.style.filter = "alpha(opacity=" + value + ")";
}

function unfadeText(el, tg) {
  var v = el.style.opacity * 100 + 1;
  if(v > 100) {
    setOpacity(el, 100);
    setTimeout(bundleFunction(null, fadeText, [el, tg]), 5000);
    return;
  }
  setOpacity(el, v);
  setTimeout(bundleFunction(null, unfadeText, [el, tg]), 10);
}

function fadeText(el, tg) {
  var v = el.style.opacity * 100 - 1;
  if(v < 0) {
    setOpacity(el, 0);
    rotateText(el, tg);
    //or... setTimeout(bundleFunction(null, rotateText, [el, tg]), NUMBER);
    return;
  }
  setOpacity(el, v);
  setTimeout(bundleFunction(null, fadeText, [el, tg]), 10);
}

function bundleFunction(context, func, args) {
  context = context || null;
  if(typeof func == "string" && context)
    func = context[func];
  if(!args)
    args = [];
  else if(!(args instanceof Array))
    args = [args];
  return function() {
    return func.apply(context, args);
  };
}
