var _img_grande;
var _titulo;
var _estado;

function mostrar() {
	var ops = "top=" + ((screen.height - _img_grande.height) / 2);
	ops += ",left=" + ((screen.width - _img_grande.width) / 2);
	ops += ",width=" + _img_grande.width + ",height=" + _img_grande.height;
	ops += ",status=";
	ops += (_estado) ? "yes" : "no";
	var p = "<html><head><meta http-equiv='imagetoolbar' content='no'><title>" + _titulo + "</title>";
	p += "<script>";
	p += "function hide(id) {";
    p += "if (document.getElementById) {";
    p += "document.getElementById(id).style.visibility = 'hidden';";
    p += "}";
    p += "else if (document.all) {";
    p += "document.all[id].style.visibility = 'hidden'";
    p += "}";
    p += "else if (document.layers) {";
    p += "document.layers[id].visibility = 'hidden'";
    p += "}";
	p += "}";
	p += "function esconde(){";
	p += "hide('loading');";
	p += "}";
	p += "</script>";
	p += "</head><body onLoad=\"setTimeout('esconde();', 1000)\"; style='margin:0px;padding:0px;background-image: url(" + _img_grande.src + ")'>";
	p += "<div id='loading' style='background:#FFFFFF;left:0px;top:0px;width:100%;height:100%;'>";
	p += "<table width='100%' height='100%' border='0'><tr>";
	p += "<td valign='middle' align='center' style='font-family:verdana, arial, sans-serif; letter-spacing: 1px; font-size: 11px; color: #999999; text-align:center;'>Carregant imatge ...<p><br>";
	p += "<img src='http://www.cobdc.org/icones/waiting.gif' width='14' height='29' alt='' border='0'></td>";
	p += "</tr></table>";
	p += "</div>";	
	p += "</body></html>";
	var ventana = window.open("", "", ops);
	ventana.document.open();
	ventana.document.write(p);
	ventana.document.close();
}

function cargando() {
	if (_img_grande.complete) mostrar();
	else setTimeout("cargando()", 100);
}

function abrir(imagen, titulo, estado)	{
	_img_grande = new Image();
	_img_grande.src = imagen;
	_titulo = titulo;
	_estado = estado;
	cargando();
}
