Sometimes you have strings that must fit within a certain pixel width. This function attempts to do so efficiently. Please post your suggestions or refactorings below :)
Luckily, CSS3 text-overflow should eventually take care of that.
If anyone is using ASP.NET and is interested in a server-side solution, check this blog post:
http://waldev.blogspot.com/2010/09/truncate-text-string-aspnet-fit-width.html