/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Pour noter "vu" l'une des alertes.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function MAP_alertes(temps)
{
	if (window.XMLHttpRequest)	{ CREATUREalertes_xhr = new XMLHttpRequest(); }
	else
	{
		if (window.ActiveXObject)
		{
			try
			{
				CREATUREalertes_xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	if (CREATUREalertes_xhr) {MAP_alertes2(temps);}
	else {alert("Désolé, je ne peux pas créer XMLHttpRequest");}
}

function MAP_alertes2(temps)
{
		CREATUREalertes_xhr.open("GET", "modules/creature/v2/valider_alerte.php?j="+temps, true);
		CREATUREalertes_xhr.onreadystatechange = MAP_alertes3;
		CREATUREalertes_xhr.send(null);		
}		
function MAP_alertes3()
{
		if (CREATUREalertes_xhr.readyState == 4)
		{
			if (CREATUREalertes_xhr.status == 200)
			{
				document.getElementById("ALERTES_case").innerHTML = CREATUREalertes_xhr.responseText;
			}
		//	else
		//	{
		//		alert("Alertes - Un problème dans la requête");
		//	}
		}
}

//Actualisation automatique des alertes
lancer(MAP_ALERTES_init);

var MAP_ALERTES_xhr = false;
function MAP_ALERTES_init()
{
	if (document.getElementById("ALERTES_case"))
	{
		if (window.XMLHttpRequest)	{ MAP_ALERTES_xhr = new XMLHttpRequest(); }
		else
		{
			if (window.ActiveXObject)
			{
				try
				{
					MAP_ALERTES_xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {}
			}
		}
	
		if (MAP_ALERTES_xhr) {MAP_ALERTES_ouvrirFichier();}
		else {alert("Désolé, je ne peux pas créer XMLHttpRequest");}
	}
}

function MAP_ALERTES_ouvrirFichier()
{

		MAP_ALERTES_xhr.open("GET", "modules/creature/v2/afficher_alerte.php", true);
		MAP_ALERTES_xhr.onreadystatechange = MAP_ALERTES_actualiser;
		MAP_ALERTES_xhr.send(null);

		setTimeout("MAP_ALERTES_ouvrirFichier()", 5*1000);
}

function  MAP_ALERTES_actualiser()
{

	if (MAP_ALERTES_xhr.readyState == 4)
	{
		if (MAP_ALERTES_xhr.status == 200)
		{
			//alert(MAP_ALERTES_xhr.responseText);
				document.getElementById("ALERTES_case").innerHTML = MAP_ALERTES_xhr.responseText;
		}
		else
		{
			//alert("MAP_ALERTES - Un problème dans la requête");
		}
	}
}



/////////////////////
//Alertes défis
/////////////////////
//Actualisation automatique des ALERTES_defis
lancer(MAP_ALERTES_defis_init);

var MAP_ALERTES_defis_xhr = false;
function MAP_ALERTES_defis_init()
{
	if (document.getElementById("CASE_alertedefis"))
	{
		if (window.XMLHttpRequest)	{ MAP_ALERTES_defis_xhr = new XMLHttpRequest(); }
		else
		{
			if (window.ActiveXObject)
			{
				try
				{
					MAP_ALERTES_defis_xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {}
			}
		}
	
		if (MAP_ALERTES_defis_xhr) {MAP_ALERTES_defis_ouvrirFichier();}
		else {alert("Désolé, je ne peux pas créer XMLHttpRequest");}
	}
}

function MAP_ALERTES_defis_ouvrirFichier()
{

		MAP_ALERTES_defis_xhr.open("GET", "modules/creature/v2/alertes.php", true);
		MAP_ALERTES_defis_xhr.onreadystatechange = MAP_ALERTES_defis_actualiser;
		MAP_ALERTES_defis_xhr.send(null);

		setTimeout("MAP_ALERTES_defis_ouvrirFichier()", 5*1000);
}

function  MAP_ALERTES_defis_actualiser()
{

	if (MAP_ALERTES_defis_xhr.readyState == 4)
	{
		if (MAP_ALERTES_defis_xhr.status == 200)
		{
			//alert(MAP_ALERTES_defis_xhr.responseText);
				document.getElementById("CASE_alertedefis").innerHTML = MAP_ALERTES_defis_xhr.responseText;
		}
		else
		{
			//alert("MAP_ALERTES_defis - Un problème dans la requête");
		}
	}
}

