var KeyWords = "C++, WPF, .NET, Java, Applications, SQL Server, C#, perl, MySQL, ASP.NET, WCF, Webservices, SOAP, PHP, JSF, JBoss, JSP, Oracle, AJAX, GWT, J2SE, XML, XSLT, DMS, XSL-FO, XUI, PDF, Arbortext, OpenGL, DirectX";

function animBoxInit(boxElement) {
  // var Colors = new Array("#3300FF", "#009933", "#990000");
  var Colors = new Array("#98C5FF", "#FFBCD1", "#94FF9A", "#FFB298", "#CC9933");
  KeyWords = KeyWords.split(", ");
  for (i = 0; i < KeyWords.length; i++)
    boxElement.innerHTML += '<span class="animboxkeyword">' + KeyWords[i] + '</span>';
  KeyWords = boxElement.getElementsByTagName("span");
  var ys = (boxElement.offsetHeight) / (KeyWords.length + 2);
  for ( var i = 0; i < KeyWords.length; i++) {
    with (KeyWords[i]) {
      style.color = Colors[i % Colors.length];
      var x = (Math.pow(Math.random(), 2)) * (i % 2 * 2 - 1); // -1 ... 1
      x = (x + 1) / 2 * (boxElement.offsetWidth - offsetWidth) + (offsetWidth / 2);
      KeyWords[i]._cx = x;
      KeyWords[i]._cy = (i + 1) * ys;
      setOpacity(KeyWords[i], 0);
      animBoxCenter(KeyWords[i]);
    }
  }
  disableSelection(boxElement.parentNode);
  setTimeout('animBoxTimer()', 1);
}

function animBoxCenter(obj) {
  obj.style.left = Math.floor(obj._cx - obj.offsetWidth / 2) + "px";
  obj.style.top = Math.floor(obj._cy - obj.offsetHeight / 2) + "px";
}

function animBoxTimer() {
  if (!animBoxTimer.cnt)
    animBoxTimer.cnt = 0;
  animBoxTimer.cnt += 2;
  for (i = 0; i < KeyWords.length; i++) {
    var c = (animBoxTimer.cnt + 137 * i) % 400; // 0 - 399
    if (c > 199)
      c = 0;
    else
      c = c <= 100 ? (c / 100.0) : ((200 - c) / 100.0);
    setOpacity(KeyWords[i], c);
  }
  setTimeout('animBoxTimer()', 60);
}

function setOpacity(e, v) {
  e.style.opacity = v;
  e.style.filter = "alpha(opacity=" + (v * 100.0) + ")";
}

function disableSelection(e) {
  with (e) {
    if (typeof onselectstart != "undefined")
      onselectstart = function() {
        return false
      };
    if (typeof style.MozUserSelect != "undefined")
      style.MozUserSelect = "none";
    if (typeof onmousedown != "undefined")
      onmousedown = function() {
        return false
      };
    style.cursor = "default"
  }
}
