function create_bloc_detail_project()
{
	if ( ($(document.getElementById('id_project'))) && (document.getElementById('id_project')!="" && document.getElementById('id_project')!="0") )
	{
		var id_project = document.getElementById('id_project').value;
		//document.getElementById('centre').innerHTML = '<div id="descriptifProjet">' + document.getElementById('id_project').value + '</div>';
		var valchange = "id_project=" + escape((id_project).replace(/\+/g, '%2B'));
		submitAjaxDetailsProject(valchange, "ajax/refresh_details_project.php");
	}
	else
	{
		document.getElementById('centre').innerHTML = '<div id="descriptifProjet"><p>Pas de résultat pour ce projet<p></div><div id="listingProjet"><p>Pas de résultat pour ce projet</p></div><div style="clear:both"></div>';
	}
}


function submitAjaxDetailsProject(data, url)
{
	var xhrObjectUser = createAjax();
	xhrObjectUser.open("POST", url, true);
	xhrObjectUser.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhrObjectUser.send(data);
	xhrObjectUser.onreadystatechange = function()
	{
		if (xhrObjectUser.readyState == 4)
		{
			var response;	
			response     = xhrObjectUser.responseXML.documentElement;

			var items    = response.getElementsByTagName("project");
			//var sql = "no sql";
			var html = '';
			//sql = items[0].getElementsByTagName("sql")[0].childNodes[0].nodeValue;
			var count        = items.length;
			//var pair=true;
			//html += "SQL : "+ sql +"<br/>";
				
			if (count>0)
			{
				for(i = 0; i < count; i++) 
				{
					html += '<div id="descriptifProjet">';
					html += '<div id="visuelDescriptif">';
					/*html += '<img src="'+items[i].getElementsByTagName("urlMedia")[0].childNodes[0].nodeValue+'f.jpg" alt="Visuel projet"/>';*/
					html += '<img class="img_list" src="'+items[i].getElementsByTagName("urlMedia")[0].childNodes[0].nodeValue+'" alt="Visuel projet" />';
					html += '<h2>' + items[i].getElementsByTagName("nbId")[0].childNodes[0].nodeValue  + ' annonces</h2>';
					html += '</div>';
					html += '<div id="detailDescriptif">';
					html += '<h2>' + items[i].getElementsByTagName("nameCity")[0].childNodes[0].nodeValue.substr(1)  + ' ' + items[i].getElementsByTagName("nameCountry")[0].childNodes[0].nodeValue.substr(1)  + '</h2>';
					html += '<p>';
					html += trim(items[i].getElementsByTagName("descriptionProject")[0].childNodes[0].nodeValue.substr(1));
					html += '<br />';
					html += '</p>';
					//html += '<p class="Reference">Référence : ' + items[i].getElementsByTagName("referenceProject")[0].childNodes[0].nodeValue + '</p>';
					html += '</div>';
					html += '</div>';
				}
				document.getElementById('centre').innerHTML = html + document.getElementById('centre').innerHTML;
			}
			else
			{
				document.getElementById('centre').innerHTML = '<div id="descriptifProjet"><p>Pas de résultat pour ce projet<p></div><div id="listingProjet"><p>Pas de résultat pour ce projet</p></div><div style="clear:both"></div>';
			}
		}
	}
}

