function process_ajax(info)
{
	var i = 0;
	while(info[i] != null)
	{
		if(info[i].where == 'html')
			$(info[i].l_id).innerHTML = info[i].value;
		else if(info[i].where == 'remove')
			$(info[i].l_id).remove();
		else if(info[i].where == 'append')
			$(info[i].l_id).insert({bottom: info[i].value});
		else if(info[i].where == 'prepend')
			$(info[i].l_id).insert({top: info[i].value});
		else if(info[i].where == 'value')
			$(info[i].l_id).value = info[i].value;
		else if(info[i].where == 'js')
			eval(info[i].value);
		i = i + 1;
	}
	if($('ajaxIndicator'))
		$('ajaxIndicator').setStyle({display: 'none'});
}


function sendAjax(info, action, url)
{
	var data = new Object();
	data.action = action;
	data.info = info;
	var json = encodeURIComponent(Object.toJSON(data));
	if($('ajaxIndicator'))
		$('ajaxIndicator').setStyle({display: 'inline'});

	new Ajax.Request(url,
	{
		method:'post',
		parameters: 'ls_ajax='+json,
		onSuccess: function(transport){
			if(transport.responseText.isJSON()) {
				process_ajax(transport.responseText.evalJSON(true));
			}
			else {
				alert('Errors:\n\n' + transport.responseText.replace(/<br \/>/g, '\n'));	
			}
		},
		onFailure: function(){ alert('There was an error.') }
	});	
}
