function AfficheMasque(id) {

	affiche	= document.getElementById(id);


	if (affiche.style.display == 'none') {
		affiche.style.display = '';

	} else {
		affiche.style.display = 'none';
	}

}

function Photo(id) {

	var divparent	= document.getElementById("DetailPhoto");

	if (document.getElementById("GdePhoto")) {
		var mynode = document.getElementById("GdePhoto" );
		var parent = mynode.parentNode;
		parent.removeChild(mynode);

	} else {

	var photo = document.createElement("img");
			photo.setAttribute("src", "http://images.annonces-auto.info/auto/"+id+".jpg");
			photo.setAttribute("onclick", "Photo(); return false;");
			photo.setAttribute("title", "Cliquez sur l'image pour la réduire");
			photo.id = 'GdePhoto';
			divparent.appendChild(photo);


	}




}

function AfficheMasquePro(valeur) {



	if (valeur ==0) {

			document.getElementById("Prof").setAttribute("style","display:none;");


	} else {


			document.getElementById("Prof").setAttribute("style","");

	}

}



function SelectVilleFR(Pays) {
	var divparent	= document.getElementById("ChoixVille");

	if ( divparent.hasChildNodes() ){
		while ( divparent.childNodes.length >= 1 ){
			divparent.removeChild( divparent.firstChild );
		}
	}


	if (Pays == "FR") {

		var VilleInput 		= document.createElement("select");
			VilleInput.setAttribute("name","Ville");
			VilleInput.setAttribute("id","Ville");
		var option 		= document.createElement("option");
			option.text = "Entrez votre code postal";
			VilleInput.add(option,null);

		divparent.appendChild(VilleInput);

		var codep 	= document.getElementById("CodePostal");



		getVilles(codep.value, 'Ville');


	} else {



		var VilleInput 	= document.createElement("input");

			VilleInput.setAttribute("type","text");
			VilleInput.setAttribute("name","Ville");
			VilleInput.setAttribute("size","20");

		divparent.appendChild(VilleInput);
	}

}

function addOption(idselect,valeur,libelle) {

var selectParent	= document.getElementById(idselect);
var option 		= document.createElement("option");

			option.text = libelle;

			selectParent.add(option,null);

}

function getVilles(cp,idselect) {


	cpLen = cp.length ;
	if (cpLen == 5) {

		var Retard = new Ajax.Request('/ajax/getVilles.php',

			{ 	method:'get',
				parameters : {cp: cp},
				onSuccess: function(transport) {

					var reponse = transport.responseText.evalJSON();
					selectparent = document.getElementById(idselect);
					if ( selectparent.hasChildNodes() ){
						while ( selectparent.childNodes.length >= 1 ){
							selectparent.removeChild( selectparent.firstChild );
						}
					}
					reponse.each(

						function (reponse){

							addOption(idselect,reponse.nom,reponse.nom);

						}

					);

				}

			}
		);






	}



}

