var getRecordatorio = null;
var xmlRecordatorio = null;

function CrearRecordatorio(){
	if (window.XMLHttpRequest){
		getRecordatorio=new XMLHttpRequest()
	}else if (window.ActiveXObject){
		getRecordatorio=new ActiveXObject("Microsoft.XMLHTTP")
	}
	if (getRecordatorio){
		var url="celebracion.xml";
		getRecordatorio.onreadystatechange=CambioDeEstadoRecordatorio;
		getRecordatorio.open("GET",url,true);
		getRecordatorio.send(null);
	}else{
		alert ("Tu explorador no soporta XMLHttpRequest");
	}
}

function CambioDeEstadoRecordatorio(){
	if (getRecordatorio.readyState == 4){
		xmlRecordatorio = getRecordatorio.responseXML;
		xmlRecordatorio = xmlRecordatorio.getElementsByTagName('hecho');
		setRecordar();
	} 
} 

function setRecordar() 
{
	var QueMes = 0;
	var now = new Date()
	var anio = now.getYear()
	if (anio < 1000) {anio+=1900}
	var mes = now.getMonth()+QueMes
	if (now.getMonth()+QueMes > 11) {mes-=12;anio++}
	if (now.getMonth()+QueMes < 0) {mes+=12;anio--}
	var fecha = now.getDate();
	
	drawMensaje(mes+1, fecha);
}

function drawMensaje(mes, dia) {
var codigo = ""
var strfechahoy = dia.toString() + '-' + mes.toString();

for (i=0;i<xmlRecordatorio.length;i++){
	var strfecha = xmlRecordatorio[i].getAttribute('fecha');
	var strdescripcion = xmlRecordatorio[i].getAttribute('descripcion');
	var strimagen = xmlRecordatorio[i].getAttribute('imagen');
	
	strdescripcion = reemplazar(strdescripcion, "[", "<");
    strdescripcion = reemplazar(strdescripcion, "]", ">");
	
	if (strfechahoy == strfecha)
	{
		codigo += '<table width="100%" class="tabla_recordar">';
		codigo += '<tr>';
		codigo += '<td align="left"><img src="imagen-recordar/' + strimagen + '" class="alignleft" />' + strdescripcion  +'</td>';
		codigo += '</tr>';
		codigo += '</table>';
		
		//break;
	}
}

document.getElementById("boxrecordatorio").innerHTML=codigo;
}
