// JavaScript Document

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();
}}

/**
 * Codigo copiado de XGAP (https://sourceforge.net/projects/xgap/):
 * http://xgap.svn.sourceforge.net/viewvc/xgap/trunk/xgap/motores/ultimo/scripts/utilidades.js?view=markup
 * Abre una nueva ventana del navegador, de manera que ocupe toda la pantalla.
 * @param {String} pagina URL de la pagina a abrir
 * @param {String} nombre_ventana
 */
function abrirPaginaPantallaCompleta(pagina,nombre_ventana){
	var params, w;

	params = 'menubar=no,toolbar=no,status=no,location=no,resizable=yes,scrollbars=yes' +
	       ',width=' + (screen.availWidth - 10).toString() + ',height=' + (screen.availHeight - 122).toString() +
	       ',top=0,left=0,screenX=0,screenY=0';
	w = window.open('',nombre_ventana,params,true);
	if (w) { // Un bloqueador de popups puede impedir la apertura de la ventana
		w.location = pagina;
		w.focus();
		w.moveTo(0, 0);
		w.resizeTo(screen.availWidth, screen.availHeight);
	}
	return w;
}

/**
 * Codigo copiado de XGAP (https://sourceforge.net/projects/xgap/):
 * http://xgap.svn.sourceforge.net/viewvc/xgap/trunk/xgap/motores/ultimo/scripts/utilidades.js?view=markup
 * y posteriormente adaptado.
 * Abre una nueva ventana del navegador.
 * abrirVentana(pagina, nombre_ventana, 0, 0) equivale a abrirPaginaPantallaCompleta(pagina, nombre_ventana).
 * @param {String} pagina URL de la pagina a abrir
 * @param {String} nombre_ventana
 * @param {Number} ancho ancho en pixeles de la ventana;
 * 		si es positivo, indica el ancho final;
 * 		si es cero, toma el ancho total de la pantalla
 * 		si es negativo, la ventana queda con el ancho total de la pantalla menos el ancho dado
 * @param {Number} alto alto en pixeles de la ventana;
 * 		si es positivo, indica el alto final;
 * 		si es cero, toma el alto total de la pantalla
 * 		si es negativo, la ventana queda con el alto total de la pantalla menos el alto dado
 * @param {Number} ancho (opcional) ancho mínimo de la ventana; por defecto 200px;
 * 		sólo se usa si se especifica un ancho negativo
 * @param {Number} alto (opcional) alto mínimo de la ventana; por defecto 200px;
 * 		sólo se usa si se especifica un alto negativo
 */
function abrirVentana(pagina, nombre_ventana, ancho, alto, ancho_min, alto_min) {
	var params, w, t, l;

	if (typeof ancho_min == 'undefined') {
		ancho_min = 200;
	}
	if (typeof alto_min == 'undefined') {
		alto_min = 200;
	}

	if (ancho < 0) {
		ancho = screen.availWidth + ancho;
		if (ancho < ancho_min) {
			ancho = ancho_min;
		}
	}
	if (ancho > 0) {
		l = Math.floor((screen.availWidth - ancho) / 2).toString();
		ancho_final = ancho;
	} else {
		l = 0;
		ancho = screen.availWidth - 10;
		ancho_final = screen.availWidth;
	}

	if (alto < 0) {
		alto = screen.availHeight + alto;
		if (alto < alto_min) {
			alto = alto_min;
		}
	}
	if (alto > 0) {
		t = Math.floor((screen.availHeight - alto) / 2).toString();
		alto_final = alto;
	} else {
		t = 0;
		alto = screen.availHeight - 122;
		alto_final = screen.availHeight;
	}

	params = 'menubar=no,toolbar=no,status=no,location=no,resizable=yes,scrollbars=yes' +
	       ',width=' + ancho.toString() + ',height=' + alto.toString() +
	       ',top=' + t + ',left=' + l + ',screenX=' + l + ',screenY=' + t;
	w = window.open('',nombre_ventana,params,true);
	if (w) { // Un bloqueador de popups puede impedir la apertura de la ventana
		w.location = pagina;
		w.focus();
		w.moveTo(l, t);
		w.resizeTo(ancho_final, alto_final);
	}
	return w;
}

