
function VeureArxiu(base)
{
	me = document.getElementById('f'+base);
	if(me.value!='') window.open(me.value,'window','');
}

function CargaFoto(despla,foto,base)
{
	x = document.getElementById(foto);
	y = document.getElementById(despla);
	if(y.selectedIndex!=-1)
	{
		valor = y.options[y.selectedIndex].value;
		x.innerHTML= '<img src=\"../../inc/gen_imatge.php?taula=arxius&id='+valor+'&foto=newbinmini&base='+base+'\" width=\"200\">';
	}
	
	
}

function EliminarLlista(me)
{
	x = document.getElementById(me);
	index = x.selectedIndex;
	if(index!=-1)
	{
		x.options[index] = null;
		CargaValors(me);
	}
}

function MouLlista(me,bDir)
{
	index = document.getElementById(me).selectedIndex;
	if(index!=-1)
	{
		actual = document.getElementById(me);
		var nxidx = index+(bDir? -1: 1);
		if(nxidx<0) nxidx = actual.options.length-1;
		if(nxidx>=actual.options.length) nxidx=0;
		var oldVal = actual.options[index].value;
		var oldText = actual.options[index].text;
		actual.options[index].value = actual.options[nxidx].value;
		actual.options[index].text = actual.options[nxidx].text;
		actual.options[nxidx].value = oldVal;
		actual.options[nxidx].text = oldText;
		actual.selectedIndex = nxidx;
		CargaValors(me);
	}
}

function CargaValors(from)
{
	cadena = '';
	me = document.getElementById(from);
	for(i=0;i<me.options.length;i++)
	{
		cadena = cadena + me.options[i].value+" ";
	}
	document.getElementById("o"+from).value = cadena;
}

function llistaAdd(me,valor,texte)
{
	xen = document.getElementById(me);
	xen.options[xen.options.length] = new Option(texte,valor);
	CargaValors(me);
}

function MostraImatge(me,arrel)
{
	xen = document.getElementById(me);
	index = xen.selectedIndex;
	if(index!=-1)
	{
		direc=arrel+xen.options[index].value;
		window.open(direc,'','');
	}
	else
	{
		alert('Imatge no seleccionada');
	}
}
function Elements(me)
{
	return document.getElementById(me);
}

function Limit()
{
	return flimits;
}

