Update xlayout.js

fixed more bugs and also converted into an object and jquery plugin.