var winID = null;

// Metodo que invoca pop-up donde se maximiza una foto previamente seleccionada.
function popupBig(picname, caption, ancho, alto) {
	// Convertimos las barras en invertidas (para Opera).
	if ( !( iBPmix==2 || iBPmix==4)) 
		winID = window.open('../../popup/showpic.html?pic='+escape(picname) + '&cap='+escape(caption) + '&width='+ancho + '&height='+alto, 'bigpic', 'width=100,height=100,top=10,left=20,scrollbars=no,resizable=yes,status=no');
	else {
		var winXmod = 60;
		var winYmod = 90;      
		winID = window.open('../../popup/showpic.html?pic='+escape(picname) + '&cap='+escape(caption) + '&width='+ancho + '&height='+alto, 'bigpic', 'width='+(ancho+winXmod)+',height='+(alto+winYmod)+',top=10,left=20,scrollbars=no,resizable=no,status=no');	
	}
	winID.focus();
}


// Cierra la ventana de Big
function closeBig() {
  if ( iBPmix==2 || iBPmix==4) {
    //Netscape, en plataforma Win o Mac respectivamente				
		if ( winID != null )	{			
			if (  winID.name != undefined) winID.close();
		}
		winID = null;				
	}
	else	{
		// IExplorer  
		if ( winID != null)	winID.close();
		winID = null;
	}	  
}







//*****	FUNCIONES PARA RECOGER PARAMETROS DE URL.	*****//

// Recogemos los parámetros de entrada.
var strParam 		= location.search.substr(1);	
var arrayParam 	= new Array();			
returnParam();


// Almaceno los parámetros en un array.
function returnParam(){

	var i = 0;		
	var largo = strParam.length;		// largo de los parametros

	while(largo){					// mientras no salga del ciclo
		var posIgual = strParam.indexOf("=");	// busca la posicion del =
		var posAmp = strParam.indexOf("&");		// busca la posicion del &

		if(posAmp == 0 || posAmp == -1)		// si no encuentra el & lo igual con el largo del string con parametros
			posAmp = strParam.length;			

		if(posIgual != 0 || posIgual != -1){	// si no encuentra el = sale del ciclo
			var variable = strParam.substr(0,posIgual);				// nombre variable
			var valor = strParam.substr(posIgual + 1,posAmp - posIgual - 1);	// valor variable
			arrayParam[variable] = valor;					// crea un elemento de la matriz en la posicion variable(nombre del parametro) con el valor de esa variable

			if(posAmp >= strParam.length)					// si no quedan parametro sale del ciclo
				break;
			else	
				strParam = strParam.substr(posAmp + 1);	// recorta el string desde donde encuentra el anterior &
		}
		else
			break;						// sale del ciclo si no encuentra el signo =
	}
}







//*****	FUNCIONES PARA ABRIR UNA VENTANA, PUEDE SER GENERICA... 
//			A DÍA DE 29/05/2003, NO ES USUDA.
var win = null;

	
function OpenWindow (mypage,myname,w,h,scroll)
{
	LeftPosition	= (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition 	= (screen.height) ? (screen.height-h)/2 : 0;
	
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+', resizable=no';
	
	win = window.open( mypage, myname, settings);
	win.focus();
}


function CloseWindow () {
	if ( win != null)	{
		if (  win.name != "undefined") 
			win.close();
		
		win = null;
	}		
}


//*****	VENTANA PARA AMPLIAR UNA FOTO.	*****//
var winAmpliarFoto = null;

function OpenWindowAmpliar (mypage, nameImg, descriptionImg, widthFoto, heightFoto, scroll)
{
	// En primer lugar, cerramos la ventana, si está abierta.
	CloseWindowAmpliar();

	var w = parseInt(widthFoto) + 50;
	var h = parseInt(heightFoto) + 95;

	var LeftPosition	= (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition 	= (screen.height) ? (screen.height-h)/2 : 0;
	var myname ="ampliar";
	
	var settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+', resizable=no';
	
	mypage = mypage + "?nameImg=" + nameImg + "&descriptionImg=" + escape(descriptionImg) + "&widthImg=" + widthFoto + "&heightImg=" + heightFoto;

	winAmpliarFoto = window.open( mypage, myname, settings);
	winAmpliarFoto.focus();
}


function CloseWindowAmpliar () {
	if ( winAmpliarFoto != null)	{
		if (  winAmpliarFoto.name != "undefined") 
			winAmpliarFoto.close();
			
		winAmpliarFoto = null;
	}		
}


//*****	FUNCIONES PARA IMPRIMIR LOS PARÁMETROS EN POPUP AMPLIAR FOTO.

// Escribo la imagen a mostrar.
function fEscribirImg()	{
	document.write ("<img src='imagen/" + arrayParam["nameImg"] + "' alt='" + unescape(arrayParam["descriptionImg"]) + "' width='" + arrayParam["widthImg"] + "' height='" + arrayParam["heightImg"] + "'>");
}

// Escribo descripción de imagen a mostrar.
function fDescripcion()	{
	document.write ( "<strong>" + unescape(arrayParam["descriptionImg"]) + "</strong>");
}






