// JavaScript Document
<!--Fuciones de manejo del fichero XML en donde se encuentran las letras-->
var xmlDocFestivales;
var arData;
var arMes = new Array();
var arAnio = new Array();
var arGruposFestival = new Array();
var arGrupos = new Array();
var arLugar = new Array();
var arNombre = new Array();
var arAuxDiasFestival = new Array();
var arDias = new Array();
var arGrupos = new Array();
var arHorario = new Array();
var arPrecio = new Array();
var arVenta = new Array();
var arMasInfo = new Array();
var arTituloTable = new Array();
arTituloTable.push("Lugar");
arTituloTable.push("Fecha");
arTituloTable.push("Grupos");
arTituloTable.push("Horarios");
arTituloTable.push("Precio");
arTituloTable.push("Venta");
arTituloTable.push("Más info");
var sCurrentMonth;
var sCurrentYear;
var sVentaAux;
var today = new Date();
sCurrentMonth = today.getMonth();		
sCurrentYear = today.getFullYear();
//Mapeo los meses
var arMonths = new Array(12);
arMonths[0]="Enero";
arMonths[1]="Febrero";
arMonths[2]="Marzo";
arMonths[3]="Abril";
arMonths[4]="Mayo";
arMonths[5]="Junio";
arMonths[6]="Julio";
arMonths[7]="Agosto";
arMonths[8]="Septiembre";
arMonths[9]="Octubre";
arMonths[10]="Noviembre";
arMonths[11]="Diciembre";

var arMesesInfo;

function importaXMLFestivales(fichero,funcion) {
  var mozilla = (typeof document.implementation != 'undefined')
      && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined');

  if (mozilla) {
    xmlDocFestivales = document.implementation.createDocument("", "", null)
    xmlDocFestivales.load(fichero);
    xmlDocFestivales.onload = function()
    {
      funcion(xmlDocFestivales);
    }
  } else if (ie) {
    xmlDocFestivales = new ActiveXObject("Microsoft.XMLDOM");
    xmlDocFestivales.async = false;
    xmlDocFestivales.load(fichero);
    if (xmlDocFestivales.readyState == 4) funcion(xmlDocFestivales);
  }
  else {
    alert('Tu navegador no puede manejar este script');
    return;
  }
}

function importaFestivalesXML(fichero) {
  importaXMLFestivales(fichero,PaintDataFestivales);
}

function PaintDataFestivales(xmlDocFestivales){
		try{
			FillScreen();
		}catch(err){
			alert(err.message);
		}
	}
		