function create_project(response)
{
	var items    = response.getElementsByTagName("project");
	//var sql = "no sql";
	if (items[0])
	{
		var nb = items[0].getElementsByTagName("nbres")[0].childNodes[0].nodeValue;
		//sql = items[0].getElementsByTagName("sql")[0].childNodes[0].nodeValue;
	}
	var html = "<div style='position:absolute; top:320px; left:43%;'>";
	html += "<div id='divimage' style='display:none; width:186px; padding:5px; color:#e0007a; border:solid 2px #a3a09c; background-color:#FFFFFF;'>";
	html += "<img id='image' src='' width='181px'/>";
	html += "<div id='texte' align='right' width='100%' style='color:#8DB93F; font-size:0.8em; font-weight:bold;'>Image</div>";
	html += "</div>";
	html += "</div>";

	//html += "SQL : "+ sql +"<br/>";
	var count        = items.length;
	if (count>0)
	{
		for(i = 0; i < count; i++) 
		{	
			/*
			html += '<div class="annoncesHome">';
			html += '<h2>' + trim(items[i].getElementsByTagName("nameCity")[0].childNodes[0].nodeValue)  + '<br />';
			html += trim(items[i].getElementsByTagName("nameCountry")[0].childNodes[0].nodeValue)  + '</h2>';
			html += '<a href="index.php?page=4&amp;idproject='+ items[i].getElementsByTagName("idProject")[0].childNodes[0].nodeValue  +'" title="Plus d\'informations"><img class="img_list" onmouseover="showBigImg(this,' + i + ', ' + items[i].getElementsByTagName("idProject")[0].childNodes[0].nodeValue + ');" onmouseout="hideBigImg(this, ' + items[i].getElementsByTagName("idProject")[0].childNodes[0].nodeValue + ');" width="64" height="64" src="' + items[i].getElementsByTagName("urlMedia")[0].childNodes[0].nodeValue + '" alt="Visuel Bien" title="Plus d\'informations" /></a>';
				html += '<div id="info_' + items[i].getElementsByTagName("idProject")[0].childNodes[0].nodeValue + '">';
					html += '<p class="villeListing">' + items[i].getElementsByTagName("nbId")[0].childNodes[0].nodeValue + ' annonce(s) ' + '<a href="index.php?page=4&amp;idproject='+ items[i].getElementsByTagName("idProject")[0].childNodes[0].nodeValue  +'" title="Plus d\'informations"><img class="PuceInfos" src="images/home/puce_infos.jpg" alt="Plus d\'informations" title="Plus d\'informations" /></a></p>';
					//html += '<p class="new">NOUVEAU !</p>';
				html += '</div>';
			html += '</div>';
			*/
			html += '<div class="annoncesHome">';
			html += '<h2>' + trim(items[i].getElementsByTagName("nameCity")[0].childNodes[0].nodeValue)  + ' - ' + trim(items[i].getElementsByTagName("nameCountry")[0].childNodes[0].nodeValue)  + '</h2>';
			html += '<div class="descIntroProjet">';
			html += '<div class="pclassProjet"><p>' + trim(items[i].getElementsByTagName("descProject")[0].childNodes[0].nodeValue)  + '</p></div>';
			html += '<div id="info_' + items[i].getElementsByTagName("idProject")[0].childNodes[0].nodeValue + '" style="display: block; text-align:right; margin:0 10px 0 0;">';
			html += '<p class="villeListing"> ' + items[i].getElementsByTagName("nbId")[0].childNodes[0].nodeValue + ' annonce(s) ' + ' <a title="Plus d\'informations" href="index.php?page=4&amp;idproject='+ items[i].getElementsByTagName("idProject")[0].childNodes[0].nodeValue  +'"> <img class="PuceInfos" title="Plus d\'informations" alt="Plus d\'informations" src="images/home/puce_infos.jpg"/> </a> </p>';
			html += '</div>';
			html += '</div>';
			html += '<a title="Plus d\'informations" href="index.php?page=4&amp;idproject='+ items[i].getElementsByTagName("idProject")[0].childNodes[0].nodeValue  +'"> <img class="img_list" height="64" width="64" title="Plus d\'informations" alt="Visuel Bien" src="' + items[i].getElementsByTagName("urlMedia")[0].childNodes[0].nodeValue + '" onmouseover="showBigImgProjet(this, \'' + trim(items[i].getElementsByTagName("nameCity")[0].childNodes[0].nodeValue)  + " - " + trim(items[i].getElementsByTagName("nameCountry")[0].childNodes[0].nodeValue)  + '\');" onmouseout="hideBigImgProjet(this);" style="position: static; left: 0px; top: -35px;"/> </a> </div>';

		}
	}
	else
	{
		html += "<p>Pas d'annonces pour cette recherche</p>";
	}
	
	return html;
}

function create_post_projet(valchange)
{	
	var objCountry = document.getElementById("country");
	var objCity = document.getElementById("city");
	var objArea = document.getElementById("area");
	
	valchange += "&" + objCountry.id+ "=" + escape((objCountry.value).replace(/\+/g, '%2B'));
	
	if (objCountry.value == "1")
	{
		valchange += "&" + objCity.id+ "=" + escape((objCity.value).replace(/\+/g, '%2B'));
		if (objCity.value == "473")
		{
			valchange += "&" + objArea.id+ "=" + escape((objArea.value).replace(/\+/g, '%2B'));
		}
	}
	return valchange;
}

