var now = new Date();
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

if (dayNames[now.getDay()] == "Monday" || dayNames[now.getDay()] == "Tuesday") {
	xmlder = "../programacion/mie_jue.xml"
}
else if (dayNames[now.getDay()] == "Wednesday" || dayNames[now.getDay()] == "Thursday") {
	xmlder = "../programacion/fin.xml"
}	
else if (dayNames[now.getDay()] == "Friday" || dayNames[now.getDay()] == "Saturday" || dayNames[now.getDay()] == "Sunday") {
	xmlder = "../programacion/lun_mar.xml"
}

if (window.XMLHttpRequest) { 
	xmlhttp=new XMLHttpRequest(); 
}
else { 
	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
xmlhttp.open("GET",xmlder,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

var x=xmlDoc.getElementsByTagName("evento");
var y=xmlDoc.getElementsByTagName("catalogo");
j = 0;

document.write(
	"<h2>" + y[j].getElementsByTagName("fechas")[0].childNodes[0].nodeValue + 
	"<br /> <span class=\"nota\"> A partir de las 12:00 hrs. Programación sujeta a cambios. </span><br /> </h2>"
);

for (i=0; i < x.length; i++) {
	
    if (i%2) {
	parnon = "par"
    }
    else {
	parnon = "non"
    }
    
    document.write("<ul>");
    
    document.write (
        "<li class=\""+ parnon +"\">"
    );

    barro = x[i].getElementsByTagName("barra")[0];
    if (barro.childNodes.length) {
	document.write (
            "<strong><span class=\"nota\">" +
                x[i].getElementsByTagName("barra")[0].childNodes[0].nodeValue +
                "</span></strong><br /><br />"
        );
    } else {}

    
    serio = x[i].getElementsByTagName("serie")[0];
    if (serio.childNodes.length) {
	document.write(
	    "Serie:  <strong>" +
		x[i].getElementsByTagName("serie")[0].childNodes[0].nodeValue + 
		"</strong><br />"
	);
    } else {}

    programo = x[i].getElementsByTagName("programa")[0];
    if (programo.childNodes.length) {
	document.write(
    	    "Programa: <em>" + 
    		x[i].getElementsByTagName("programa")[0].childNodes[0].nodeValue +
    		"</em> <br />"
	);
    } else {}
    
    duraciono = x[i].getElementsByTagName("duracion")[0];
    if (duraciono.childNodes.length) {
	document.write(
	    "<span class=\"nota\"> Duración: " + 
    		x[i].getElementsByTagName("duracion")[0].childNodes[0].nodeValue +
    		"<br />"
	);
    } else {}
  
    prodo = x[i].getElementsByTagName("prod")[0];
    if (prodo.childNodes.length) {
    	document.write(
    	    "Año de producción: " +
    		x[i].getElementsByTagName("prod")[0].childNodes[0].nodeValue +
    		"<br />"
    	);
    } else {}

    disco = x[i].getElementsByTagName("disciplina")[0];
    if (disco.childNodes.length) {
        document.write(
            "Disciplina artística: " +
                x[i].getElementsByTagName("disciplina")[0].childNodes[0].nodeValue +
                "</span> <br />"
        );
    } else {}
		
    extro = x[i].getElementsByTagName("extra")[0];
    if (extro.childNodes.length) {
    	document.write(
    	    "<span class=\"nota\">" +
    		x[i].getElementsByTagName("extra")[0].childNodes[0].nodeValue + "</span><br />"
    	);
    } else {}
    document.write(
	"<br /> <span class=\"nota\"><strong> Horario: " +
	    x[i].getElementsByTagName("horario")[0].childNodes[0].nodeValue +
	    "</strong></span><br />" );
    document.write("<br />");
    document.write("</li>")
    document.write("</ul>");
}

