var ventanaBusqueda = null;
var fotoAux1 = new Image();

function delLista (lista)
{
	for (var i = 0; i < lista.length; i++)
	{
		lista[i] = null;
		i--;
	}
}

var isNS4=(document.layers) ? 1 : 0;
var isIE4=((document.all) && !isNS4)? 1 : 0;
var isMoz=((document.getElementById) &&!(isNS4) && !(isIE4)) ? 1 :0;

function getWindowHeight ()
{
  if (isNS4)
  	return(window.innerHeight);
  if (isIE4)
    return(document.body.clientHeight);
  return(-1);
}
function getWindowWidth()
{
	if (isNS4)
    	return(window.innerWidth);
	if (isIE4)
    	return(document.body.clientWidth);
	return(-1);
}
function resize ()
{
	var w = getWindowWidth();
	var h = getWindowHeight();
	if (document.getElementById("tablaMain"))
	{
		document.getElementById("tablaMain").width = w;
		document.getElementById("tablaMain").height = h;
	}
}
/*
window.onresize = resize;
resize ();
*/
function agregar_favoritos (titulo)
{
	var url = "http://" + window.location.hostname;
	if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4))
	{
		window.external.AddFavorite (url, titulo);
	}
	else
	{ 
		if (navigator.appName == "Netscape") 
			window.alert ("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
		 	//window.external.AddFavorite(url,titulo);
	}
}
function agregar_inicio ()
{
	//incluye esta línea justamente al comienzo del body
	//<IE:HOMEPAGE ID="obj_pagina_inicio" />
	var url = "http://" + window.location.hostname;
	obj_pagina_inicio.style.behavior = 'url(#default#homepage)';
	obj_pagina_inicio.setHomePage (url);
}
function cargar_ventana (url, anchura, altura)
{
	openWindow (url, "", anchura, altura, "no", "no");
}
var ventanaBusqueda;
var fotoAux1 = new Image();
function verFoto (urlFoto)
{
	var cont = "<html><head><title>Ver Foto</title></head>\n";
	cont += "<body bgcolor=#F3F3F3 scroll=no><table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
	cont += "<tr><td align=center><img src=\"img/reloj_arena.gif\" border=0><p><font face=verdana size=1>Cargando imagen...</font></td>\n";
	cont += "</tr></table>\n";
	cont += "</body></html>";
	openWindow ("", "ventanaBusqueda", 250, 300, "no", "no");
	ventanaBusqueda.document.open();
	ventanaBusqueda.document.write (cont);
	ventanaBusqueda.document.close();
	fotoAux1.onload=loadFoto;
	fotoAux1.src = urlFoto;
}
function verFotoImprimir (urlFoto)
{
	var cont = "<html><head><title>Ver Foto</title></head>\n";
	cont += "<body bgcolor=#F3F3F3 scroll=no><table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
	cont += "<tr><td align=center><img src=\"img/reloj_arena.gif\" border=0><p><font face=verdana size=1>Cargando imagen...</font></td>\n";
	cont += "</tr></table>\n";
	cont += "</body></html>";
	openWindow ("", "ventanaBusqueda", 250, 300, "no", "no");
	ventanaBusqueda.document.open();
	ventanaBusqueda.document.write (cont);
	ventanaBusqueda.document.close();
	fotoAux1.onload=loadFotoImprimir;
	fotoAux1.src = urlFoto;
}
function loadFotoImprimir ()
{
	if (!ventanaBusqueda || ventanaBusqueda.closed)
		return (false);
	var w = fotoAux1.width + 10;
	var h = fotoAux1.height + 79;
	if (w > screen.width - 20)
	{
		var w2 = screen.width - 20;
		h = Math.round (h * w2 / w);
		w = w2;
	}
	if (h > screen.height - 60)
	{
		var h2 = screen.height - 60;
		w = Math.round (w * h2 / h);
		h = h2;
	}
	var cont = "<html><head><title>Detalle de la imagen</title></head>\n";
	cont += "<style type='text/css'><!-- .botones{font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 10px; font-style: normal; color: #333333;} --> </style>";
	cont += "<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onKeyDown=\"window.close();\" onContextMenu=\"return (false);\">\n";
	cont += "<div id=capafoto style=\"position:absolute; width:" + w + "px; height:" + h + "px; z-index:1; left: 0px; top: 0px; overflow: hidden;\">\n";
	//cont += "<img src=\"img/null.gif\" border=0 width=" + (w - 10) + " heigth=" + (h - 29) + ">\n";
	cont += "<div align='center'><br><input type='button' onClick='print()' value='Imprimir' class='botones'>&nbsp;<input type='button' onClick='window.close();' value='Cerrar' class='botones'><div>";
	cont += "</div>\n";
	cont += "<img name=foto src=\"img/null.gif\" border=0 width=" + (w - 10) + " heigth=" + (h - 29) + ">\n";

	cont += "</body></html>";
	ventanaBusqueda.resizeTo (w, h);
	var left = Math.round (screen.width / 2) - Math.round (w / 2);
	if (h > screen.height - 100)
		var top = 20;
	else
		var top = Math.round (screen.height / 2) - Math.round (h / 2);
	ventanaBusqueda.moveTo (left, top);
	ventanaBusqueda.document.open();
	ventanaBusqueda.document.write (cont);
	ventanaBusqueda.document.close();
	ventanaBusqueda.document.images["foto"].src = fotoAux1.src;
}
function loadFoto ()
{
	if (!ventanaBusqueda || ventanaBusqueda.closed)
		return (false);
	var w = fotoAux1.width + 10;
	var h = fotoAux1.height + 49;
	if (w > screen.width - 20)
	{
		var w2 = screen.width - 20;
		h = Math.round (h * w2 / w);
		w = w2;
	}
	if (h > screen.height - 60)
	{
		var h2 = screen.height - 60;
		w = Math.round (w * h2 / h);
		h = h2;
	}
	var cont = "<html><head><title>Ver Foto</title></head>\n";
	cont += "<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onKeyDown=\"window.close();\" onContextMenu=\"return (false);\">\n";
	cont += "<div id=capafoto style=\"position:absolute; width:" + w + "px; height:" + h + "px; z-index:1; left: 0px; top: 0px; overflow: hidden;\">\n";
	cont += "<img src=\"img/null.gif\" border=0 width=" + (w - 10) + " heigth=" + (h - 29) + ">\n";
	cont += "</div>\n";
	cont += "<img name=foto src=\"img/null.gif\" border=0 width=" + (w - 10) + " heigth=" + (h - 29) + ">\n";
	ventanaBusqueda.resizeTo (w, h);
	var left = Math.round (screen.width / 2) - Math.round (w / 2);
	if (h > screen.height - 100)
		var top = 20;
	else
		var top = Math.round (screen.height / 2) - Math.round (h / 2);
	ventanaBusqueda.moveTo (left, top);
	ventanaBusqueda.document.open();
	ventanaBusqueda.document.write (cont);
	ventanaBusqueda.document.close();
	ventanaBusqueda.document.images["foto"].src = fotoAux1.src;
}
function abreVentanaModal (win, form, action, target)
{
	win.onLoad = enviaForm (form, action, target);
}
function enviaForm (form, action, target)
{
	form.submit();
	form.action = action;
	form.target = target;
}
function openWindow (url, name, w, h, scrollbars, resizable, otras)
{
	if (ventanaBusqueda && !ventanaBusqueda.closed)
		ventanaBusqueda.close();
	if (w <= 0 || h <= 0)
	{
		if (w <= 0)
			w = screen.width - 10;
		if (h <= 0)
			h = screen.height - 60;
		var left = top = 0;
	}
	else
	{
		var left = Math.round (screen.width / 2) - Math.round (w / 2);
		if (h >= screen.height - 100)
			var top = 10;
		else
			var top = Math.round (screen.height / 2) - Math.round (h / 2);
	}
	var mas = "";
	if (otras != null)
		mas = ", " + otras;
	ventanaBusqueda = window.open (url, name, "top=" + top + ", left=" + left + ", width=" + w + ", height=" + h + ", scrollbars=" + scrollbars + ", resizable=" + resizable + ", status=yes" + mas);
}
