var docXMLNot;

function verNotificaciones(){
	document.getElementById('lista_notificaciones').style.display = "block";
	document.getElementById('lista_favoritos').style.display = "none";
	desplegado = "notificaciones";
}

function notificaciones(v,seg){
	document.getElementById('total_notificaciones').style.display = "none";
	compruebaNotificaciones(v);
	setInterval("compruebaNotificaciones("+v+")",seg);	
}

function compruebaNotificaciones(v){
	
	mi_fecha=new Date();
	r = mi_fecha.getTime();
	
	var url="/xml/consultaNotificaciones.php?ww="+ r +"&v=" + v;
		
	oXML = crearMotorAjax();
	oXML.open('GET',url, true);
	oXML.onreadystatechange = function(){
		if (oXML.readyState == 4) {
			docXMLNot = oXML.responseXML.documentElement;
			mostrarNotificaciones();
		}
	}
	oXML.send(null);
		
}

function mostrarNotificaciones(){
	
	var listaNodos=docXMLNot.getElementsByTagName("notificacion");
	
	var html='<table cellspacing="0" cellpadding="0" border="0" width="180px">';
	
	
	
	if (listaNodos.length != 0 ){
		
		texto=Base64.decode(listaNodos[0].attributes[1].value);
		
		if (texto != "No tienes nuevas notificaciones personales"){
			document.getElementById('total_notificaciones').style.display = "block";
			document.getElementById('total_notificaciones').innerHTML = listaNodos.length;
		}else{
			document.getElementById('total_notificaciones').style.display = "none";
		}
		
	}else{
		document.getElementById('total_notificaciones').style.display = "none";
	}
	
	for(i=0;i<listaNodos.length;i++){
	
		texto=Base64.decode(listaNodos[i].attributes[1].value);
		imagen=listaNodos[i].attributes[0].value;
		
		if (texto != ""){
			html += '<div class="notificacion"><div style="float:left; margin-right:3px"><img src="/img/notificaciones/'+imagen+'" /></div><div style="float:left; width:220px;">'+texto+'</div><div style="clear:both"></div></div>';
		}
	
	}
	
	html += '</table>';
	document.getElementById('lista_notificaciones').innerHTML = html;
}