refactor jquery.couch.js, gets rid of a lot of duplicate code, patch by Yoan Blanc, closes COUCHDB-368