/**
 * RUZEE.Ellisis 0.1
 * (c) 2007 Steffen Rusitschka
 *
 * RUZEE.Ellipsis is freely distributable under the terms of an MIT-style license.
 * For details, see http://www.ruzee.com/
 *
 * Heavily modified for use on this web site by David Herman
 * Don't copy this script - rather go and get the original
 */

(function() {

  function ellipsis(e) {

    var w = e.getWidth(); // - 10000;
    var t = e.innerHTML;

    e.innerHTML = "<span>" + t + "</span>";
    e = e.down();

    while (t.length > 0 && e.getWidth() >= w) {
      t = t.substr(0, t.length - 1);
      e.innerHTML = t + "...";
    }

	id = e.up().previous();

	if (e.innerHTML.indexOf(' x ') >= 0)
		e.innerHTML = e.innerHTML.substr(0, e.innerHTML.indexOf(' x ') + 3) + '<a href="' + id.innerHTML + '">' + e.innerHTML.substr(e.innerHTML.indexOf(' x ') + 3) + '</a>';
  }

  document.write('<style type="text/css">' + '.ellipsis { margin-right:-10000px; }</style>');
  Event.observe(window, "load", function() { $$('.ellipsis').each(ellipsis); });

})();
