// Funcions per mostrar popups d'imatges

var Finestra_Img;

function WinPopup_CA(Imatge,X,Y) {  //v2.0
	WinPopup("Imatge",Imatge,X,Y,"imatge.htm");
}

function WinPopup_ES(Imatge,X,Y) {  //v2.0
	WinPopup("Imagen",Imatge,X,Y,"imagen.htm");
}

function WinPopup_EN(Imatge,X,Y) {  //v2.0
	WinPopup("Picture",Imatge,X,Y,"picture.htm");
}

function WinPopup(NomFinestra,Imatge,X,Y,FitxerHtml) {  //v2.0
  if ( Imatge ) {
		var visor = "http://www.ub.edu/sl/img/winpopup/" + FitxerHtml + "?";
		var param = 'resizable=no,width=' + X + ',height=' + Y + ',toolbar=no,scrollbars=no,status=no,location=no';
		var origen = visor + Imatge;
		// if (Finestra_Img) TancaFinestraImg();
  	Finestra_Img = window.open( origen, NomFinestra, param );
  	Finestra_Img.focus();
	}
}

function RecullNomImatge() {
	var InCorrecte = 0;
	if (window.opener)
		if (window.location.search) {
			var cadimg = window.location.search.substring(1);
			document.images["Imatge"].src = cadimg;
		}
		else {InCorrecte = 1}
	else {InCorrecte = 1}
	if (InCorrecte != 0) {
		window.close();
	}
}

function TancaFinestraDependent() {
		if (Finestra_Img) {Finestra_Img.close()}
}

function TancaFinestraImg() {
//		if (Finestra_Img) {
//			Finestra_Img.close();
			window.close();
			window.opener.focus();
//		}
}

//
//	Retorna la carpeta del document actual
//
function PathLocation() {
  // Retorna el path del document actiu
	var strURL =window.location.href;
	var strPath;
	var n = 0;
	var ind = strURL.indexOf('/');
	while (ind>-1) {
		n = ind+1;
		ind = strURL.indexOf('/', n)
	};
	strPath = strURL.substring(0, n);
	return strPath;
}
//
//	Retorna la carpeta que conté la carpeta del document actual
//
function PathParentLocation() {
  // Retorna el path del document actiu
	var strURL =window.location.href;
	var strPath;
	var n = 0; var ant = 0;
	var ind = strURL.indexOf('/');
	while (ind>-1) {
		ant = n;
		n = ind+1;
		ind = strURL.indexOf('/', n)
	};
	strPath = strURL.substring(0, ant);
	return strPath;
}
//
//	Mostra un missatge a la barra d'estat
//
function Status_Missatge(Missatge){
	window.status = Missatge;
	return true
}