//Función que construye el combo de Discos
	function FillScreen(){
		try{
			arData = getData();
			var arDataMes;
			//Obtenemos los datos del combo de meses
			arMesesInfo=getMesesWithInfo(arData);
			FillCombo(arMesesInfo);
			var iMes;
			iMes = parseInt(sCurrentMonth)+1;
			arDataMes=GetDataMes(iMes,sCurrentYear);
			PaintTable(arDataMes);
		}catch(err){
			alert(err.message);
		}
	}
	
	function GetDataMes(sMes,sAnio){
		try{
			var arData = new Array();
			var arPagina = new Array();
			var arInfo = new Array();
			var arAuxDias;
			var arAuxGrupos;
			var arAuxGruposDia;
			var arDias;
			var arGrupos;
			var arPaginas = new Array();	
			var arFestival = new Array();	
			arMes = new Array();
			arLugar = new Array();
			arNombre = new Array();
			arAuxDiasFestival = new Array();
			arAuxDias = new Array();
			arDias = new Array();
			arAuxGrupos = new Array();
			arGrupos = new Array();
			arAuxGruposDia = new Array();
			arHorario = new Array();			
			arPrecio = new Array();
			arVenta = new Array();
			arMasInfo = new Array();
			arAnio = new Array();
			//Obtenemos las páginas
			arPaginas = xmlDocFestivales.getElementsByTagName("pagina");
			for(var iPag=0;iPag<arPaginas.length;iPag++){
				arInfo = new Array();
				arMes = new Array();
				arNombre = new Array();
				arLugar = new Array();
				arDias = new Array();
				arGrupos = new Array();
				arHorario = new Array();
				arPrecio = new Array();
				arVenta = new Array();
				arMasInfo = new Array();
				arAnio = new Array();	
				//obtenemos los festivales
				arFestival = arPaginas[iPag].getElementsByTagName("festival");
				for(i=0;i<arFestival.length;i++){
					if((arFestival[i].getElementsByTagName("mes")[0].firstChild.data==sMes)&&(arFestival[i].getElementsByTagName("anio")[0].firstChild.data==sAnio)){
						arMes.push(arFestival[i].getElementsByTagName("mes")[0].firstChild.data);
						arLugar.push(arFestival[i].getElementsByTagName("lugar")[0].firstChild.data);
						arNombre.push(arFestival[i].getElementsByTagName("nombre")[0].firstChild.data);
						arAuxDiasFestival = new Array();
						arAuxDiasFestival =arFestival[i].getElementsByTagName("diaFestival");
						arAuxDias = new Array();
						arAuxGrupos = new Array();
						arAuxGruposDia = new Array();
						if(arAuxDiasFestival.length==1){
							arAux = new Array();
							arAuxDias.push(arAuxDiasFestival[0].getElementsByTagName("dia")[0].firstChild.data);
							arAuxGruposDia = arAuxDiasFestival[0].getElementsByTagName("grupo");
							for(z=0;z<arAuxGruposDia.length;z++){
								arAux.push(arAuxGruposDia[z].firstChild.data);
							}
							arAuxGrupos.push(arAux);
						}else{
							for(j=0;j<arAuxDiasFestival.length;j++){
								arAux = new Array();
								arAuxDias.push(arAuxDiasFestival[j].getElementsByTagName("dia")[0].firstChild.data);
								arAuxGruposDia = arAuxDiasFestival[j].getElementsByTagName("grupo");
								for(z=0;z<arAuxGruposDia.length;z++){
									arAux.push(arAuxGruposDia[z].firstChild.data);
								}
								arAuxGrupos.push(arAux);
							}
						}
						arDias.push(arAuxDias);
						arGrupos.push(arAuxGrupos);
						arHorario.push(arFestival[i].getElementsByTagName("horario")[0].firstChild.data);
						arPrecio.push(arFestival[i].getElementsByTagName("precio")[0].firstChild.data);
						arVenta.push(arFestival[i].getElementsByTagName("venta")[0].firstChild.data);
						arMasInfo.push(arFestival[i].getElementsByTagName("masinfo")[0].firstChild.data);
						arAnio.push(arFestival[i].getElementsByTagName("anio")[0].firstChild.data);										
					}				
				}//Fin for festivales por página
				if(arMes.length>0){
					arInfo.push(arMes);
					arInfo.push(arNombre);
					arInfo.push(arLugar);
					arInfo.push(arDias);
					arInfo.push(arGrupos);
					arInfo.push(arHorario);
					arInfo.push(arPrecio);
					arInfo.push(arVenta);
					arInfo.push(arMasInfo);
					arInfo.push(arAnio);				
					arPagina.push(arInfo);
				}
			}//Fin for paginas
			arData.push(arPagina);
			return arData;	
		}catch(err){
			alert(err.message);
		}
	}
	
	function FillCombo(arValues){
		try{
			var arAux;
			var iMes;
			var sText;
			var sValue;
			var oCombo = document.getElementById("idMeses");
			for(l=0;l<arValues.length;l++){
				arAux = arValues[l];
				iMes = parseInt(arAux[0])-1;
				sText = arMonths[iMes]+ " " + arAux[1];
				sValue =arAux[1] + iMes;
				oOption = new Option(sText,sValue);
				oCombo.options[l]=oOption;
			}
			oCombo.value=sCurrentYear.toString()+sCurrentMonth.toString();
		}catch(err){
			alert(err.message);
		}
	}
	
	function PaintTable(arData){
		try{
			var arGruposFestival;
			var oDiv = document.getElementById("idTabla");
			var oTable;
			var oTbody;
			var oTr;
			var oTd;
			var oLink;
			var oText;
			var sPath;
			var iMes;
			var oTableGrupos;
			var arDiasAux;
			var arGruposAux;
			var arListGruposAux;
			var oTableAux;
			var oTbodyAux;
			var oTrAux;
			var oTdAux;
			var sStyleFechas;
			var sStyleGrupos;
			var arDataMes = new Array();
			var arDataPage = new Array();
			arDataMes = arData[0];
			arDataPage =arDataMes[0]
			//Se pasan el array de datos a cada Array de subdatos			
			arMes = arDataPage[0];
			arNombre = arDataPage[1];
			arLugar = arDataPage[2];
			arDias = arDataPage[3];
			arGrupos = arDataPage[4];
			arHorario = arDataPage[5];
			arPrecio = arDataPage[6];
			arVenta = arDataPage[7];
			arMasInfo = arDataPage[8];
			arAnio = arDataPage[9];
			
			oTable = document.getElementById("tblMain");
			if (mozilla) {
				oTable.setAttribute("class","tableTitleMesTable");			
			} else if (ie) {
				oTable.setAttribute("className","tableTitleMesTable");
			}else {
				alert('Tu navegador no puede manejar este script');
				return;
			}
			oTbody = document.getElementById("idTbody");
			oTd=document.getElementById("tdMes");
			//Pintamos el mes
			iMes=parseInt(arMes[0])-1;
			if(oTd.hasChildNodes()){
				oText = oTd.firstChild;
				oTd.removeChild(oText);
			}
			oText=oTd.appendChild(document.createTextNode(arMonths[iMes].toUpperCase()));
			//Pintamos los datos del festival	
			var oTable2;
			var oTbody2;
			var oTr2;
			var oTd2;
			var oDiv2 = document.getElementById("idTabla2");
			for(i=0;i<arLugar.length;i++){
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableFestivalName");			
				} else if (ie) {
					oTable2.setAttribute("className","tableFestivalName");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}				
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				//Nombre del festival
				oTd2=oTr2.appendChild(document.createElement("td"));
				oText=oTd2.appendChild(document.createTextNode(arNombre[i]));		
				//Lugar del festival
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}		
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[0]));	
				oTd2=oTr2.appendChild(document.createElement("td"));
				if (mozilla) {
					oTd2.setAttribute("class","tdLugarTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdLugarTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arLugar[i]));	
				//Fechas
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[1]));	
				arDiasAux = new Array();
				arDiasAux = arDias[i];
			    sStyleFechas = GetStyleFecha(arDiasAux.length);			
				for(z=0;z<arDiasAux.length;z++){
					oTd2=oTr2.appendChild(document.createElement("td"));
					if (mozilla) {
						oTd2.setAttribute("class",sStyleFechas);			
					} else if (ie) {
						oTd2.setAttribute("className",sStyleFechas);
					}else {
						alert('Tu navegador no puede manejar este script');
						return;
					}
					oText=oTd2.appendChild(document.createTextNode(arDiasAux[z]+ " "+arMonths[iMes]));	
				}
				//Grupos
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[2]));	
				arGruposAux = new Array();
				arListGruposAux = new Array();
				arGruposAux = arGrupos[i];
			    sStyleGrupos = GetStyleGrupos(arDiasAux.length);			
				for(z=0;z<arGruposAux.length;z++){
					oTd2=oTr2.appendChild(document.createElement("td"));
					if (mozilla) {
						oTd2.setAttribute("class",sStyleGrupos);			
					} else if (ie) {
						oTd2.setAttribute("className",sStyleGrupos);
					}else {
						alert('Tu navegador no puede manejar este script');
						return;
					}	
					oTableAux=oTd2.appendChild(document.createElement("table"));
					oTbodyAux=oTableAux.appendChild(document.createElement("tbody"));
					arListGruposAux = arGruposAux[z];
					for(t=0;t<arListGruposAux.length;t++){
						oTrAux=oTbodyAux.appendChild(document.createElement("tr"));
						oTdAux=oTrAux.appendChild(document.createElement("td"));			
						oTdAux.setAttribute("align","left");
						if (mozilla) {
							oTdAux.setAttribute("class","tdGruposTableInt");			
						} else if (ie) {
							oTdAux.setAttribute("className","tdGruposTableInt");
						}else {
							alert('Tu navegador no puede manejar este script');
							return;
						}			
						oText=oTdAux.appendChild(document.createTextNode(arListGruposAux[t]));	
					}
				}
				//Horario
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[3]));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdHorarioFesTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdHorarioFesTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arHorario[i]));	
				//Precio
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[4]));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdPrecioTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdPrecioTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arPrecio[i]));	
				//Venta
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[5]));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdVentaTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdVentaTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				sVentaAux = arVenta[i].toLowerCase();
				if(sVentaAux.indexOf("http")!=-1){
					oLink = oTd2.appendChild(document.createElement("a"));
					oLink.setAttribute("href",arVenta[i]);
					oLink.setAttribute("target","_blank");	
					oText=oLink.appendChild(document.createTextNode(arVenta[i]));	
				}else{
					oText=oTd2.appendChild(document.createTextNode(arVenta[i]));	
				}
				//Más Info
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[6]));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdMasinfoTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdMasinfoTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oLink = oTd2.appendChild(document.createElement("a"));
				oLink.setAttribute("href",arMasInfo[i]);
				oLink.setAttribute("target","_blank");	
				oText=oLink.appendChild(document.createTextNode(arMasInfo[i]));	
				if(i!=arLugar.length-1){
					oTr=oDiv2.appendChild(document.createElement("br"));
				}
			}//Fin for
			
			if(arDataMes.length>1){
				PaintPaginado(arDataMes.length);
			}
	
		}catch(err){
			alert(err.message);
		}
	}
	
	//Se pinta en una página en concreto del mes
	function PaintTablePagina(arData,iPagina){
		try{
			var arGruposFestival;
			var oDiv = document.getElementById("idTabla");
			var oTable;
			var oTbody;
			var oTr;
			var oTd;
			var oLink;
			var oText;
			var sPath;
			var iMes;
			var oTableGrupos;
			var arDiasAux;
			var arGruposAux;
			var arListGruposAux;
			var oTableAux;
			var oTbodyAux;
			var oTrAux;
			var oTdAux;
			var sStyleFechas;
			var sStyleGrupos;
			var arDataMes = new Array();
			var arDataPage = new Array();
			arDataMes = arData[0];
			arDataPage =arDataMes[iPagina]
			//Se pasan el array de datos a cada Array de subdatos			
			arMes = arDataPage[0];
			arNombre = arDataPage[1];
			arLugar = arDataPage[2];
			arDias = arDataPage[3];
			arGrupos = arDataPage[4];
			arHorario = arDataPage[5];
			arPrecio = arDataPage[6];
			arVenta = arDataPage[7];
			arMasInfo = arDataPage[8];
			arAnio = arDataPage[9];
			
			oTable = document.getElementById("tblMain");
			if (mozilla) {
				oTable.setAttribute("class","tableTitleMesTable");			
			} else if (ie) {
				oTable.setAttribute("className","tableTitleMesTable");
			}else {
				alert('Tu navegador no puede manejar este script');
				return;
			}
			oTbody = document.getElementById("idTbody");
			oTd=document.getElementById("tdMes");
			//Pintamos el mes
			iMes=parseInt(arMes[0])-1;
			if(oTd.hasChildNodes()){
				oText = oTd.firstChild;
				oTd.removeChild(oText);
			}
			oText=oTd.appendChild(document.createTextNode(arMonths[iMes].toUpperCase()));
			//Pintamos los datos del festival	
			var oTable2;
			var oTbody2;
			var oTr2;
			var oTd2;
			var oDiv2 = document.getElementById("idTabla2");
			for(i=0;i<arLugar.length;i++){
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableFestivalName");			
				} else if (ie) {
					oTable2.setAttribute("className","tableFestivalName");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}				
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				//Nombre del festival
				oTd2=oTr2.appendChild(document.createElement("td"));
				oText=oTd2.appendChild(document.createTextNode(arNombre[i]));		
				//Lugar del festival
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}		
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[0]));	
				oTd2=oTr2.appendChild(document.createElement("td"));
				if (mozilla) {
					oTd2.setAttribute("class","tdLugarTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdLugarTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arLugar[i]));	
				//Fechas
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[1]));	
				arDiasAux = new Array();
				arDiasAux = arDias[i];
			    sStyleFechas = GetStyleFecha(arDiasAux.length);			
				for(z=0;z<arDiasAux.length;z++){
					oTd2=oTr2.appendChild(document.createElement("td"));
					if (mozilla) {
						oTd2.setAttribute("class",sStyleFechas);			
					} else if (ie) {
						oTd2.setAttribute("className",sStyleFechas);
					}else {
						alert('Tu navegador no puede manejar este script');
						return;
					}
					oText=oTd2.appendChild(document.createTextNode(arDiasAux[z]+ " "+arMonths[iMes]));	
				}
				//Grupos
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[2]));	
				arGruposAux = new Array();
				arListGruposAux = new Array();
				arGruposAux = arGrupos[i];
			    sStyleGrupos = GetStyleGrupos(arDiasAux.length);			
				for(z=0;z<arGruposAux.length;z++){
					oTd2=oTr2.appendChild(document.createElement("td"));
					if (mozilla) {
						oTd2.setAttribute("class",sStyleGrupos);			
					} else if (ie) {
						oTd2.setAttribute("className",sStyleGrupos);
					}else {
						alert('Tu navegador no puede manejar este script');
						return;
					}	
					oTableAux=oTd2.appendChild(document.createElement("table"));
					oTbodyAux=oTableAux.appendChild(document.createElement("tbody"));
					arListGruposAux = arGruposAux[z];
					for(t=0;t<arListGruposAux.length;t++){
						oTrAux=oTbodyAux.appendChild(document.createElement("tr"));
						oTdAux=oTrAux.appendChild(document.createElement("td"));			
						oTdAux.setAttribute("align","left");
						if (mozilla) {
							oTdAux.setAttribute("class","tdGruposTableInt");			
						} else if (ie) {
							oTdAux.setAttribute("className","tdGruposTableInt");
						}else {
							alert('Tu navegador no puede manejar este script');
							return;
						}			
						oText=oTdAux.appendChild(document.createTextNode(arListGruposAux[t]));	
					}
				}
				//Horario
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[3]));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdHorarioFesTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdHorarioFesTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arHorario[i]));	
				//Precio
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[4]));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdPrecioTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdPrecioTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arPrecio[i]));	
				//Venta
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[5]));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdVentaTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdVentaTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				sVentaAux = arVenta[i].toLowerCase();
				if(sVentaAux.indexOf("http")!=-1){
					oLink = oTd2.appendChild(document.createElement("a"));
					oLink.setAttribute("href",arVenta[i]);
					oLink.setAttribute("target","_blank");	
					oText=oLink.appendChild(document.createTextNode(arVenta[i]));	
				}else{
					oText=oTd2.appendChild(document.createTextNode(arVenta[i]));	
				}
				//Más Info
			    oTable2=oDiv2.appendChild(document.createElement("table"));
				if (mozilla) {
					oTable2.setAttribute("class","tableRowFes");			
				} else if (ie) {
					oTable2.setAttribute("className","tableRowFes");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}	
			    oTbody2=oTable2.appendChild(document.createElement("tbody"));
				oTr2=oTbody2.appendChild(document.createElement("tr"));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdTitRowTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdTitRowTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oText=oTd2.appendChild(document.createTextNode(arTituloTable[6]));
				oTd2=oTr2.appendChild(document.createElement("td"));
				oTd2.setAttribute("align","left");
				if (mozilla) {
					oTd2.setAttribute("class","tdMasinfoTable");			
				} else if (ie) {
					oTd2.setAttribute("className","tdMasinfoTable");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oLink = oTd2.appendChild(document.createElement("a"));
				oLink.setAttribute("href",arMasInfo[i]);
				oLink.setAttribute("target","_blank");	
				oText=oLink.appendChild(document.createTextNode(arMasInfo[i]));	
				if(i!=arLugar.length-1){
					oTr=oDiv2.appendChild(document.createElement("br"));
				}
			}//Fin for
			
			if(arDataMes.length>1){
				PaintPaginado(arDataMes.length);
			}
	
		}catch(err){
			alert(err.message);
		}
	}
	
	
	function FillSubtable(oSubTable,arGrupos){
		try{
			var oSubTbody;
			var oSubTr;
			var oSubTd;
			oSubTbody=oSubTable.appendChild(document.createElement("tbody"));
			for(z=0;z<arGrupos.length;z++){
				oSubTr=oSubTbody.appendChild(document.createElement("tr"));
				oSubTd=oSubTr.appendChild(document.createElement("td"));
				oSubTd.setAttribute("align","left");
				oText=oSubTd.appendChild(document.createTextNode(arGrupos[z])); 
			}
		}catch(err){
			alert(err.message);
		}
	}
	
	//Devolvemos un Array bidimensional
	function getMesesWithInfo(arInfo){
		try{
			var arMeses = arInfo[0];
			var arAnios = arInfo[9];
			var arFecha;
			var arResult = new Array();
			for(i=0;i<arMeses.length;i++){
				arFecha = new Array();
				if(arResult.length>0){
					if(!ExistFecha(arResult,arMeses[i],arAnios[i])){
						arFecha.push(arMeses[i]);
						arFecha.push(arAnios[i]);
						arResult.push(arFecha);
					}
				}else{
					arFecha.push(arMeses[i]);
					arFecha.push(arAnios[i]);
					arResult.push(arFecha);
				}
			}
			return arResult;
		}catch(err){
			alert(err.message);
		}
	}
	
	function ExistFecha(arFecha,sMes,sAnio){
		try{
			var bExist = false;
			var arOneDate;
			for(j=0;j<arFecha.length;j++){
				arOneDate=arFecha[j];
				if((arOneDate[0]==sMes)&&(arOneDate[1]==sAnio)){
					bExist = true;
					break;
				}
			}
			return bExist;
		}catch(err){
			alert(err.message);
		}	
	}
	
	function getStyleCelda(iCelda){
		try{
			var sStyle = '';
			switch (iCelda){
				case "0":
					sStyle="tdLugarTable";
					break;
				case "1":
					sStyle="tdFestivalTable";
					break;
				case "2":
					sStyle="tdDiasTable";
					break;
				case "3":
					sStyle="tdPrecioTable";
					break;
				case "4":
					sStyle="tdGruposTable";
					break;
				case "5":
					sStyle="tdMasinfoTable";
					break;
			}
		}catch(err){
			alert(err.message);
		}
	}
		
	function getData(){
		try{
			var arInfo = new Array();
			var arAuxDias;
			var arAuxGrupos;
			var arAuxGruposDia;
			var arDias;
			var arGrupos;
			var arFestival = new Array();	
			arMes = new Array();
			arLugar = new Array();
			arNombre = new Array();
			arAuxDiasFestival = new Array();
			arAuxDias = new Array();
			arDias = new Array();
			arAuxGrupos = new Array();
			arGrupos = new Array();
			arAuxGruposDia = new Array();
			arHorario = new Array();			
			arPrecio = new Array();
			arVenta = new Array();
			arMasInfo = new Array();
			arAnio = new Array();
			//obtenemos los festivales
			arFestival = xmlDocFestivales.getElementsByTagName("festival");
			for(i=0;i<arFestival.length;i++){
				arMes.push(arFestival[i].getElementsByTagName("mes")[0].firstChild.data);
				arLugar.push(arFestival[i].getElementsByTagName("lugar")[0].firstChild.data);
				arNombre.push(arFestival[i].getElementsByTagName("nombre")[0].firstChild.data);
				arAuxDiasFestival = new Array();
				arAuxDiasFestival =arFestival[i].getElementsByTagName("diaFestival");
				arAuxDias = new Array();
				arAuxGrupos = new Array();
				arAuxGruposDia = new Array();
				if(arAuxDiasFestival.length==1){
					arAux = new Array();
					arAuxDias.push(arAuxDiasFestival[0].getElementsByTagName("dia")[0].firstChild.data);
					arAuxGruposDia = arAuxDiasFestival[0].getElementsByTagName("grupo");
					for(z=0;z<arAuxGruposDia.length;z++){
						arAux.push(arAuxGruposDia[z].firstChild.data);
					}
					arAuxGrupos.push(arAux);
				}else{
					for(j=0;j<arAuxDiasFestival.length;j++){
						arAux = new Array();
						arAuxDias.push(arAuxDiasFestival[j].getElementsByTagName("dia")[0].firstChild.data);
						arAuxGruposDia = arAuxDiasFestival[j].getElementsByTagName("grupo");
						for(z=0;z<arAuxGruposDia.length;z++){
							arAux.push(arAuxGruposDia[z].firstChild.data);
						}
						arAuxGrupos.push(arAux);
					}
				}
				arDias.push(arAuxDias);
				arGrupos.push(arAuxGrupos);
				arHorario.push(arFestival[i].getElementsByTagName("horario")[0].firstChild.data);
				arPrecio.push(arFestival[i].getElementsByTagName("precio")[0].firstChild.data);
				arVenta.push(arFestival[i].getElementsByTagName("venta")[0].firstChild.data);
				arMasInfo.push(arFestival[i].getElementsByTagName("masinfo")[0].firstChild.data);
				arAnio.push(arFestival[i].getElementsByTagName("anio")[0].firstChild.data);					
			}
			arInfo.push(arMes);
			arInfo.push(arNombre);
			arInfo.push(arLugar);
			arInfo.push(arDias);
			arInfo.push(arGrupos);
			arInfo.push(arHorario);
			arInfo.push(arPrecio);
			arInfo.push(arVenta);
			arInfo.push(arMasInfo);
			arInfo.push(arAnio);
			return arInfo;	
		}catch(err){
			alert(err.message);
		}
	}
	
	
	function changeMes(){
		try{
			var oCombo = document.getElementById("idMeses");
			var arDataMes;
			var iMes=parseInt(oCombo.value.substring(4))+1;
			var sCurrentYear = oCombo.value.substring(0,4);
			arDataMes=GetDataMes(iMes,sCurrentYear);
			CleanDiv();
			PaintTable(arDataMes);
		}catch(err){
			alert(err.message);	
		}
		
	}
	
	//Función que limpia los datos de los festivales excepto el mes
	function CleanDiv(){
		try{
			var oDiv = document.getElementById("idTabla2");
			oDiv.innerHTML="";
			var oDiv2 = document.getElementById("idTabla3");
			oDiv2.innerHTML="";
		}catch(err){
			alert(err.message);	
		}	
	}
	
	//Función que obtiene el estilo de las fechas para calcular el ancho
	function GetStyleFecha(sNum){
		var sRes = 1;
		switch(sNum){
			case 1: 
				sRes = "tdFechaFesTable";
				break;
			case 2:
				sRes = "tdFechaFesTable2";
				break;
			case 3:
				sRes = "tdFechaFesTable3";
				break;			
			};
			return sRes;
	}
	
	//Función que obtiene el estilo de las fechas para calcular el ancho
	function GetStyleGrupos(sNum){
		var sRes = 1;
		switch(sNum){
			case 1: 
				sRes = "tdGruposTable";
				break;
			case 2:
				sRes = "tdGruposTable2";
				break;
			case 3:
				sRes = "tdGruposTable3";
				break;			
			};
			return sRes;
	}
	
