- JsHttpRequest.request= function(submit) {
- var url = window.location.toString();
- url = url.substring(0, url.indexOf('?'));
+// Main functions for asynchronus form submitions
+// Trigger is the source of request and can have following forms:
+// - input object - all form values are also submited
+// - arbitrary string - POST var trigger with value 1 is added to request;
+// if form parameter exists also form values are submited, otherwise
+// request is directed to current location
+//
+ JsHttpRequest.request= function(trigger, form) {
+
+
+ var submitObj = typeof(trigger) == "string" ?
+ document.getElementsByName(trigger)[0] : trigger;
+
+ form = form || (submitObj && submitObj.form);
+
+ var url = form ? form.action :
+ window.location.toString();
+
+ if (!form) url = url.substring(0, url.indexOf('?'));
+
+ var values = this.formValues(trigger, form);
+ if (!submitObj)
+ values[trigger] = 1;
+ // this is to avoid caching problems
+ values['_random'] = Math.random()*1234567;