// JavaScript Document
var corps="";
var net =new Object();
net.READY_STATE_UNINTIALIZED=0;
net.READY_STATE_LOADING=1;
net.READY_STATE_LOADED=2;
net.READY_STATE_INTERACTIVE=3;
net.READY_STATE_COMPLETE=4;
var LOADER_HTTP_METHOD="GET";
//constructeur et prototype de remplissage de liste
net.FillList = function(liste) {
	this.liste=liste;
	
}

net.FillList.prototype= {
   chargerListe:function() {
	  elems=this.req.responseText;
	  elements=elems.split(';');
	  for (i=0;i<elements.length;i++) {
	    var o=new Option(elements[i],elements[i]);
		this.element_out.options[i]=o;
	 }
   }
}

//constructeur et prototype de chargement de page xml-xsl
net.ContentLoader=function(url,onload,onerror,element_out) {
	this.url=url;
	this.req=null;
	this.element_out=element_out;
	this.onload=onload;
	this.onerror=(onerror) ? onerror : this.defaultError;
	this.loadXMLDoc(url);
}

net.ContentLoader.prototype= {
	
	loadXMLDoc:function(url) {
		if ( window.XMLHttpRequest) {
			this.req=new XMLHttpRequest();
		}else if (window.ActiveXObject) {
			this.req =new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (this.req) {
			try {
				var loader=this;
				this.req.onreadystatechange=function() {
					loader.onReadyState.call(loader);
				}  
				this.req.open(LOADER_HTTP_METHOD,url,true);
				if (LOADER_HTTP_METHOD=="GET")
				   this.req.send(null);
				else {
				   this.req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				   this.req.send(corps);
				}
				   
			} catch (err){
				this.onerror.call(this);
			}
		}
	}, //fin loadXMLDoc
	
    onReadyState:function() {
		var req = this.req;
		var ready = req.readyState;
		if (ready==net.READY_STATE_COMPLETE) {
			var httpStatus=req.status;
			if (httpStatus==200 || httpStatus==0) {
				this.onload.call(this);
			}else {
				this.onerror.call(this);
			}
		}
	}, // fin onreadyState
	
	defaultError:function() {
		alert( "data error!"
			  +"\n\nreadyState: "+this.req.readyState
			  +"\nstatus :"+this.req.status
			 
			  );
	}
} // fin protoype


//fonction de rappel pour affichage
function innerOut() {
  
  this.element_out.innerHTML="";
  this.element_out.innerHTML=this.req.responseText;
	
}
//fonction de rappel pour affichage
function loginOut() {
  if(this.req.responseText !='') {
     this.element_out.innerHTML="";
     this.element_out.innerHTML=this.req.responseText;
  }
  else
    alert("identification incorrecte !");
	
}

function mbrOut() {
	rep=false;
  if ( this.req.responseText =='email deja utilise') {
      alert("email deja utilise");   
  }
  else {
	  if( this.req.responseText =='login deja utilise' ) {
         alert("login deja utilise");
	  }
	  else {
	    rep=true;
	  }
  }
  
  if (rep)
   this.element_out.innerHTML=this.req.responseText;
}

//fonction de rappel deboguage only
function toConsole(data) {
	
     var newline=document.createElement("div");
	 div_encours.appendChild(newline);
	 var txt = document.createTextNode(data);
	 newline.appendChild(txt);
	 
}

function fermerDiv(id){
	document.getElementById(id).innerHTML="";
}