//-------------------------------------- FUNCIONES DEL SITIO PARA ABRIR VENTANAS -----------------------

function openGaleria(url, name)
{
	openWindow(url, name, 'no', 'no', 465, 614);
}

function openWindowCV(url, name)
{
	openWindow(url, name, 'no', 'yes', 400, 380);
}

function openWindowPersonal(url, name)
{
	openWindow(url, name, 'no', 'no', 400, 500);
}

function openWindowExposicion(url, name)
{
	openWindow(url, name, 'no', 'no', 333, 500);
}
function openWindowMapa(url, name)
{
	openWindow(url, name, 'no', 'no', 570, 610);
}
function openWindowobras(url, name)
{
	openWindow(url, name, 'no', 'no', 500, 650);
}

function abrirContenidoNota(nombreObj)
{
	obj = document.getElementById(nombreObj);
	versionImprimible(obj);
}

/// Esta funcion funciona perfecto menos en IE 6
function versionImprimibleNoIE6(obj)
{
	miNuevaVentana =window.open("","miNuevaVentana", "width=750,height=600,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1");
	miNuevaVentana.document.writeln("<html><head><title>Revista Todavía</title>");
	miNuevaVentana.document.writeln("<link href='estilos.css' rel='stylesheet' type='text/css'/>");
	miNuevaVentana.document.writeln("</head><body>");
	miNuevaVentana.document.writeln(obj.innerHTML);
	miNuevaVentana.document.writeln("</body></html>");
}

function versionImprimible(obj)
{
	miNuevaVentana =window.open("impresion.html","miNuevaVentana", "width=750,height=600,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1");
}

// -------------------------------------- FUNCIONES DEL SITIO PARA NAVEGACION DE IMAGENES -----------------------

/// Cambia el indice al indice siguiente en forma circular.
function siguiente()
{
   indice++;
   if (indice >= arregloObras.length)
   		indice = 0;
		
	cargarDeIndice();
}

/// Cambia el indice al indice anterior en forma circular.
function anterior()
{
	indice--;
	if (indice < 0)
		indice = arregloObras.length - 1;

	cargarDeIndice();
}

/// Va directamente a un indice especifico
function irA(numero)
{
	indice = numero;
	cargarDeIndice();
}

/// Hace efectivo el cambio de imagen y texto a partir del indice seleccionado.
function cargarDeIndice()
{
	objImagen = document.getElementById('imagen');
	objNombre = document.getElementById('nombre');
	
	objNombre.innerHTML = arregloObras[indice];
	objImagen.src = arregloImagenes[indice].src;

	objNumeroActual = document.getElementById('numeroDeImagen');
	if (objNumeroActual)
		objNumeroActual.innerHTML = (indice + 1);
}

/// Carga y crea los links a cada una de las imagenes
function cargarNumerosDeImagenes()
{
	objNumerosDeImagenes = document.getElementById('numerosDeImagenes');
	if (objNumerosDeImagenes)
	{
		indiceMaximo = arregloObras.length;
		for (i = 0; i < indiceMaximo; i++)
		{
			numeroAmostrar = i+1;
			objNumerosDeImagenes.innerHTML += "<a class='" + nombreClaseLink + "' href='javascript:irA(" + i + ");' >" + numeroAmostrar + "</a> &nbsp;";
		}
	}
} 

function cargarCambioAutomatico()
{
	cargarCambioAutomaticoCada(5);
}

function cargarCambioAutomaticoCada(segundos)
{
	setInterval ( "siguiente()", segundos * 1000 );
}

/// Carga los arreglos iniciales y llama al cargar inicial. 
function cargar()
{
	cargarArregloImagenes();
	cargarArregloObras();
	cargarDeIndice();
	cargarNumerosDeImagenes();
	//cargarCambioAutomatico();
}

//--------------------------------------- FUNCIONES GENERALES -----------------------

function openWindow(which)
{
	openwWindow(which, 'namepopup');
}

function openWindow(url, name)
{
	openWindow(url, name, 'no', 'no', 500, 400);
}

function openWindow(url, name, tieneToolBar, tieneScrollBar, alto, ancho)
{
	str = 'toolbar=' + tieneToolBar + ',location=no,directories=no,status=no,menubar=no,scrollbars=' + tieneScrollBar +',resizable=no,menubar=no,width=' + ancho + ',height=' + alto;
	popupWindow = window.open(url,name,str);
	popupWindow.focus();
}



