+// 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, tout) {
+// if (trigger.type=='submit' && !validate(trigger)) return false;
+ tout = tout || 10000; // default timeout value
+ document.getElementById('msgbox').innerHTML='';
+ set_mark(tout>10000 ? 'progressbar.gif' : 'ajax-loader.gif');
+ JsHttpRequest._request(trigger, form, tout, 0);
+};
+
+JsHttpRequest._request = function(trigger, form, tout, retry) {
+ if (trigger.tagName=='A') {
+ var content = {};
+ var upload = 0;
+ var url = trigger.href;
+ if (trigger.id) content[trigger.id] = 1;
+ } else {
+ var submitObj = typeof(trigger) == "string" ?
+ document.getElementsByName(trigger)[0] : trigger;
+
+ form = form || (submitObj && submitObj.form);
+
+ var upload = form && form.enctype=='multipart/form-data';
+
+ var url = form ? form.getAttribute('action') :
+ window.location.toString();
+
+ var content = this.formInputs(trigger, form, upload);
+
+ if (!form) url = url.substring(0, url.indexOf('?'));
+
+ if (!submitObj) {
+ content[trigger] = 1;
+ }
+ }
+ // this is to avoid caching problems
+ content['_random'] = Math.random()*1234567;
+
+ var tcheck = setTimeout(
+ function() {
+ for(var id in JsHttpRequest.PENDING) {
+ var call = JsHttpRequest.PENDING[id];
+ if (call != false) {
+ if (call._ldObj.xr) // needed for gecko
+ call._ldObj.xr.onreadystatechange = function(){};
+ call.abort(); // why this doesn't kill request in firebug?
+// call._ldObj.xr.abort();
+ delete JsHttpRequest.PENDING[id];
+ }
+ }
+ set_mark(retry ? 'ajax-loader2.gif':'warning.png' );
+ if(retry)
+ JsHttpRequest._request(trigger, form, tout, retry-1);
+ }, tout );