added tablesorter plugin

* added tablesorter jquery plugin with pagination
* added jquery migration plugin to support tablesorter
* moved database code to class in database.php