countinputs=0
maxinputs=1

function aff(obj){
nameok=false;
var saisie=obj.value.replace(/.*\\(.+\.(gif|jpg|jpeg|png))$/i,'$1');
nameok= saisie.match(/^.+\.(gif|jpg|jpeg|png)$/i);
if(!nameok){alert('Format de fichier non valide \n\nFormat accepter .GIF .JPG .PNG, taille maxi: 2 Mo');
             obj.value='';}
obj.parentNode.getElementsByTagName('label')[0].innerHTML= nameok?saisie:'';
authorise(nameok);
}
 
function authorise(valid){
var emptyone=0
var i=0
tabinputs=document.getElementsByName('pic[]');
 
while (tabinputs[i]){
	if (tabinputs[i].value.length==0) {emptyone++;}
 	i++;}
  document.getElementById('add').disabled=((emptyone==0) && valid)?false:true;
}
 
function addinput(){
if (countinputs>maxinputs){ alert('maximun atteint')
                    return false;}
var newInputfile=document.getElementById('inputline').cloneNode(true);
newInputfile.removeAttribute('id');
newInputfile.getElementsByTagName('label')[0].innerHTML='';
newInputfile.getElementsByTagName('input')[0].value='';


// -- input --
//kill.type='button';
//kill.value="supprimer"

// --- img ---
var kill=document.createElement('img')
kill.src="http://www.recupe.fr/images/sup.gif";
kill.title="supprimer l'image don objet";
kill.alt="supprimer"
kill.style.cursor="pointer";


kill.onclick=function(){ this.parentNode.parentNode.removeChild(this.parentNode);
                         authorise(true);
                          countinputs--; }
newInputfile.appendChild(kill)
newInputfile.appendChild(document.createElement('br'));
document.getElementById('moreinputs').appendChild(newInputfile);
countinputs++;
authorise(true);
}
			
			
			
			
			function getXhr(){
                                var xhr = null; 
				if(window.XMLHttpRequest) // Firefox et autres
				   xhr = new XMLHttpRequest(); 
				else if(window.ActiveXObject){ // Internet Explorer 
				   try {
			                xhr = new ActiveXObject("Msxml2.XMLHTTP");
			            } catch (e) {
			                xhr = new ActiveXObject("Microsoft.XMLHTTP");
			            }
				}
				else { 
				   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
				   xhr = false; 
				} 
                                return xhr;
			}
			
			
			function depart(){
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						leselect = xhr.responseText;
						document.getElementById('divcity').innerHTML = leselect;
					}
				}
				
				xhr.open("POST","lieu/departement.php",true);
 
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				sel = document.getElementById('countryid');
				countryid = sel.options[sel.selectedIndex].value;
				xhr.send("countryid="+countryid);
			}
			
			
			
			function ville(){
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						leselect = xhr.responseText;
						document.getElementById('divarea').innerHTML = leselect;
					}
				}
				
				xhr.open("POST","lieu/ville.php",true);
 
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				sel = document.getElementById('cityid');
				cityid = sel.options[sel.selectedIndex].value;
				xhr.send("cityid="+cityid);
			}
			
	
			

