function modalDialog(url,w,h,titolo,exit){
		exit = (exit || true)
		$('#dialog').remove();
		var overlay = $('#overlay');
		if (overlay)
			overlay.hide();
		else
			overlay = $('<div id="overlay" syle="display:none">');
		var dialog = $('<div style="padding:10px;" id="dialog" class="dialog">');
		if (titolo != "") {
			dialog.append('<h3>' + titolo + '</h3>');
			h += 25;
		}
		var iframe = $('<iframe style="width:100%" src="' + url + '">');
		dialog.append(iframe);
		if (exit) {
			var chiudi = $('<input style="position:absolute;bottom:10px;right:10px" type="button" value="Chiudi">');
			chiudi.click(function() {
				dialog.remove();
				overlay.hide();
			})
			dialog.append(chiudi);
		}
		dialog.css('height',h.toString() + 'px');
		dialog.css('width',w.toString() + 'px');
		$('body').append(dialog);
		overlay.show();
		dialog.show();
		dialog.center();
}
function openAttachment(file,dbfilepath,database,unid,servlet) {
	defaultPath = '/pratiche/appofile.nsf';
	database = (database || sDBFileName);
	unid = (unid || sDocUNID);
	dbfilepath = (dbfilepath || defaultPath);
	servlet = (typeof(servlet) == "undefined") ? true : false;
	
	var url = dbfilepath + '/file?OpenForm&database=' + database  + '&unid=' + unid  + '&filename=' + file;
	if (!servlet)
		url = url + "&type=db";
	var w = 460;
	var h = 170;
	if(window.jQuery) {
		$.fn.center = function(){
			this.css('position','fixed');
			this.css('top',(($(window).height() - this.outerHeight())) / 2 + 'px');
			this.css('left',(($(window).width() - this.outerWidth()) / 2) + 'px');
			return this;
		}
		modalDialog(url,w,h,"Download file",true);
	}
	else {
		var sFeatures = 'resizable:0;dialogHeight:' + h + 'px;dialogWidth:' + w + 'px;center:1;help:0;scroll:yes;status:no';
		//window.showModalDialog(url,"",sFeatures)
		window.open(url,"captcha",sFeatures);
	}
}
