
	//Affichage des alertes dans la DIV de l'espace "mes alertes"
	function afficherAlertes(url)
	{
		var xhr = getXhr();
		
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{
				document.getElementById("alertes").innerHTML = xhr.responseText;
			}
		}

		xhr.open("POST","http://" + location.hostname+url+"/ajax/gestionAlertes.php",true);

		xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");

		xhr.send("act=1");
	}
	
	//Affichage des annonces dans la DIV de l'espace "ma sélection d'offres"
	function afficherAnnonces(url)
	{
		var xhr = getXhr();
		
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{
				document.getElementById("annonces").innerHTML = xhr.responseText;
			}
		}

		xhr.open("POST","http://" + location.hostname+url+"/ajax/gestionAnnonces.php",true);

		xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");

		xhr.send("act=1");
	}
	
	//Affichage des annonces dans la DIV de l'espace "ma sélection d'offres"
	function afficherAnnoncesPerso(url)
	{
		var xhr = getXhr();
		
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{
				document.getElementById("annoncesPerso").innerHTML = xhr.responseText;
			}
		}

		xhr.open("POST","http://" + location.hostname+url+"/ajax/gestionAnnoncesPerso.php",true);

		xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");

		xhr.send("act=1");
	}
	
	// Gestion pour l'ajout à mes alertes
	function gerer_alerte(url, action, param)
	{
		if(autorisation)
		{
			autorisation = false;
			
			var xhr = getXhr();
		
			xhr.onreadystatechange = function()
			{
				if(xhr.readyState == 4 && xhr.status == 200)
				{
					if(xhr.responseText == "ok")
					{
					document.getElementById("notification").style.filter = "alpha(opacity=0)";
					document.getElementById("notification").style.MozOpacity = 0;
					document.getElementById("notification").style.opacity = 0;
					document.getElementById("notification").innerHTML = "Your job alert has been created on this search";
					document.getElementById("notification").style.display = "inline";
					i = 0;
					afficher_notification();
					}
				}
			}

			xhr.open("POST","http://" + location.hostname+url+"/ajax/gestionAlerte.php",true);

			xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");

			xhr.send("act="+action+"&"+param);
		}
	}
	
	// Gestion pour l'ajout ou la suppression à mes annonces
	function gerer_annonce(url, action, id_div_annonce, param, notification)
	{
		if(autorisation)
		{
			autorisation = false;
			
			var xhr = getXhr();

			xhr.onreadystatechange = function()
			{
				if(xhr.readyState == 4 && xhr.status == 200)
				{
					if(action == 1)
					{
						document.getElementById("annonce" + id_div_annonce).innerHTML = "<a href=\"javascript:void(0)\" onclick=\"gerer_annonce('" + url + "', 3," + id_div_annonce + ", '" + param + "', false)\"><img src=\"" + url + "/img/savedjob.gif\" border=\"0\" style=\"vertical-align:middle\" /></a>&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"gerer_annonce('" + url + "', 3," + id_div_annonce + ", '" + param + "', false)\">Remove this job</a>";
					}
					else
					{
						document.getElementById("annonce" + id_div_annonce).innerHTML = "<a href=\"javascript:void(0)\" onclick=\"gerer_annonce('" + url + "', 1, " + id_div_annonce + ", '" + param + "', false)\"><img src=\"" + url + "/img/savejob.gif\" border=\"0\" style=\"vertical-align:middle\" /></a>&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"gerer_annonce('" + url + "', 1, " + id_div_annonce + ", '" + param + "', false)\">Bookmark this job</a>";
					}
					
					document.getElementById("notification").style.filter = "alpha(opacity=0)";
					document.getElementById("notification").style.MozOpacity = 0;
					document.getElementById("notification").style.opacity = 0;
					document.getElementById("notification").innerHTML = xhr.responseText;
					document.getElementById("notification").style.display = "inline";
					i = 0;

					if(notification == true)
					{
						afficher_notification();
					}
					else
					{
						autorisation = true;
					}
				}
			}

			xhr.open("POST","http://" + location.hostname+url+"/ajax/gestionAnnonce.php",true);

			xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");

			xhr.send("act="+action+"&"+unescape(param));
		}
	}
	
	function afficherOutils(id, url)
	{
		document.getElementById("outils"+id).style.display = "block";
		document.getElementById("button"+id).src = url+"img/moins-societe.gif";
		document.getElementById("button"+id).onclick = function() {cacherOutils(id, url)};
		document.getElementById("lien"+id).onclick = function() {cacherOutils(id, url)};
	}
	
	function cacherOutils(id, url)
	{
		document.getElementById("outils"+id).style.display = "none";
		document.getElementById("button"+id).src = url+"img/plus-societe.gif";
		document.getElementById("button"+id).onclick = function() {afficherOutils(id, url)};
		document.getElementById("lien"+id).onclick = function() {afficherOutils(id, url)};
	}
	
	function actionFermetureForm(url, rubrique, action)
	{
		if(rubrique == "Connexion")
		{
			window.location.href = "http://" + location.hostname + location.pathname;
		}
		else
		{
			if(rubrique == "Alerte" || rubrique == "Alertes")
			{
				messages = new Array("Your job alert has been created","Your job alert has been modified","Your job alert has been deleted");
				
				if(rubrique == "Alerte")
				{
					document.getElementById('notification').innerHTML = messages[0];
				}
				else
				{
					document.getElementById('notification').innerHTML = messages[parseInt(action)-2];
					afficherAlertes(url);
				}
			}
			else if (rubrique == "Annonces")
			{
				document.getElementById('notification').innerHTML = "This job offer has been deleted";
				afficherAnnonces(url);
			}
			else if (rubrique == "ToutesAnnonces")
			{
				document.getElementById('notification').innerHTML = "All your job offers have been deleted";
				afficherAnnonces(url);
			}
			else
			{
				document.getElementById('notification').innerHTML = "This search has been sent to your friend";
			}
			
			document.getElementById('notification').style.display = "inline";
			
			afficher_notification();
		}
	}
	
	function actionFermetureNotification()
	{
	}
