function get_num(param,iddiv) {
	var xhr_object = null;

	if(window.XMLHttpRequest) // Firefox
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else { // XMLHttpRequest non supporté par le navigateur
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		return;
	}
	xhr_object.open("POST", "adresse_numeros.php?"+param, true);

	xhr_object.onreadystatechange = function() {
		if(xhr_object.readyState == 4) {
			//alert(xhr_object.responseText);
			var tmp = xhr_object.responseText;
			var divname="numero" + iddiv;
			document.getElementById(divname).innerHTML = tmp;
			HideContentAll('numero', iddiv, 100);
			ShowContent('numero' + iddiv);
		}
	}
	xhr_object.send(null);
}


function ShowContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "";
}

function HideContentAll(d,e,t) {
	if(d.length < 1) { return; }
	for(i=1;i<=t;i++) {
		if(document.getElementById(d+i)) {
			if(i!=e) {
				document.getElementById(d+i).style.display = "none";
			}
		}
		else {
			//alert('erreur : ' + d+i)
		}
	}
}


function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}

function ReverseContentDisplay(d) {
	if(d.length < 1) { return; }
	if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = ""; }
	else { document.getElementById(d).style.display = "none"; }
}


function OpenLoc(params) {
	url="localite.php?" + params;
	w=window.open(url,"Aide","width=360, height=400,scrollbars=yes");
	w.focus();
}

function FillLoc(localite, formulaire) {
	if (formulaire==1) {
		window.opener.document.search_res.localite.value=localite;
	}
	else if (formulaire==2) {
		window.opener.document.search_pro.localite.value=localite;
	}

	window.close();
}



function validateForm(formulaire, langue) {
	var retour = false;
	var error = "";

	if (formulaire==1) {
		var nom = rightTrim(document.search_res.nom.value);
		var prenom = rightTrim(document.search_res.prenom.value);
		var localite = rightTrim(document.search_res.localite.value);
		if(nom.length >= 2 && prenom.length >=3) {
			if(localite.length > 0 && localite.length < 3) {
				if(langue=="fr") {
					error = error + "Veuillez saisir trois caract\350res dans la Localit\351 ou la laisser vide.\n";
				}
				else if (langue=="ar") {
					error = error + "الرجاء إدخال 3 أحرف في حقل البلدة أو تركه فارغا\n";
				}
				alert(error);
			}
			else {
				retour = true;
			}
		}
		else {
			if(langue=="fr") {
				alert("Veuillez remplir les champs obligatoires marqu\351s par un *.\n");
			}
			else if (langue=="ar") {
				alert("الرجاء ادخال مقاييس البحث\n");
			}
		}
		
	}
	else if (formulaire==2) {
		var societe = rightTrim(document.search_pro.societe.value);
		var localite = rightTrim(document.search_pro.localite.value);
		if(societe.length >= 2) {
			if(localite.length > 0 && localite.length < 3) {
				if(langue=="fr") {
					error = error + "Veuillez saisir trois caract\350res dans la Localit\351 ou la laisser vide.\n";
				}
				else if (langue=="ar") {
					error = error + "الرجاء إدخال 3 أحرف في حقل البلدة أو تركه فارغا\n";
				}
				alert(error);
			}
			else {
				retour = true;
			}
		}
		else {
			if(langue=="fr") {
				alert("Veuillez remplir les champs obligatoires marqu\351s par un *.\n");
			}
			else if (langue=="ar") {
				alert("الرجاء ادخال مقاييس البحث\n");
			}
		}
		
	}

	return retour;
}




function rightTrim(sString) {
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}


function nomReplace(nom) {
	x=nom.split(" ");
	newNom='';
	lon=x.length-1;
	for (i=0; i<=lon; i++) {
		newNom=newNom+x[i];
		if (i<lon) { newNom=newNom+'+';}
	}
	return newNom
}








//-----------------------------------------------------------------------------
// Disable right-click
//-----------------------------------------------------------------------------
var message="Sorry, right-click has been disabled.";
///////////////////////////////////
function clickIE() {
	if(document.all) {/*alert(message);*/ return false; }
}

function clickNS(e) {
	if(document.layers||(document.getElementById&&!document.all)) { if(e.which==2||e.which==3) {/*alert(message);*/return false; } }
}

if(document.layers) { document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS; }
else { document.onmouseup=clickNS; document.oncontextmenu=clickIE; }

document.oncontextmenu=new Function("return false");


//-----------------------------------------------------------------------------
// Disable content selection
//-----------------------------------------------------------------------------
function disableSelection(target) {
	//IE route
	if (typeof target.onselectstart!="undefined") {
		target.onselectstart=function(){return false}
	}
	//Firefox route
	else if (typeof target.style.MozUserSelect!="undefined") {
		target.style.MozUserSelect="none";
	}
	//All other route (ie: Opera)
	else {
		target.onmousedown=function(){return false}
	}
	target.style.cursor = "default";
}
