// JavaScript Document

// funcio per mostrar la capa oculta amb la galeria d'imatges
function mostra_galeria(){
	document.getElementById("capa_galeria").style.display = "block";
	document.getElementById("mostra_galeria").style.display = "none";
	document.getElementById("amaga_galeria").style.display = "block";
	control_galeria = false;
}

function amagar_galeria(){
	document.getElementById("capa_galeria").style.display = "none";
	document.getElementById("mostra_galeria").style.display = "block";
	document.getElementById("amaga_galeria").style.display = "none";
	control_galeria = false;
}

function mostraEvent(id){
	document.location.href = "event.php?event="+id;
}

function mostraCat(cat){
	document.location.href = "agenda.php?cat="+cat;
}

function mostraNoticia(id){
	document.location.href = "noticia.php?noticia="+id;
}

function mostraTramit(id){
	document.location.href = "tramit.php?tramit="+id;
}

function mostraOferta(id){
	document.location.href = "ofertas.php?oferta="+id;
}

function netejaCerca(){
	document.getElementById("text_cerca").value = "";
}

function valida_directorio(form){

	//miramos que se haya introducido un nombre de directorio
	if(document.getElementById('directorio').value=='')
	{
		alert("Introduzca un nombre para el nuevo directorio");
		return (false);
	}
	else
	{
		ruta=document.getElementById('rutadirectorio1').value;
		form.action = "crear_directorio.php?ruta="+ruta;
		form.submit();	
	}
}

function valida_fichero(form){
	
	//miramos que se haya introducido un nombre de directorio
	if(document.getElementById('fichero').value=='')
	{
		alert("Elija el fichero que desea subir");
		return (false);
	}
	else
	{
		ruta=document.getElementById('rutadirectorio').value;
		form.action = "subir_fichero.php?ruta="+ruta;
		form.submit();	
	}
}

function obtener_ruta(ruta)
{
	//document.getElementById("rutadirectorio").innerHTML =ruta;
	if(document.getElementById("rutadirectorio"))
	{
		document.getElementById("rutadirectorio").value=ruta;
	}
	if(document.getElementById("rutadirectorio1"))
	{
		document.getElementById("rutadirectorio1").value=ruta;
	}
	
	//damos color al directorio seleccionado
	spans=document.getElementsByTagName('span');
	for (i=0;i<spans.length;i++)
	{
		if(spans[i].id=="li_"+ruta)
		{
			document.getElementById("li_"+ruta).style.background="#39F";
		}
		else
		{
			if(spans[i].id!='')
			{
				spans[i].style.background="#F9F1F2";
			}
		}
	}
	
}



function abrir_fichero(link)
{
	window.open(link);
}