var ventanaBusqueda = null;
var fotoAux1 = new Image();
var isNS4=(document.layers) ? 1 : 0;
var isIE4=((document.all) && !isNS4)? 1 : 0;
var isMoz=((document.getElementById) &&!(isNS4) && !(isIE4)) ? 1 :0;
var URLSite = getURLSite();
function delLista(lista)
{
	for (var i = 0; i < lista.length; i++)
	{
		lista[i] = null;
		i--;
	}
}
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;
	}
}
function agregar_favoritos(url,titulo)
{
	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=\"" + URLSite + "/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=\"" + URLSite + "/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>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=\"" + URLSite + "/img/null.gif\" border=0 width=" + (w - 10) + " heigth=" + (h - 29) + ">\n";
	cont += "</div>\n";
	cont += "<img name=foto src=\"" + URLSite + "/img/null.gif\" border=0 width=" + (w - 10) + " heigth=" + (h - 29) + ">\n";
	cont += "<div align='center'><input type='button' onClick='print()' value='Imprimir'><div>";
	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() {
	var w = fotoAux1.width + 10;
	var h = fotoAux1.height + 29;
	var cont = "<html><head><title>Ver Foto</title></head>\n";
	cont += '<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onKeyDown="return false" onMouseDown="return false" onContextMenu="return false">';
	cont += '<img src="' + fotoAux1.src + '" border="0"></body></html>';
	ventanaBusqueda.resizeTo(w, h);
	ventanaBusqueda.moveTo(Math.round (screen.width / 2) - Math.round (w / 2), Math.round (screen.height / 2) - Math.round (h / 2));
	ventanaBusqueda.document.open();
	ventanaBusqueda.document.write(cont);
	ventanaBusqueda.document.close();
}
*/
function loadFoto () {
	var w = fotoAux1.width + 7;
	var h = fotoAux1.height + (isIE4 ? 29 : 48);
	var html = "<html><head><title>Ver foto</title></head>\n";
	html += "<body style='margin: 0px 0px 0px 0px;' onKeyDown='window.close();' onContextMenu='return (false);'>";
	html += "<div id='photoLayer' style='position:absolute; width:" + fotoAux1.width + "; height:" + fotoAux1.height + "; z-index:1; left: 0px; top: 0px;'>\n";
	html += "</div>";
	html += "<img name='photo' src=\"" + fotoAux1.src + "\" border=0></body></html>";
	ventanaBusqueda.resizeTo (w, h);
	ventanaBusqueda.moveTo (Math.round (screen.width / 2) - Math.round (w / 2), Math.round (screen.height / 2) - Math.round (h / 2));
	ventanaBusqueda.document.open();
	ventanaBusqueda.document.write (html);
	ventanaBusqueda.document.images["photo"].src = fotoAux1.src;
	ventanaBusqueda.document.close();
}

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();
	var left = Math.round (screen.width / 2) - Math.round (w / 2);
	var top = Math.round (screen.height / 2) - Math.round (h / 2);
	ventanaBusqueda = window.open (url, name, "top=" + top + ", left=" + left + ", width=" + w + ", height=" + h + ", scrollbars=" + scrollbars + ", resizable=" + resizable);
	ventanaBusqueda.focus();
}
function getURLSite() {
	var URLSite = document.URL;
	var start = URLSite.indexOf('//') > -1 ? URLSite.indexOf('//') + 2 : 0;
        start = (URLSite.indexOf('~') > -1 ? URLSite.indexOf('~') : start);
	return URLSite.indexOf('/', start) > -1 ? URLSite.substring(0, URLSite.indexOf('/', start)) : URLSite;
}