function ToggleNode(id, root_path)
{
	table = document.getElementById(id).style;
	img = document.getElementById('sign_'+id);

	if (table.visibility == "hidden")
	{
		if (img != null)
		{
			imagen = img.src.substr(img.src.length-6,img.src.length);
			switch (imagen)
			{
				case '+L.gif':
					img.src = root_path + 'images/arbol/-L.gif';
					break;
					
				case '+T.gif':
					img.src = root_path + 'images/arbol/-T.gif';
					break;
					
				case 'L+.gif':
					img.src = root_path + 'images/arbol/L-.gif';
					break;
					
				case 'T+.gif':
					img.src = root_path + 'images/arbol/T-.gif';
					break;
			}
		}
		table.visibility = "visible";
		table.display = "block";
	}else{
		if (img != null)
		{
			imagen = img.src.substr(img.src.length-6,img.src.length);
			switch (imagen)
			{
				case '-L.gif':
					img.src = root_path + 'images/arbol/+L.gif';
					break;
					
				case '-T.gif':
					img.src = root_path + 'images/arbol/+T.gif';
					break;
					
				case 'L-.gif':
					img.src = root_path + 'images/arbol/L+.gif';
					break;
					
				case 'T-.gif':
					img.src = root_path + 'images/arbol/T+.gif';
					break;
			}
		}
		table.visibility="hidden";
		table.display="none"; 
	}
}

/*function precargar()
{
	document.getElementById("Msg_Load").style.display = "block";
	imgs = document.images;
	precargadas = true;
	for (var i = 0, total = imgs.length; i < total; i ++)
		precargadas = (precargadas && imgs[i].complete);
		if (precargadas)
		{
			document.getElementById("Msg_Load").style.display = "none";
		}
		else setTimeout("precargar()", 100);
}*/

function GoToUrl(id, url, cod_msg)
{
	if (id != '')
	{
		document.getElementById(id).style.display = "none";
	}
	
	if (cod_msg != '')
	{
		document.getElementById(cod_msg).style.display = "block";
		setTimeout("document.location.href='"+ url +"';",100);
	}
	else
	{
		var str = url.substr(0,7);
		
		if (str == 'http://')
		{
			window.open(url);
		}
		else
		{
			document.location.href = url;
		}
	}
	return false;
}

function MostrarFecha()
{
   var nombres_dias = new Array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado")
   var nombres_meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")

   var fecha_actual = new Date()

   dia_mes = fecha_actual.getDate()		//dia del mes
   dia_semana = fecha_actual.getDay()		//dia de la semana
   mes = fecha_actual.getMonth() + 1
   anio = fecha_actual.getFullYear()

   //escribe en pagina
   document.write(nombres_dias[dia_semana] + ", " + dia_mes + " de " + nombres_meses[mes - 1] + " de " + anio)
}

/*function SubmitForm(id, cod_msg)
{
	document.getElementById('cod_msg').style.display = "block";
	setTimeout("document.forms."+ id +".submit();",1000);
	return false;
}*/

function EliminarCategoria(num_subcategorias, num_elementos, ruta)
{
	if (num_subcategorias == 0 && num_elementos == 0)
	{
		respuesta = confirm("ADVERTENCIA: ¿Desea eliminar esta categoría?");
		
		if (respuesta != "0")
		{	
			self.location = ruta;
			return true;
		}
		
		return true;
	}
	else
	{
		alert("ERROR: La categoría no está vacía. Para eliminar una categoría debe eliminar todo su contenido.");
		return false;
	}
}

function EliminarZona(num_elementos, ruta)
{
	if (num_elementos == 0)
	{
		respuesta = confirm("ADVERTENCIA: ¿Desea eliminar esta zona?");
		
		if (respuesta != "0")
		{	
			self.location = ruta;
			return true;
		}
		
		return true;
	}
	else
	{
		alert("ERROR: La zona no está vacía. Para eliminar una zona debe eliminar todo su contenido.");
		return false;
	}
}

function EliminarElemento(ruta, msg)
{
	respuesta = confirm(msg);
	
	if (respuesta != "0")
	{
		self.location = ruta;
		return true;
	}
	
	return false;
}

function EliminarDepartamento(ruta, msg, numpersonas)
{
	if(numpersonas > 0)
	{
		respuesta = confirm(msg);
		
		if (respuesta != "0")
		{
			self.location = ruta;
			return true;
		}
	}
	else
	{
		self.location = ruta;
		return true;
	}
	
	return false;
}

function EliminarUsuario(zona_admin, zona_usuario, ruta)
{
	if (zona_admin == zona_usuario)
	{
		respuesta = confirm("ADVERTENCIA: Si elimina su propio usuario no podrá entrar en un futuro. ¿Desea continuar?");
		
		if (respuesta != "0")
		{	
			self.location = ruta;
			return true;
		}
		return false;
	}
	else
	{

		respuesta = confirm("ADVERTENCIA: ¿Está seguro que desea eliminar el usuario?.");
		
		if (respuesta != "0")
		{
			self.location = ruta;
			return true;
		}
		
		return false;
	}
	return false;
}

function Descargar(existe, ruta)
{
	if (existe == 0)
	{
		alert("ERROR: El fichero solicitado no se encuentra en el servidor. Contacte con el administrador.");
		return false;
	}
	else
	{
		window.open(ruta, '', 'scrollbars=NO,Status=NO,Menubar=NO,Toolbar=NO,Resizable=YES');
		//window.location=ruta;
		return true;
	}
}

function MensajeEstadoIn(text)
{
	window.status = text;
	return true;
}

function MensajeEstadoOut()
{
	window.status = 'Bienvenido a Maristas - Cullera';
}

function Maximizar()
{
	window.moveTo(0,0); 
	window.resizeTo(screen.availWidth, screen.availHeight); 
}

function OcultarTodo(capas)
{
	for (i=0; i<capas.length; i++)
	{
		document.getElementById(capas[i]).style.display = "none";
		document.getElementById(capas[i]).style.visibility = "hidden";
	}
	
	return true;
}

function MostrarOcultarCapa(id, capas)
{
	if (document.getElementById(id).style.visibility == "visible")
	{
		document.getElementById(id).style.display = "none";
		document.getElementById(id).style.visibility = "hidden";
		return true;
	}
	else
	{
		if (OcultarTodo(capas))
		{
			document.getElementById(id).style.display = "block";
			document.getElementById(id).style.visibility = "visible";
			return true;
		}
		else return false;
	}
}
function iSubmitEnter(oEvento, oFormulario){ 
     var iAscii; 

     if (oEvento.keyCode) 
         iAscii = oEvento.keyCode; 
     else if (oEvento.which) 
         iAscii = oEvento.which; 
     else 
         return false; 

     if (iAscii == 13) oFormulario.submit(); 

     return true; 
} 