	function dias(numero)
	{

		var texto =""
		switch (numero)
		{
			case "0":
				texto ="IGANDEA"
				break;
			case "1":
				texto ="ASTELEHENA"
				break;
			case "2":
				texto ="ASTEARTEA"
				break;
			case "3":
				texto ="ASTEAZKENA"
				break;
			case "4":
				texto ="OSTEGUNA"
				break;
			case "5":
				texto ="OSTIRALA"
				break;
			case "6":
				texto ="LARUNBATA"
				break;
		}
		return texto
	
	}
	
	function mas(numero)
	{		
				document.getElementById('Menos' + numero).style.visibility = 'visible';
				document.getElementById('Menos' + numero).style.display = 'block';
				document.getElementById('More' + numero).style.visibility = 'visible';
				document.getElementById('More' + numero).style.display = 'block';
				document.getElementById('Mas' + numero).style.visibility = 'hidden';
				document.getElementById('Mas' + numero).style.display = 'none';								
	}
	
	function menos(numero)
	{		
		document.getElementById('More' + numero).style.visibility = 'hidden';
		document.getElementById('More' + numero).style.display = 'none';
		document.getElementById('Menos' + numero).style.visibility = 'hidden';
		document.getElementById('Menos' + numero).style.display = 'none';
		document.getElementById('Mas' + numero).style.visibility = 'visible';
		document.getElementById('Mas' + numero).style.display = 'block';		
	}

	var diatexto = "";
	var divColl = false;

	var texto = "";
	var cabOculto = "" ;
	var textoOculto = "";
	var arrDias = Agenda.Agenda.Dias[0].Dia;
	var cont =3;
	

		for(d=0;d<arrDias.length;d++)		
		{
			//div
			document.write("<div id='"); 
			document.write(d);
			document.write("'>");
			
			diatexto = dias(arrDias[d].Numero);
			
			if (arrDias[d].Numero ==0 || arrDias[d].Numero==6)					
			{
				cont= 3;
			}
			else
			{
				cont=2
			}
			
			document.write("<dt>&nbsp;" + diatexto + " <span  style='font-size:10px'>" + arrDias[d].Fecha + "</span></dt>");
			
			var arrCategorias = arrDias[d].Categorias[0].Categoria;
				divColl = false;
				texto = "";
				cabOculto = "" ;
				textoOculto = "";				
				//dd
				document.write("<dd>");
			
				for(c=0;c<arrCategorias.length;c++)
				{					
										
					if (c == 0)
					{
					// primera categoria 
						dif = 1;
						texto = texto + ("<h5><strong>" + arrCategorias[c].Nombre.toUpperCase() + " - " + arrCategorias[c].Subcategoria + "</strong></h5>");
					
						//ul
						texto = texto + ("<ul  type='square'>");
						var arrEventos = arrCategorias[c].Eventos[0].Evento;
										
						for(e=0;e<arrEventos.length;e++)
						{
							texto = texto + ("<li><span style='color: #000000;'>" +  arrEventos[e].HoraEve + "</span> " +  arrEventos[e].Descripcion + "</li>");
							//salir al 2 evento
							if (e==1)
							{
								break;
							}
						}
									
						//fin ul
						texto = texto + ("</ul>");					
						texto = texto + ("<hr>");
					// fin primera categoria 
					}
					else
					{
					//otras cat	
						if (arrCategorias[c].Nombre.toUpperCase() != arrCategorias[c - 1].Nombre.toUpperCase() && dif < cont)  
						{
						//distinta
							dif = dif + 1;
							texto = texto + ("<h5><strong>" + arrCategorias[c].Nombre.toUpperCase() + " - " + arrCategorias[c].Subcategoria + "</strong></h5>");
					
							//ul
							texto = texto + ("<ul  type='square'>");
							var arrEventos = arrCategorias[c].Eventos[0].Evento;
					
							for(e=0;e<arrEventos.length;e++)
							{
								texto = texto + ("<li><span style='color: #000000;'>" +  arrEventos[e].HoraEve + "</span> " +  arrEventos[e].Descripcion + "</li>");
								//salir al 2 evento
								if (e==1)
								{
									break;
								}
							}
					
							//fin ul
							texto = texto + ("</ul>");					
							texto = texto + ("<hr>");	
						// fin distinta			
						}
						
						else
						{
							//oculto
							
							if (arrCategorias.length < 3 )
							{								
								texto = texto + ("<h5><strong>" + arrCategorias[c].Nombre.toUpperCase() + " - " + arrCategorias[c].Subcategoria + "</strong></h5>");
						
								//ul
								texto = texto + ("<ul  type='square'>");
								var arrEventos = arrCategorias[c].Eventos[0].Evento;
						
								for(e=0;e<arrEventos.length;e++)
								{
									texto = texto + ("<li><span style='color: #000000;'>" +  arrEventos[e].HoraEve + "</span> " +  arrEventos[e].Descripcion + "</li>");
									//salir al 2 evento
									if (e==1)
									{
										break;
									}
								}
						
								//fin ul
								texto = texto + ("</ul>");					
								texto = texto + ("<hr>");							
							
							}
							else
							{
								
								textoOculto = textoOculto + ("<h5><strong>" + arrCategorias[c].Nombre.toUpperCase() + " - " + arrCategorias[c].Subcategoria + "</strong></h5>");
						
								//ul
								textoOculto = textoOculto + ("<ul  type='square'>");
								var arrEventos = arrCategorias[c].Eventos[0].Evento;
						
								for(e=0;e<arrEventos.length;e++)
								{
									textoOculto = textoOculto + ("<li><span style='color: #000000;'>" +  arrEventos[e].HoraEve + "</span> " +  arrEventos[e].Descripcion + "</li>");
									//salir al 2 evento
									if (e==1)
									{
										break;
									}
									
									//fin oculto
								}
						
								//fin ul
								textoOculto = textoOculto + ("</ul>");					
								textoOculto = textoOculto + ("<hr>");																						
							}

						}
					
					//fin //otras cat
					}				
				
					//salir de las categorias 2 y 4 ( sabado y domingo)
					if (arrDias[d].Numero ==0 || arrDias[d].Numero==6)					
					{
						if(arrCategorias.length  > 2 && divColl == false && textoOculto != "")
						{   								
							cabOculto = cabOculto + ("<div id='More");
							cabOculto = cabOculto + (d);
							cabOculto = cabOculto + ("'>");
							divColl = true;
							//break;
						}
					}
					else
					{			
						if(arrCategorias.length > 1 && divColl == false && textoOculto != "")
						{   																										
							cabOculto = cabOculto + ("<div id='More");
							cabOculto = cabOculto + (d);
							cabOculto = cabOculto + ("'>");
							divColl = true;
							//break;
						}						
					}										
				}
				
				//escribir texto y texto oculto
				document.write(texto);
				document.write(cabOculto);
				document.write(textoOculto);
				
				
				//imagen +
				if (divColl)
				{
				
				
					document.write ("</div>");
					//botones +, -
					document.write("<a href='#' onclick='javascript:mas(");
					document.write(d);
					document.write(");'>");							
					document.write("<img  src='imgs/abrir_eus.gif' alt='Leer más' id='Mas");
					document.write(d);
					document.write("' /></a>");
					document.write("<a href='#' onclick='javascript:menos(");
					document.write(d);
					document.write(");'>");
					document.write("<img  src='imgs/cerrar_eus.gif' alt='Ocultar' id='Menos");
					document.write(d);
					document.write("' /> </a>");
					document.write("<br/>");
					//ocultar -, divMore		
					document.getElementById('More' + d).style.visibility = 'hidden';
					document.getElementById('More' + d).style.display = 'none';					
					document.getElementById('Menos' + d).style.visibility = 'hidden';
					document.getElementById('Menos' + d).style.display = 'none';
					
				}
				// fin dd
				document.write("</dd>");				
			
			//fin div
			document.write ("</div>")
		}


