
function ayco_alertar (txt,callback) {
	var alertar_id = "info_" + new Date().getTime();
	$('<div id="' + alertar_id + '">' + txt + '</div>').dialog({
		bgiframe: true,
		modal: true,
		title: "Informaci&oacute;n",
		resizable: false,
		buttons: {
			Aceptar: function() {
				$("#" + alertar_id).dialog('close');
			}
		},
		beforeclose: function(event, ui) {
			switch (typeof(callback)) {
				case "function":
					callback.call();
					break;
				case "string":
					eval(callback);
					break;
			}
			$("#" + alertar_id).dialog('destroy').remove();
		}
	});
}

function ayco_confirmar (txt,callback_ok,callback_ko) {
	var confirmar_id = "info_" + new Date().getTime();
	$('<div id="' + confirmar_id + '">' + txt + '</div>').dialog({
		bgiframe: true,
		modal: true,
		title: "Confirmaci&oacute;n",
		resizable: false,
		buttons: {
			Aceptar: function() {
				switch (typeof(callback_ok)) {
					case "function":
						callback_ok.call();
						break;
					case "string":
						eval(callback_ok);
						break;
				}
				$("#" + confirmar_id).dialog('close');
			},
			Cancelar: function() {
				switch (typeof(callback_ko)) {
					case "function":
						callback_ko.call();
						break;
					case "string":
						eval(callback_ko);
						break;
				}
				$("#" + confirmar_id).dialog('close');
			}
		},
		beforeclose: function(event, ui) {
			$("#" + confirmar_id).dialog('destroy').remove();
		}
	});
}

function callback_form (result, txt) {
	if (typeof($.blockUI)!="undefined") {
		clase	= result;
		switch (result) {
			case "OK":
				msg		= ((typeof(txt)!="undefined") ? txt : '<p>Los datos se han guardado correctamente.</p>' );
				break;
			case "KO_FORM":
				clase	= "KO";
				msg		= ((typeof(txt)!="undefined") ? txt : '<p>El formulario contiene errores. Revise los campos y vuelva a intentarlo.</p>' );
				break;
			case "KO_RESULT":
				clase	= "KO";
				msg		= ((typeof(txt)!="undefined") ? txt : '<p>Los datos no se han guardado correctamente.</p>' );
				break;
			case "KO":
				msg		= ((typeof(txt)!="undefined") ? txt : '<p>Ha ocurrido un error inesperado.</p>' );
				break;
			default:
				clase	= "loading";
				msg		= ((typeof(txt)!="undefined") ? txt : '<p>Cargando datos...</p>' );
				break;
		}
		'<p>Los datos se han guardado correctamente.</p>',
		$.blockUI({
			message: $('' +
				'<div class="blockui">' +
					'<div class="' + clase + '">' +
						msg +
					'</div>' +
				'</div>'
			),
			css: {
				border					: 'none', 
				padding					: '5px', 
				backgroundColor			: '#000',
				'-moz-border-radius'	: '5px',
				'-webkit-border-radius'	: '5px',
				'-khtml-border-radius'	: '5px',
				opacity: .75
			}
		});
		setTimeout(function () { $.unblockUI() },3000);
	}
}
