
var IE6 = (navigator.userAgent.indexOf("MSIE 6")>-1) ? 1 : 0;
var IE7 = (navigator.userAgent.indexOf("MSIE 7")>-1) ? 1 : 0;
var xml;

function remplirVille(cp) {

 	if (typeof http != 'undefined') {
  		http.open("GET", racine+'ajax/get_ville.php?cp=' + cp, true);
  		http.onreadystatechange = remplirSelectVille;
  		http.send(null);
  	}
  	else return false;
}

function remplirSelectVille() {
	if (http.readyState == 4) {
		if (http.status == 200) {

			xml = http.responseXML;

			if(xml==null){
				select = document.getElementById("commune");
				select.length=0;
				alert('Veuillez saisir un code postal valide');
			}
			else{
				if (xml.firstChild.nodeName=='xml')
					var type = xml.firstChild.nextSibling.nodeName;
				else
					var type = xml.firstChild.nodeName;

				liste = xml.getElementsByTagName(type);

				select = document.getElementById("commune");
				select.length=0;
				select.options[select.length] = new Option('Choisissez...', '0', false, false);
				if (liste) {
					for(var i=0; i<liste[0].childNodes.length; i++) {
						if (liste[0].childNodes[i].nodeType == 1) {
							var option = new Option(liste[0].childNodes[i].firstChild.nodeValue, liste[0].childNodes[i].attributes[0].value, false, false);
							select.options[select.length] = option;
						}
					}
				}
			}
   		}
	}
}

function desactivation() {
	if(confirm('Souhaitez vous désactiver votre compte ?')){
		document.location.href=racine+'index.php?desactivation=1'
	}
}

function afficheAlert(id) {
	tab=new Array();
	tab[1]="Votre demande est prise en compte";
	if(tab[id])
		alert(tab[id]);
}

url = document.location.href;
xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);
var ajax_get_error = false;
function ajax_do (url) {
	if (url.substring(0, 4) != 'http') {
	url = base_url + url;
	}
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild (jsel);
	return true;
}
function ajax_get (url, el) {
	if (typeof(el) == 'string') {
	el = document.getElementById(el);
	}
	if (el == null) { return false; }
	if (url.substring(0, 4) != 'http') {
	url = base_url + url;
	}
	getfile_url = base_url + 'getfile.php?url=' + escape(url) + '&el=' + escape(el.id);
	ajax_do (getfile_url);
	return true;
}