//Función que pinta el paginado de festivales en caso de tenerlo
	function PaintPaginado(iLinksPag){
		try{
			var oDiv = document.getElementById("idTabla3");
			var oTable = document.createElement("table");
			var oTbody=oTable.appendChild(document.createElement("tbody"));
			var oTr = oTbody.appendChild(document.createElement("tr"));
			var oTd;
			var oLink;
			var oText;
			var iTextLink;
			for(var i=0;i<iLinksPag;i++){
				oTd = oTr.appendChild(document.createElement("td"));
				if (mozilla) {
					oTd.setAttribute("class","tdLinksPaginas");
					//oTd.setAttribute("idLink",i);
				} else if (ie) {
					oTd.setAttribute("className","tdLinksPaginas");
					//oTd.setAttribute("idLink",i);
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}
				oLink = oTd.appendChild(document.createElement("a"));
				oLink.setAttribute("idLink",i);
				oLink.setAttribute("href","#_ancla");
				//Se añaden los eventos
				if(ie){
					oLink.attachEvent("onclick",ChangePage);
				}else{ 
					 if (mozilla) {
						oLink.onclick=new function(){
							oLink.addEventListener("click",ChangePageFirefox, false);
						}
					  }else {
						alert('Tu navegador no puede manejar este script');
						return;
					  }
			    }
				iTextLink = parseInt(i) + parseInt(1);
				oText = oLink.appendChild(document.createTextNode(iTextLink));
			}
			oDiv.appendChild(oTable);
		}catch(err){
			alert(err.message);
		}
	}
	
	function ChangePage(){
		var iLink = event.srcElement.getAttribute("idLink");
		var oCombo = document.getElementById("idMeses");
		var arDataMes;
		var iMes=parseInt(oCombo.value.substring(4))+1;
		var sCurrentYear = oCombo.value.substring(0,4);
		CleanDiv();
		arDataMes=GetDataMes(iMes,sCurrentYear);
		PaintTablePagina(arDataMes,iLink);
	}
	
	function ChangePageFirefox(){
		var iText = this.innerHTML;
		var iLink;
		iLink = parseInt(iText) - parseInt(1);
		var oCombo = document.getElementById("idMeses");
		var arDataMes;
		var iMes=parseInt(oCombo.value.substring(4))+1;
		var sCurrentYear = oCombo.value.substring(0,4);
		CleanDiv();
		arDataMes=GetDataMes(iMes,sCurrentYear);
		PaintTablePagina(arDataMes,iLink);
	}
			