// JavaScript Document
var xmlDocAgendaConciertos;
var mozilla;
var ie;
var sCurrentMonth;
var sCurrentYear;
var arDia;
var arMes;
var arAnio;
var arLugar;
var arWebSala;
var arHora;
var arGrupo;
var arWebGrupo;
var arPrecio;
var arVenta;
var today = new Date();
var sMonth = today.getMonth();
sCurrentMonth = today.getMonth();		
var sDayMonth = today.getDate();
var sYear = today.getFullYear();
sCurrentYear = today.getFullYear();
//Primer mes del año
var iMonthIni = 0;
var iNumDaysMonth = getDays(iMonthIni,sYear);
var dayIniMonth = new Date(sYear,iMonthIni,"1");
var dayFinMonth = new Date(sYear,iMonthIni,iNumDaysMonth);
var oDate;
mozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
ie = (typeof window.ActiveXObject != 'undefined');
function importaXMLAgendaConciertos(fichero,funcion) {
  if (mozilla) {
    xmlDocAgendaConciertos = document.implementation.createDocument("", "", null)
    xmlDocAgendaConciertos.load(fichero);
    xmlDocAgendaConciertos.onload = function()
    {
      funcion(sCurrentMonth,sCurrentYear);
    }
  } else if (ie) {
    xmlDocAgendaConciertos = new ActiveXObject("Microsoft.XMLDOM");
    xmlDocAgendaConciertos.async = false;
    xmlDocAgendaConciertos.load(fichero);
    if (xmlDocAgendaConciertos.readyState == 4) funcion(sCurrentMonth,sCurrentYear);
  }
  else {
    alert('Tu navegador no puede manejar este script');
    return;
  }
}

function importaAgendaConciertosXML(fichero) {
  importaXMLAgendaConciertos(fichero,PaintScreen);
}

function PaintScreen(sMes,sYear){
	try{	
		PaintAllCalendarios(iMonthIni,sYear,iNumDaysMonth);
		PaintAgendaMes(sMes,sYear)
	}catch(err){
		alert(err.message);
	}
}

function PaintAgendaMes(sMes,sYear){
	try{
		DeleteDivConciertos();
		getInfoConciertosMes(sMes,sYear);
		BuildInfoFechaConciertoMes(sMes,sYear);
		//Se construye la info de cada concierto
		for(var i=0;i<arDia.length;i++){
			BuiltInfoConcierto(i);
		}
	}catch(err){
		alert(err.message);
	}
}

function PaintAgendaDia(sDia,sMes,sYear){
	try{
		DeleteDivConciertos();
		getInfoConciertosDia(sDia,sMes,sYear);
		//Se construye la info de cada concierto
		BuildInfoFechaConciertoDay(sDia,sMes,sYear);
		for(var i=0;i<arDia.length;i++){
			BuiltInfoConcierto(i);
		}
	}catch(err){
		alert(err.message);
	}
}

//Función que pinta el título del mes seleccionado
function BuildInfoFechaConciertoMes(sMes,sYear){
		try{
			var oDiv;
			var sTexto = "Conciertos para el mes de "+arMonths[sMes]+ " del "+sYear;
			oDiv = document.getElementById("dataFechaConciertos");
			oDiv.innerHTML="";
			oDiv.appendChild(document.createTextNode(sTexto))
		}catch(err){
			alert(err);
		}		
	}

//Función que pinta el título un día seleccionado
function BuildInfoFechaConciertoDay(sDia,sMes,sYear){
		try{
			var oDiv;
			var sTexto = "Conciertos para el día "+sDia+" de "+arMonths[sMes]+ " del "+sYear;
			oDiv = document.getElementById("dataFechaConciertos");
			oDiv.innerHTML="";
			oDiv.appendChild(document.createTextNode(sTexto))
		}catch(err){
			alert(err);
		}		
	}

