function crearDialog(){
	var dialog = document.createElement("div");
	$(dialog).attr("id", "dialog");
	var body = document.getElementsByTagName("body")[0];
	body.appendChild(dialog);
}

function confirmacion(texto, callback, titulo){
	$(document).ready(function(){
		var title = titulo || "Confirmación";
		crearDialog();
		title = htmlentities(title);
		texto = htmlentities(texto);
		title = "<span class='ui-icon ui-icon-help' style='float:left; margin:0 7px 0 0;'></span>"+title;
		$("#dialog").html("<p>"+htmlentities(texto)+"</p>");
		$("#dialog").dialog({
			autoOpen: true,
			bgiframe: true,
			modal: true,
			show: 'drop',
			title: title,
			resizable:false,
			buttons: {
				"No": function() {
					$(this).dialog('close');
					eval(callback+"('false')");
				},
				"Si": function() {
					$(this).dialog('close');
					eval(callback+"('true')");
				}
			},
			close: function() {
				$("#dialog").remove();
			}
		});
	});
}

function aviso(texto, titulo, callback){
	$(document).ready(function(){
		var title = titulo || "Aviso";
		var ejecutar = callback || "";
		crearDialog();
		title = htmlentities(title);
		texto = htmlentities(texto);
		title = "<span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+title;
		$("#dialog").html("<p>"+texto+"</p>");
		$("#dialog").dialog({
			autoOpen: true,
			bgiframe: true,
			modal: true,
			show: 'drop',
			title: title,
			resizable: false,
			buttons: {
				"Ok": function() {
					$(this).dialog('close');
					if(ejecutar != ""){
						//eval(ejecutar+'()');
						eval(ejecutar);
					}
				}
			},
			close: function() {
				$("#dialog").remove();
			}
		});
	});
}
