var titulopordefecto = "Imagen"; //Si no se especifica un título al llamar a la función colocará el que se especifique aquí
var ventana;

function popup(titulo, foto, altfoto){
   //if(cont==1){ventana.close();ventana=null}
   if(titulo==null){titulo=titulopordefecto}
   ventana=window.open('','ventana','resizable=yes,scrollbars=no,status=no')
   ventana.document.write('<html><head><title>' + titulo + '</title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" bgcolor="#000000" onUnload="opener.cont=0"><img src="' + foto + '" onLoad="opener.redimensionar(this.width, this.height)" onclick="window.close()" alt="' + altfoto + '">');
   ventana.document.close();
   //win.window.focus();
   ventana.focus();
   cont++;
}

function redimensionar(ancho, alto){
   ventana.resizeTo(ancho+12,alto+60);//28);
   ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
}
