
var ongoingAjax = 0;

function modifyWindow(domainLeftYear, domainRightYear, windowFromYear, windowToYear) {
	$('windowCleared').hide();
	$('ongoingAjax').show();
	$$('.subrecords').each(function(element) {
		element.hide();
	});

	ongoingAjax++;
	var options = {method: 'get', onSuccess: onSubrecords};
	new Ajax.Request('./?cfrom='+windowFromYear+'&cleft='+domainLeftYear+'&cright='+domainRightYear+'&cto='+windowToYear+'&recordsonly=1', options);
}

function onSubrecords(t) {
	if (ongoingAjax > 0) {
		ongoingAjax--;
		if (ongoingAjax == 0) {
			$('ongoingAjax').hide();
			$$('.subrecords').each(function(element) {
				element.replace(t.responseText);
			});
		}
	}
}

function clearWindow() {
	ongoingAjax = 0;

	$('windowCleared').show();

	$('ongoingAjax').hide();
	$$('.subrecords').each(function(element) {
		element.hide();
	});
}
