
function httpRequestForm(formId){
    var f = document.getElementById(formId)
    if(!f){
      alert('Form ID:' + formId + ' not fount!');
      return false;
    }
    var qs = "?" + create_request_string(f);
//    alert(qs);
//    return false;
    
    var url = f.getAttribute('url') + qs
    //alert(url)
    httpXRequest('POST',url,true,null,qs)
      
    
}
// ----------------------------------------
// Wrapper function for constructing a request object.
//	Parameters:
//		reqType: The HTTP request type, such as GET or POST.
//		url: The URL of the server program.
//		asynch: Whether to send the request asynchronously or not.
// ----------------------------------------

function httpXRequest(reqType,url,asynch,respHandle) {

	// Mozilla-based browsers
	if (window.XMLHttpRequest) {
		request = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		request = new ActiveXObject("Msxml2.XMLHTTP");
		if (!request) {
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	// Request could still be null if neither ActiveXObject
	//   initialization succeeded
	
	if (request) {
		// If the reqType param is POST, then the fifth arg is the POSTed data
		if (reqType.toLowerCase() != "post") {
			initReq(reqType, url, asynch, respHandle);
		} else {
			// The POSTed data
			var args = arguments[4];
			//alert(args)
			if (args != null && args.length > 0) {
				initReq(reqType, url, asynch, respHandle, args);
			}
		}
	} else {
		alert("Your browser does not permit the use of all " +
			"of this application's features!");
	}

}

// ----------------------------------------
// Initialize a request object that is already constructed
// ----------------------------------------

function initReq(reqType, url, bool, respHandle) {
  
	try {
		// Specify the function that will handle the HTTP response
		request.onreadystatechange = function(){  //handleResponse;
          if(request.readyState==4) {
            if(request.status==200)
              var rt = request.responseText
              if(rt==null) rt="null response" 
              if(rt.substring(0,8)=='command:'){
                eval(rt.substring(8));
              }else{
                
                alert(rt);
              }
            //setTimeout('entops_sndReq(\''+action+'\',\''+target+'\','+delay+')',delay*1000);
            // clean up
            request.onreadystatechange = null;
            request = null;
          }
        };
		request.open(reqType, url, bool);
		// If the reqType param is POST, then the
		//   fifth argument to the function is the POSTed data
		if (reqType.toLowerCase() == "post") {
			// Set the Content-Type header for a POST request
			request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
			//request.setRequestHeader("Content-Type", "application/octet-stream; charset=utf-8");
			//request.setRequestHeader("Content-length", arguments[4].length);
      //request.setRequestHeader("Connection", "close");
      
			request.send(arguments[4]);
		} else {
			request.send(null);
		}
	} catch (errv) {
		alert("The application cannot contact the server at the moment. " +
			"Please try again in a few seconds.\n" +
			"Error detail: " + errv.message);
	}
}
