function createForm(action, method, id, admin_action){
	var f =  document.createElement("form");
	document.body.appendChild(f);
	f.action = action+"?admin_action="+admin_action;//+"&debug=query";
	f.method = method;
	f.id = id;
	//var hid = createHidden('admin_action', admin_action);
	//f.appendChild(hid);
	return f;
}

function createHidden(name, value){
	var hid = document.createElement("input");
	hid.type = 'hidden';
	hid.name = name;
	hid.value = value;	
	return hid;	
}

function setLister(down_limit, step, total_count, admin_action, subject){
	var f = createForm(main_module, "POST", 'limits_form', admin_action);
	var hid_down = createHidden('limits['+subject+'][down_limit]='+down_limit, down_limit);
	var hid_step = createHidden('limits['+subject+'][step]='+step, step);
	var hid_total = createHidden('limits['+subject+'][total_count]='+total_count, total_count);
	f.appendChild(hid_down);
	f.appendChild(hid_step);
	f.appendChild(hid_total);
	f.submit();		
}

function setPost(action, postStr, resp) {		
	var xmlHttpReq = false;
	response = '';
	responseXML = '';
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', main_module, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
	    if (self.xmlHttpReq.readyState == 4) {
			response = self.xmlHttpReq.responseText;
			responseXML = self.xmlHttpReq.responseXML;
			//if(debug && document.getElementById('debug') != null)
			//	document.getElementById('debug').innerHTML = response;
			eval(resp);
	    }
	}
	self.xmlHttpReq.send('admin_action='+action+'&'+postStr);
}
