/* Script is inspired on the example in the book "JavaServer Faces 2.0" (by Burns and Schalk), page 355. */

if (!window["ajaxErrorIndicator"]) {
	var ajaxErrorIndicator = {};
}
ajaxErrorIndicator.onError = function onError(data) {
	var status = data.status;
	var element = document.getElementById(ajaxErrorIndicator.errorComponentID);
	element.style.display = "inline";
	setTimeout(function() {
		jQuery(element).fadeOut(500);
	}, 3000);
};

jsf.ajax.addOnError(ajaxErrorIndicator.onError);

ajaxErrorIndicator.init = function init(errorComponentID) {
	ajaxErrorIndicator.errorComponentID = errorComponentID;
};
