An modified version from http://duilib.googlecode.com/svn/