jquery.couch: fix document copying

To COPY a doc the client must specify the target doc id in Destination
header. Additionally, it may add the revision parameter if document
already exists and we want to copy over it.
diff --git a/script/jquery.couch.js b/script/jquery.couch.js
index ffbad34..21b151e 100644
--- a/script/jquery.couch.js
+++ b/script/jquery.couch.js
@@ -734,6 +734,16 @@
          */
         copyDoc: function(docId, options, ajaxOptions) {
           ajaxOptions = $.extend(ajaxOptions, {
+            beforeSend: function(XMLHttpRequest) {
+              if (!options || !options.docid) {
+                  throw "Target docid required";
+              }
+              var header = options.docid;
+              if (options.rev) {
+                  header += '?rev=' + options.rev
+              }
+              XMLHttpRequest.setRequestHeader("Destination", header);
+            },
             complete: function(req) {
               var resp = $.parseJSON(req.responseText);
               if (req.status == 201) {