//Función que escribe la info de cada concierto
function BuiltInfoConcierto(iIndex){
	try{
		var oDiv;
		var oTable;
		var oTbody;
		var oTr;
		var oTd;
		var oLink;
		var oText;
		oDiv = document.getElementById("dataConciertos");
		oTable=oDiv.appendChild(document.createElement("table"));
		oTbody=oTable.appendChild(document.createElement("tbody"));
		<!--Primera Fila -->
		oTr=oTbody.appendChild(document.createElement("tr"));
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");
		oText=oTd.appendChild(document.createTextNode("Lugar: "));
		if (mozilla) {
			oTd.setAttribute("class","tdWidthTit");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthTit");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}			
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");
		oLink = oTd.appendChild(document.createElement("a"));
		oLink.setAttribute("href",arWebSala[iIndex]);
		oLink.setAttribute("target","_ top");
		oText=oLink.appendChild(document.createTextNode(arLugar[iIndex]));
		if (mozilla) {
			oTd.setAttribute("class","tdWidthDat");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthDat");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}				
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");
		oText=oTd.appendChild(document.createTextNode("Grupo: "));		
		if (mozilla) {
			oTd.setAttribute("class","tdWidthTit");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthTit");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");
		oLink = oTd.appendChild(document.createElement("a"));
		oLink.setAttribute("href",arWebGrupo[iIndex]);
		oLink.setAttribute("target","_ top");
		oText=oLink.appendChild(document.createTextNode(arGrupo[iIndex]));
		if (mozilla) {
			oTd.setAttribute("class","tdWidthDat");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthDat");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}
		<!--Fin Primera Fila -->
		<!--Segunda Fila -->
		oTr=oTbody.appendChild(document.createElement("tr"));
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");
		oText=oTd.appendChild(document.createTextNode("Fecha: "));
		if (mozilla) {
			oTd.setAttribute("class","tdWidthTit");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthTit");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}			
		oTd=oTr.appendChild(document.createElement("td")); 
		oText=oTd.appendChild(document.createTextNode(CalculateDayOfWeek(arAnio[iIndex],arMes[iIndex],arDia[iIndex])+" "+arDia[iIndex]+"/"+arMes[iIndex]+"/"+arAnio[iIndex]));
		if (mozilla) {
			oTd.setAttribute("class","tdWidthDat");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthDat");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}				
		oTd=oTr.appendChild(document.createElement("td"));	
		oTd.setAttribute("align","left");
		oText=oTd.appendChild(document.createTextNode("Hora: "));		
		if (mozilla) {
			oTd.setAttribute("class","tdWidthTit");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthTit");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");
		oText=oTd.appendChild(document.createTextNode(arHora[iIndex]));
		if (mozilla) {
			oTd.setAttribute("class","tdWidthDat");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthDat");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}
		<!--Fin Segunda Fila -->
		<!--Tercera Fila -->
		oTr=oTbody.appendChild(document.createElement("tr"));
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");		
		oText=oTd.appendChild(document.createTextNode("Precio: "));
		if (mozilla) {
			oTd.setAttribute("class","tdWidthTit");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthTit");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}			
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");		
		oText=oTd.appendChild(document.createTextNode(arPrecio[iIndex].replace("euros","€")));
		if (mozilla) {
			oTd.setAttribute("class","tdWidthDat");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthDat");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}				
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");		
		oText=oTd.appendChild(document.createTextNode("Venta: "));		
		if (mozilla) {
			oTd.setAttribute("class","tdWidthTit");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthTit");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}
		oTd=oTr.appendChild(document.createElement("td"));
		oTd.setAttribute("align","left");		
		oText=oTd.appendChild(document.createTextNode(arVenta[iIndex]));
		if (mozilla) {
			oTd.setAttribute("class","tdWidthDat");			
		} else if (ie) {
			oTd.setAttribute("className","tdWidthDat");
		}else {
			alert('Tu navegador no puede manejar este script');
			return;
		}
		<!--Fin Tercera Fila -->
		oDiv.appendChild(document.createElement("hr"));			
	}catch(err){
		alert(err.message);
	}
}

//Para mapear la posición en el calendario de los días
var arHeaderWeek = new Array();
arHeaderWeek.push("L");
arHeaderWeek.push("M");
arHeaderWeek.push("X");
arHeaderWeek.push("J");
arHeaderWeek.push("V");
arHeaderWeek.push("S");
arHeaderWeek.push("D");

//Para mapear la posición en el calendario de los días
var arDayShortOfWeek = new Array(7);
arDayShortOfWeek[0]="D";
arDayShortOfWeek[1]="L";
arDayShortOfWeek[2]="M";
arDayShortOfWeek[3]="X";
arDayShortOfWeek[4]="J";
arDayShortOfWeek[5]="V";
arDayShortOfWeek[6]="S";

//Mapeo de días de semana
var arDayOfWeek = new Array(7);
arDayOfWeek[0]="Domingo";
arDayOfWeek[1]="Lunes";
arDayOfWeek[2]="Martes";
arDayOfWeek[3]="Miercoles";
arDayOfWeek[4]="Jueves";
arDayOfWeek[5]="Viernes";
arDayOfWeek[6]="Sabado";

//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";

//Función que nos indica si es bisiesto o no el año
function EsBisiesto(year) {
	if (year % 4 == 0){
		return true
	}else{
		return false
	}
}

//Función que nos obtiene el número de dias del año
function getDays(month, year) {
	var ar = new Array(12)
	ar[0] = 31 // Enero
	ar[1] = (EsBisiesto(year)) ? 29 : 28 // Febrero
	ar[2] = 31 // Marzo
	ar[3] = 30 // Abril
	ar[4] = 31 // Mayo
	ar[5] = 30 // Junio
	ar[6] = 31 // Julio
	ar[7] = 31 // Agosto
	ar[8] = 30 // Septiembre
	ar[9] = 31 // Octubre
	ar[10] = 30 // Noviembre
	ar[11] = 31 // Diciembre
	return ar[month]
} 
	
	function PaintCalendario(mes,anio,numDias,oControl){
		try{
			var oDiv;
			var oTable;
			var oTbody;
			var oTr;
			var oTd;
			var sText;
			//Se pinta el Mes
			var sDivTit ="Tit"+oControl;
			var oDivTit = document.getElementById(sDivTit);
			oDivTit.onmouseover=new function(){
				oDivTit.style.cursor = "pointer";
			}
			oDivTit.onclick=function(){
				PaintAgendaMes(mes,anio);
			}
			oAnchor = oDivTit.appendChild(document.createElement("a"));
			var sNameMonth = arMonths[mes];
			sText=oAnchor.appendChild(document.createTextNode(sNameMonth+" "+anio));
			oAnchor.setAttribute("alt", "Ver Conciertos "+sNameMonth+" "+anio)
			if (mozilla) {
				oAnchor.setAttribute("class","tdTitCal");			
			} else if (ie) {
				oAnchor.setAttribute("className","tdTitCal");
			}else {
				alert('Tu navegador no puede manejar este script');
				return;
			}		
			//Se pinta el area del Calendario
			oDiv = document.getElementById(oControl);
			oTable = oDiv.appendChild(document.createElement("table"));
			//oTable.style.border = "2px solid #FF0000";
			if (mozilla) {
				oTable.setAttribute("class","divDiasCal");			
			} else if (ie) {
				oTable.setAttribute("className","divDiasCal");
			}else {
				alert('Tu navegador no puede manejar este script');
				return;
			}				
			oTbody = oTable.appendChild(document.createElement("tbody"));
			//Se pinta la cabecera con los dias en formato corto
			oTr = oTbody.appendChild(document.createElement("tr"));
			for(var i=0;i<7;i++){
				oTd = oTr.appendChild(document.createElement("td"));
				if (mozilla) {
					oTd.setAttribute("class","divNombreDiasCortos");			
				} else if (ie) {
					oTd.setAttribute("className","divNombreDiasCortos");
				}else {
					alert('Tu navegador no puede manejar este script');
					return;
				}					
				sText=oTd.appendChild(document.createTextNode(arHeaderWeek[i]))
			}
			//Obtenemos el primer dia de ese mes para saber que es
			var numCell = getNumCellsPaint(anio,mes);
			var bMoreRow =true;
			var bPaintCell =false;
			var iIndexRow = 0;
			var sTextDay= 0;
			while(bMoreRow){
				oTr = oTbody.appendChild(document.createElement("tr"));
				if(iIndexRow==0){//La primera fila
					for(var i=0;i<7;i++){
						oTd = oTr.appendChild(document.createElement("td"));
						if (mozilla) {
							oTd.setAttribute("class","divFontDiasCal");			
						} else if (ie) {
							oTd.setAttribute("className","divFontDiasCal");
						}else {
							alert('Tu navegador no puede manejar este script');
							return;
						}	
						if(!bPaintCell){
							if(parseInt(i)==parseInt(numCell)){
								bPaintCell=true;
								sTextDay = parseInt(sTextDay)+parseInt(1);
								if(ThereIsConcertsDay(sTextDay,mes,anio)){
									oTd.style.background = "orange";
								}else{
									oTd.style.background = "#D792C1";
								}
								oTd.setAttribute("idElem",sTextDay);
								oTd.setAttribute("idMes",mes);
								oTd.setAttribute("idAnio",anio);
								oTd.setAttribute("ColorFondo",oTd.style.background);
								sText=oTd.appendChild(document.createTextNode(sTextDay));
								//oTd.onmouseover=new function(){
								//	oTd.style.cursor = "pointer";
								//}
								if(ie){
									oTd.attachEvent("onclick",PaintDay);
									oTd.attachEvent("onmouseover",LightFondoCelda);
									oTd.attachEvent("onmouseout",NormalFondoCelda);
								}else if (mozilla) {
										oTd.addEventListener("click",PaintDayFirefox, false);
										oTd.addEventListener("mouseover",LightFondoCeldaFirefox, false);
										oTd.addEventListener("mouseout",NormalFondoCeldaFirefox, false);
									  }else {
										alert('Tu navegador no puede manejar este script');
										return;
									   }				
														
							}
						}else{
							sTextDay = parseInt(sTextDay)+parseInt(1);
							if(ThereIsConcertsDay(sTextDay,mes,anio)){
								oTd.style.background = "orange";
							}else{
								oTd.style.background = "#D792C1";
							}
							oTd.setAttribute("idElem",sTextDay);
							oTd.setAttribute("idMes",mes);
							oTd.setAttribute("idAnio",anio);
							oTd.setAttribute("ColorFondo",oTd.style.background);
							sText=oTd.appendChild(document.createTextNode(sTextDay));
							oTd.value=sTextDay;
							//oTd.onmouseover=new function(){
							//	oTd.style.cursor = "pointer";
							//}
							if(ie){
								oTd.attachEvent("onclick",PaintDay);
								oTd.attachEvent("onmouseover",LightFondoCelda);
								oTd.attachEvent("onmouseout",NormalFondoCelda);
							}else if (mozilla) {
									oTd.addEventListener("click",PaintDayFirefox, false);
									oTd.addEventListener("mouseover",LightFondoCeldaFirefox, false);
									oTd.addEventListener("mouseout",NormalFondoCeldaFirefox, false);
								  }else {
									alert('Tu navegador no puede manejar este script');
									return;
								   }																													
						}			
					}
				}else{//El resto de Filas
					for(var i=0;i<7;i++){
						oTd = oTr.appendChild(document.createElement("td"));
						if (mozilla) {
							oTd.setAttribute("class","divFontDiasCal");			
						} else if (ie) {
							oTd.setAttribute("className","divFontDiasCal");
						}else {
							alert('Tu navegador no puede manejar este script');
							return;
						}	
						sTextDay = parseInt(sTextDay)+parseInt(1);
						if(bPaintCell){
							if(parseInt(sTextDay)<parseInt(numDias)){
								if(ThereIsConcertsDay(sTextDay,mes,anio)){
									oTd.style.background = "orange";
								}else{
									oTd.style.background = "#D792C1";
								}
								oTd.setAttribute("idElem",sTextDay);
								oTd.setAttribute("idMes",mes);
								oTd.setAttribute("idAnio",anio);
								oTd.setAttribute("ColorFondo",oTd.style.background);
								sText=oTd.appendChild(document.createTextNode(sTextDay));
								//oTd.onmouseover=new function(){
								//	oTd.style.cursor = "pointer";
								//}
								if(ie){
									oTd.attachEvent("onclick",PaintDay);
									oTd.attachEvent("onmouseover",LightFondoCelda);
									oTd.attachEvent("onmouseout",NormalFondoCelda);
								}else if (mozilla) {
									oTd.onclick=new function(){
										oTd.addEventListener("click",PaintDayFirefox, false);
										oTd.addEventListener("mouseover",LightFondoCeldaFirefox, false);
										oTd.addEventListener("mouseout",NormalFondoCeldaFirefox, false);
									}
								  }else {
									alert('Tu navegador no puede manejar este script');
									return;
								   }																																																						
							}else{
								if(ThereIsConcertsDay(sTextDay,mes,anio)){
									oTd.style.background = "orange";
								}else{
									oTd.style.background = "#D792C1";
								}
								oTd.setAttribute("idElem",sTextDay);
								oTd.setAttribute("idMes",mes);
								oTd.setAttribute("idAnio",anio);
								oTd.setAttribute("ColorFondo",oTd.style.background);
								sText=oTd.appendChild(document.createTextNode(sTextDay));
								//oTd.onmouseover=new function(){
								//	oTd.style.cursor = "pointer";
								//}
								if(ie){
									oTd.attachEvent("onclick",PaintDay);
									oTd.attachEvent("onmouseover",LightFondoCelda);
									oTd.attachEvent("onmouseout",NormalFondoCelda);
								}else if (mozilla) {
									oTd.onclick=new function(){
										oTd.addEventListener("click",PaintDayFirefox, false);
										oTd.addEventListener("mouseover",LightFondoCeldaFirefox, false);
										oTd.addEventListener("mouseout",NormalFondoCeldaFirefox, false);
									}
								  }else {
									alert('Tu navegador no puede manejar este script');
									return;
								   }																												
								bPaintCell=false;
								bMoreRow=false;
							}
						}						
					}
				}
				iIndexRow = parseInt(iIndexRow)+parseInt(1);
			}
		}catch(err){
			alert(err.message);
		}
	}
	
	//Devuelve el número de la celda en la que se empieza a pintar
	function getNumCellsPaint(anio,mes){
		try{
			var nDate = new Date(anio,mes,"1");
			var sFisrtDay = nDate.getDay();
			var numCell = 0;
			switch(sFisrtDay){
				case 0:
					numCell = 6;
					break;
				case 1:
					numCell = 0;
					break;
				case 2:
					numCell = 1;
					break;
				case 3:
					numCell = 2;
					break;
				case 4:
					numCell = 3;
					break;
				case 5:
					numCell = 4;
					break;
				case 6:
					numCell = 5;
					break;																														
			}
			return numCell;
		}catch(err){
			alert(err.message);
		}
	}
	
	
	function PaintDay(){
		try{
			PaintAgendaDia(event.srcElement.getAttribute("idElem"),event.srcElement.getAttribute("idMes"),event.srcElement.getAttribute("idAnio"));			
		}catch(err){
			alert(err.message);
		}
	}
	
	function LightFondoCelda(){
		try{
			event.srcElement.style.cursor="pointer";
			//event.srcElement.style.background="orange";
			event.srcElement.style.background="#FFCCFF";
			event.srcElement.style.color="blue";
		}catch(err){
			alert(err.message);
		}
	
	}
	
	function LightFondoCeldaFirefox(){
		try{
			//this.style.backgroundColor = "orange";
			//this.style.backgroundColor = "#FFCCFF";
			//this.style.color = "blue";
			this.style.cursor = "pointer";
		}catch(err){
			alert(err.message);
		}
	
	}
	
	function NormalFondoCeldaFirefox(){
		try{
			//this.style.backgroundColor = this.ColorFondo;
			//this.style.color = "#0000CC";
		}catch(err){
			alert(err.message);
		}
	
	}
	
	function NormalFondoCelda(){
		try{
			event.srcElement.style.background=event.srcElement.ColorFondo;
			event.srcElement.style.color="#0000CC";
		}catch(err){
			alert(err.message);
		}
	
	}
	
	function PaintDayFirefox(){
		try{
			var oTextHtml = this.parentNode.innerHTML;
			var iMes = oTextHtml.indexOf("idmes=");
			var oMes = oTextHtml.substring(iMes+7);
			var iYear = oTextHtml.indexOf("idanio=");
			var oYear = oTextHtml.substring(iYear+8);
			PaintAgendaDia(this.innerHTML,oMes.substring(0,oMes.indexOf("\"")),oYear.substring(0,oYear.indexOf("\"")));	
		}catch(err){
			alert(err.message);
		}
	}
	
	//Función que obtiene la info del disco de ese mes
	function getInfoConciertosMes(sMonth,sYear){
		try{
			arDia = new Array();
			arMes= new Array();
			arAnio= new Array();
			arLugar= new Array();
			arWebSala= new Array();
			arHora= new Array();
			arGrupo= new Array();
			arWebGrupo= new Array();
			arPrecio= new Array();
			arVenta= new Array();
			arListaConciertosPaint = new Array();
			var arConciertos = new Array();
			arConciertos = xmlDocAgendaConciertos.getElementsByTagName("concierto");
			for(var i=0;i<arConciertos.length;i++){
				if((arConciertos[i].getElementsByTagName("mes")[0].firstChild.data==sMonth+1)&&(arConciertos[i].getElementsByTagName("anio")[0].firstChild.data==sYear)){
					arDia.push(arConciertos[i].getElementsByTagName("dia")[0].firstChild.data);
					arMes.push(arConciertos[i].getElementsByTagName("mes")[0].firstChild.data);
					arAnio.push(arConciertos[i].getElementsByTagName("anio")[0].firstChild.data);
					arLugar.push(arConciertos[i].getElementsByTagName("lugar")[0].firstChild.data);
					arWebSala.push(arConciertos[i].getElementsByTagName("webSala")[0].firstChild.data);
					arHora.push(arConciertos[i].getElementsByTagName("hora")[0].firstChild.data);
					arGrupo.push(arConciertos[i].getElementsByTagName("grupo")[0].firstChild.data);
					arWebGrupo.push(arConciertos[i].getElementsByTagName("webGrupo")[0].firstChild.data);
					arPrecio.push(arConciertos[i].getElementsByTagName("precio")[0].firstChild.data);
					arVenta.push(arConciertos[i].getElementsByTagName("venta")[0].firstChild.data);
				}
			}
		}catch(err){
			alert(err.message);
		}
	}
	
	//Función que obtiene la info del disco de ese dçia
	function getInfoConciertosDia(sDay,sMonth,sYear){
		try{
			arDia = new Array();
			arMes= new Array();
			arAnio= new Array();
			arLugar= new Array();
			arWebSala= new Array();
			arHora= new Array();
			arGrupo= new Array();
			arWebGrupo= new Array();
			arPrecio= new Array();
			arVenta= new Array();
			arListaConciertosPaint = new Array();
			var arConciertos = new Array();
			var sMesCompare =parseInt(sMonth)+parseInt(1);
			arConciertos = xmlDocAgendaConciertos.getElementsByTagName("concierto");
			for(var i=0;i<arConciertos.length;i++){
				if((arConciertos[i].getElementsByTagName("dia")[0].firstChild.data.toString()==sDay.toString())&&(arConciertos[i].getElementsByTagName("mes")[0].firstChild.data.toString()==sMesCompare.toString())&&(arConciertos[i].getElementsByTagName("anio")[0].firstChild.data.toString()==sYear.toString())){
					arDia.push(arConciertos[i].getElementsByTagName("dia")[0].firstChild.data);
					arMes.push(arConciertos[i].getElementsByTagName("mes")[0].firstChild.data);
					arAnio.push(arConciertos[i].getElementsByTagName("anio")[0].firstChild.data);
					arLugar.push(arConciertos[i].getElementsByTagName("lugar")[0].firstChild.data);
					arWebSala.push(arConciertos[i].getElementsByTagName("webSala")[0].firstChild.data);
					arHora.push(arConciertos[i].getElementsByTagName("hora")[0].firstChild.data);
					arGrupo.push(arConciertos[i].getElementsByTagName("grupo")[0].firstChild.data);
					arWebGrupo.push(arConciertos[i].getElementsByTagName("webGrupo")[0].firstChild.data);
					arPrecio.push(arConciertos[i].getElementsByTagName("precio")[0].firstChild.data);
					arVenta.push(arConciertos[i].getElementsByTagName("venta")[0].firstChild.data);
				}
			}
		}catch(err){
			alert(err.message);
		}
	}
	
	function ThereIsConcertsDay(sDay,sMonth,sYear){
			try{
				var bExist=false;
				var arConciertos = new Array();
				var sMesCompare =parseInt(sMonth)+parseInt(1);
				arConciertos = xmlDocAgendaConciertos.getElementsByTagName("concierto");
				for(var i=0;i<arConciertos.length&&!bExist;i++){
					if((arConciertos[i].getElementsByTagName("dia")[0].firstChild.data.toString()==sDay.toString())&&(arConciertos[i].getElementsByTagName("mes")[0].firstChild.data.toString()==sMesCompare.toString())&&(arConciertos[i].getElementsByTagName("anio")[0].firstChild.data.toString()==sYear.toString())){
						bExist = true;
					}			
				}
				return bExist;
			}catch(err){
				alert(err.message);
			}
		}
	
	function DeleteDivConciertos(){
	try{
		var oDiv = document.getElementById('dataConciertos');
		oDiv.innerHTML="";
	}catch(err){
		alert(err.message);
	}
}

//calcula el dia de la semana
function CalculateDayOfWeek(sYear,sMes,sDay){
		try{
			var oFecha = new Date(sYear,sMes-1,sDay);
			var numdia = oFecha.getDay();
			if ( numdia == 0) {
				nomdia = "Domingo"
			}
			if ( numdia == 1) {
				nomdia = "Lunes"
			}
			if ( numdia == 2) {
				nomdia = "Martes"
			}
			if ( numdia == 3) {
				nomdia = "Miercoles"
			}
			if ( numdia == 4) {
				nomdia = "Jueves"
			}
			if ( numdia == 5) {
				nomdia = "Viernes"
			}
			if ( numdia == 6) {
				nomdia = "Sabado"
			}
			return nomdia
		}catch(err){
			alert(err.message);
		}
		
		function mod(x, x_div){   
        for (var i=x; i>=x_div; i -= x_div);   
                return i;
		}
}

function PaintAllCalendarios(iMonthIni,sYear,iNumDaysMonth){
	try{
		//Pintamos los calendarios
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario1");
		//Febrero
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario2");
		//Marzo
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario3");
		//Abril
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario4");
		//Mayo
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario5");
		//Junio
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario6");
		//Julio
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario7");
		//Agosto
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario8");
		//Septiembre
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario9");
		//Octubre
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario10");
		//Noviembre
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario11");
		//Diciembre
		iMonthIni = parseInt(iMonthIni)+parseInt(1);
		iNumDaysMonth = getDays(iMonthIni,sYear);
		PaintCalendario(iMonthIni,sYear,iNumDaysMonth,"calendario12");
	}catch(err){
		alert(err.message);
	}	
}

