var sending_data = new Object;
var submiting_form = "";

function doLoad(force){
	var req = new Subsys_JsHttpRequest_Js();
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			if(debug && $('debug')) $('debug').innerHTML = req.responseText;
			else if(debug) alert(req.responseText);
			LoadDataEnd();
			if(submiting_form != "") { Form.enable(submiting_form); submiting_form = "";}
			if (req.responseJS) {
				if(req.responseJS.system_message && !req.responseJS.box) showErrorBox('messages_box','system_message',req.responseJS.system_message);
				else if(req.responseJS.system_message && req.responseJS.box) showErrorBox(req.responseJS.box,req.responseJS.message_box,req.responseJS.system_message);
				if(req.responseJS.system_message2 && !req.responseJS.box) showErrorBox2('messages_box','system_message',req.responseJS.system_message2);
				else if(req.responseJS.system_message2 && req.responseJS.box) showErrorBox2(req.responseJS.box,req.responseJS.message_box,req.responseJS.system_message2);
				if(typeof(req.responseJS.func) != "undefined"){
					var args = req.responseJS.args;
					var func = eval(req.responseJS.func);
					func(args);
				}else if(req.responseJS.funcs){
					for(i in req.responseJS.funcs)
					{
						var args = req.responseJS.funcs[i].args;
						var func = eval(req.responseJS.funcs[i].func);
						func(args);
					}
				}else if(typeof(req.responseJS.call_function) != "undefined"){
					var args = req.responseJS.function_params;
					var func = eval(req.responseJS.call_function);
					func(args);
				}else if(req.responseJS.call_functions){
					for(i in req.responseJS.call_functions)
					{
						var args = req.responseJS.call_functions[i].function_params;
						var func = eval(req.responseJS.call_functions[i].call_function);
						func(args);
					}
				}
				if(typeof(req.responseJS.reset_form) != "undefined")
				{
					var form_obj = $(req.responseJS.reset_form);
					setTimeout(function(){ form_obj.reset(); },100);
					clear_hot_text(form_obj);
				}
				if(typeof(req.responseJS.required_fields) != "undefined"){
					for(tdid in req.responseJS.required_fields){
						var tdid_obj = $(tdid);
//						if(req.responseJS.required_fields[tdid] === true) tdid_obj.style.color = '#0099FF';
//						else tdid_obj.style.color = '#CEA639';
						if(req.responseJS.required_fields[tdid] === true) tdid_obj.className = 'tfvNormal';
						else tdid_obj.className = 'tfvHighlight';
					}
				}
			}
		}
	}
	//req.caching = true;
	req.open('POST', current_script, true);
	req.send(sending_data);
}
function callRemoteFunction(url, indata){
	if(typeof(url) == 'object')
	{
		sending_data = url;
		current_script = url.url;
	}else
	{
		sending_data = indata;
		current_script = url;
	}
	if (timeout) clearTimeout(timeout);
	if(submiting_form != "") Form.disable(submiting_form);
	LoadDataStart();
	block_loading_flag = 1;
	timeout = setTimeout(doLoad, 1000);
}