Moved code to a jquery plugin and added parameters.