+ /**
+ * Helper function to rewrite default HTTP form action URLs to HTTPS
+ * so we can actually fetch them when on an SSL page in ssl=sometimes
+ * mode.
+ *
+ * It would be better to output URLs that didn't hardcode protocol
+ * and hostname in the first place...
+ *
+ * @param {String} url
+ * @return string
+ */
+ RewriteAjaxAction: function(url) {
+ // Quick hack: rewrite AJAX submits to HTTPS if they'd fail otherwise.
+ if (document.location.protocol == 'https:' && url.substr(0, 5) == 'http:') {
+ return url.replace(/^http:\/\/[^:\/]+/, 'https://' + document.location.host);
+ } else {
+ return url;
+ }
+ },
+
+ /**
+ * Grabs form data and submits it asynchronously, with 'ajax=1'
+ * parameter added to the rest.
+ *
+ * If a successful response includes another form, that form
+ * will be extracted and copied in, replacing the original form.
+ * If there's no form, the first paragraph will be used.
+ *
+ * @fixme can sometimes explode confusingly if returnd data is bogus
+ * @fixme error handling is pretty vague
+ * @fixme can't submit file uploads
+ *
+ * @param {jQuery} form: jQuery object whose first element is a form
+ *
+ * @access public
+ */