Rewrite as jQuery plugin, new namings etc.