var IE  = window.ActiveXObject ? true : false;
var MOZ = window.sidebar       ? true : false; 
////A VIRER -> POUR FLASH/HTACCESS///
function GETCOOKIE(){
	return document.cookie;
}
/* BINDING
Ce code invoque la méthode apply de l'instance m. m est connu de la fonction grâce à la closure. m correspond à l'instance de la fonction this.count dans ce cas.
C'est donc this.count qui sera appelé.
Le premier paramètre de apply est l'instance souhaitée en tant que contexte.
C'est le premier paramètre passé à bind.
En l'occurrence c'est this lors de l'appel à addEvent.
Dans ce contexte this référencie l'instance de Compteur.

Il aurait été possible de donner des arguments supplémentaires à bind qui aurrait alors été transmis à count en arguments.

*/
/*
Function.prototype.bind = function() {
  var m = this; // sauve le context this
  // extrait le 1er argument et garde les autres pour propagation
  var instance = Array.prototype.shift.call(arguments)
  return function() {
    return m.apply(instance, arguments);
  }
}*/
function Swf( file , target , width , height , version , flashvars , params ){
	//function createSWF(attObj, parObj, id) {
			var UNDEF = "undefined",
		OBJECT = "object",
		SHOCKWAVE_FLASH = "Shockwave Flash",
		SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
		FLASH_MIME_TYPE = "application/x-shockwave-flash",
		EXPRESS_INSTALL_ID = "SWFObjectExprInst",
		
		win = window,
		doc = document,
		nav = navigator,
		
		domLoadFnArr = [],
		regObjArr = [],
		objIdArr = [],
		listenersArr = [],
		script,
		timer = null,
		storedAltContent = null,
		storedAltContentId = null,
		isDomLoaded = false,
		isExpressInstallActive = false;

	var ua = function() {
		var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
			playerVersion = [0,0,0],
			d = null;
		if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
			d = nav.plugins[SHOCKWAVE_FLASH].description;
			if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
				d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
				playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
				playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
			}
		}
		else if (typeof win.ActiveXObject != UNDEF) {
			var a = null, fp6Crash = false;
			try {
				a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
			}
			catch(e) {
				try { 
					a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
					playerVersion = [6,0,21];
					a.AllowScriptAccess = "always";	 // Introduced in fp6.0.47
				}
				catch(e) {
					if (playerVersion[0] == 6) {
						fp6Crash = true;
					}
				}
				if (!fp6Crash) {
					try {
						a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
					}
					catch(e) {}
				}
			}
			if (!fp6Crash && a) { // a will return null when ActiveX is disabled
				try {
					d = a.GetVariable("$version");	// Will crash fp6.0.21/23/29
					if (d) {
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
				}
				catch(e) {}
			}
		}
		var u = nav.userAgent.toLowerCase(),
			p = nav.platform.toLowerCase(),
			webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
			ie = false,
			windows = p ? /win/.test(p) : /win/.test(u),
			mac = p ? /mac/.test(p) : /mac/.test(u);
		/*@cc_on
			ie = true;
			@if (@_win32)
				windows = true;
			@elif (@_mac)
				mac = true;
			@end
		@*/
		return { w3cdom:w3cdom, pv:playerVersion, webkit:webkit, ie:ie, win:windows, mac:mac };
	}();			
	if (ua.ie && ua.win) { // IE, the object element and W3C DOM methods do not combine: fall back to outerHTML
			target.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width+'" height="'+height+'" id="'+target.id+'"><param name="movie" value="'+file+'" /></object>';
				
	}else{
			var objet = document.createElement("object");
			objet.setAttribute("type", "application/x-shockwave-flash");
			objet.setAttribute("width", width);
			objet.setAttribute("height", height);
			objet.setAttribute("data", file);
			objet.id = target.id;
			objet.style.visibility = "visible";
			
			////FLASHVARS
			var param = document.createElement("param");
			param.name = "flashvars";
			var vars = "";
			for( var i in flashvars ){
				vars +="&"+i+"="+flashvars[i];
			}
			param.value = vars;
			objet.appendChild( param );

			//////PARAMS
			for( var i in params ){
				var param = document.createElement("param");
				param.name = i;
				param.value = params[i];
				objet.appendChild( param );
			}


			target.appendChild( objet );
	}
				
		
}
function createElement( balise , child ){
	var element = document.createElement( balise );
	if( child ){
		if( typeof(child) == "string" ){
			child = Text( child );
		}
		element.appendChild( child );
	}
	return element;
}
function getSelectedText( parent ){
	if (parent.getSelection){
	   var str = parent.getSelection();
	}else if (parent.document.getSelection){
	   var str = parent.document.getSelection();
	}else {
	   var str = parent.document.selection.createRange().htmlText;
	}
	return str;
}
function Form(name){
	var form = document.createElement("form");
	form.setAttribute("name" , name);
	form.setAttribute("id" , name);
	return form;
}
function Text(text){
	return document.createTextNode(text);
}
function BR(){
	return document.createElement("br");
}
function H(niveau,text){
	var h = document.createElement('h'+niveau);
	if( typeof(text) != "object" ){
		text = Text(text);
	}
	h.appendChild( text );
	return h;
}
function Span( text , classe , id ) {
	var span = document.createElement('span');
	span.appendChild( document.createTextNode(text) );
	if( classe ){
		span.className = classe;
	}
	if( id ){
		span.id = id;
	}
	return span;
}
function LinkButton(text,action){
	var a = document.createElement('a');
	a.className = "LikeButton";
	if( typeof(text) != "object" ){
		text = Text(text);
	}
	a.appendChild( text );
	if( action ){
		a.onclick = action;
	}
	return a;
}
function LinkSpan(text,id,href){
	var a = document.createElement('a');
	a.className = "LikeButton";
	if( href ){
		a.href = href;
	}
	
	if( id ){
		a.id = id;
	}else{
		a.id = text;
	}
	
	if( typeof(text) != "object" ){
		text = Span(text);
	}
	a.appendChild( text );
	return a;
}
function Icone(text,classe){
	var a = document.createElement('a');
	
	if( classe ){
		a.className = classe;
	}else{
		a.className = text;
	}
	
	if( typeof(text) != "object" ){
		text = Span(text);
	}
	a.appendChild( text );
	return a;
}
function Link(text,href){
	var a = document.createElement('a');
	if( typeof(text) != "object" ){
		text = Text(text);
	}
	a.appendChild( text );
	if( typeof(href) != "undefined" ){
		a.setAttribute( "href" , href );
	}
	return a;
}
function Checkbox(name){
	var checkbox = document.createElement("input");
	checkbox.type = "checkbox";
	if( name ){
	checkbox.name = name;
	checkbox.id = name;
	}
	return checkbox;
}
/* Champ avec recherche pendant la saisie */
function GroupCheckboxes(request,id,Default,explanations){
	
	this.Content = Div("GroupCheckboxes");
	
	this.request = request;
	
	
	var parentTarget = this;

	this.choix = function(){
		if( this.checked ){
			//s'il est checked on ajoute à la liste
			parentTarget.value += this.value + ";";
		}else{
			//s'il est pas checked on le retire de la liste
			
			var idSelected = parentTarget.value.split(";");
			
			parentTarget.value = "";
			
			for( var j = 0 ; j < idSelected.length ; j++ ){
				if( idSelected[j] != this.value && idSelected[j] != "" && idSelected[j] != " " ){
					parentTarget.value += idSelected[j] + ";";
				}

			}
		}
	}
	this.Construct = function(){
			/* Envoi la requete*/
				if( typeof(this.request) == "string" ){
					var RequeteRecherche = ObjXMLHttpRequest();
					RequeteRecherche.SendRequest( this.request ,false,"" );
					if ( RequeteRecherche.responseText != "error" ) {
						var liste= eval('('+RequeteRecherche.responseText+')');
					}else{
						var divitem = DivSelect();
						divitem.appendChild( Text( Langs['NoResult'] ) );
						this.Liste.appendChild(divitem);
					}
				}else{
					var liste= this.request;
				}
					this.value = "";
					
					//EXPLANATIONS//////////////////////
					if(explanations){
						var ExpText = createElement( "i" , explanations );
						this.Content.appendChild(ExpText);
					}
					////////////////////////////////////
					
					var tab = new Tableau(4);
					this.Content.appendChild(tab.Content);
					
					for( var i in liste ){
						var checkbox = Checkbox(id);
							checkbox.value = i;
							
							if(Default){ if(Default!=""){
								var selected = Default.split(";");
								for( var j in selected ){
									if( selected[j] == i ){
										this.value = i+";";
										checkbox.checked = true;
										break;
									}
								}
							} }
							
						checkbox.onclick = this.choix;
						tab.Add( checkbox );
						tab.Add( Text( liste[i] ) );
					}
///////////SI PROBLEME J'AI GARDE L'ANCIEN
/*					for( var i in liste ){
						var divitem = DivSelect();
							this.Content.appendChild( divitem );
						var tab = new Tableau(2);
							divitem.appendChild(tab.Content);
						var checkbox = Checkbox(id);
							checkbox.value = i;
							
							if(Default){
								var selected = Default.split(";");
								for( var j in selected ){
									if( selected[j] == i ){
										this.value = i+";";
										checkbox.checked = true;
										break;
									}
								}
							}
							
						checkbox.onclick = this.choix;
						tab.Add( checkbox );
						tab.Add( Text( liste[i] ) );
						this.Content.appendChild(tab.Content);
					}
*/	}
		this.value = Default;
		this.Construct();
}

function Checkbox2(name, donnee){
	var checkbox = document.createElement("input");
	checkbox.setAttribute("type","checkbox");
	checkbox.setAttribute("name" , name);
	checkbox.setAttribute("id" , name);
	if (donnee=="true") { 
	checkbox.setAttribute("checked" , "checked");
	}
	return checkbox;
}

function Radio(name, id, value, donnee){
	var radio = document.createElement("input");
	radio.type = "radio";
	radio.name = name;
	if( id != "" && id != undefined ){
		radio.id = id;
	}
	radio.value = value;
	
	if (value == donnee) {
		radio.checked=true;
	}

return radio;
}

function CheckboxInstant(label,cid,field,request,valInit,disable){
	this.Content = document.createElement("label");
	this.CheckBox = Checkbox("block");
	this.Content.appendChild( this.CheckBox );
	this.CheckBox.checked = eval(valInit);
	if( typeof(disable) != "undefined" ){
		if( disable == "true"  ){
			this.CheckBox.disabled = eval(disable);
			this.CheckBox.checked = eval(disable);
		}
	}
	this.Content.appendChild( Text( label ) );
	this.CheckBox.onclick = function(){
		var RequeteProfil = ObjXMLHttpRequest();
		RequeteProfil.SendRequest( request ,false,"&CID=" + cid + "&field=" + field + "&value=" + this.checked);
	}
			
}
function TextArea(name,value){
	var textarea = document.createElement("textarea");
	textarea.setAttribute("name" , name);
	if( value ){
	textarea.value = value;
	}
	return textarea;
}

function Field(name,value){
	
	var field = document.createElement("input");
	field.setAttribute("type" , "text");
	field.setAttribute("name" , name);
	if( value ){
	field.setAttribute("value" , value);
	}
	return field;
}
function FieldHidden(name,value){
	
	var field = document.createElement("input");
	field.type="hidden";
	field.name=name;
	if( value ){
	field.value=value;
	}
	return field;
}
function Button(value){
	var button = document.createElement("input");
	button.setAttribute("type" , "button");
	button.setAttribute("value" , value);
	return button;
}
function ImgButton(srcOff,srcOn){
	if( !srcOn ){ srcOn = srcOff ; }
	var img = document.createElement('img');
	img.srcOff = srcOff;
	img.srcOn = srcOn;
	img.setAttribute("src",srcOff);
	img.setAttribute("style","cursor:pointer");
	img.className = "LikeButton";
	img.onmouseover = function(){
		this.setAttribute("src",this.srcOn);
	}
	var parent = this;
	img.onmouseout = function(){
		if( this.Selected ){
			this.setAttribute("src",this.srcOn);
		}else{
			this.setAttribute("src",this.srcOff);
		}
	}
	img.TurnToOff = img.onmouseout;
	return img;
}

function FieldPassword(name){
	var field = document.createElement("input");
	field.setAttribute("type" , "password");
	field.setAttribute("name" , name);
	return field;
}

function Div(id){
	var div = document.createElement('div');
	if( id!="" && id!="undefined" ){
		div.id = id ;
	}
	return div;
}
function Liste( id ){
	this.Content = document.createElement('ul');
	if( id ){
		this.Content.setAttribute( "id" , id );
	}
	this.Add = function( element , classe ){
		var li = document.createElement('li');
		if( classe ){
			li.className = classe;
		}
		if( typeof(element) == "string" ){
			li.appendChild( Text( element ) );
		}else{
			li.appendChild( element );
		}
		this.Content.appendChild(li);
	}
	this.Reset = function(){
		RemoveAllChilds(this.Content,0);
	}
}
function DivSelect(){
	var divselect = Div();
	divselect.className = "divselect";
	return divselect;
}
function Img(src){
	var img = document.createElement('img');
	img.setAttribute("src",src);
	return img
}
/* Champ avec recherche pendant la saisie */
function FieldRecherche(pagerequest,id,Default){
	
	/* cree le champ */
	this.Content = document.createElement("input");
	this.Content.setAttribute("type" , "text");
	this.Content.setAttribute("id" , id);
	this.value = "";
	
	this.pagerequest = pagerequest;
	this.Liste = Div();
	this.Liste.className = "ListeFieldRecherche";
	this.Timer = 0;
	
	this.Content.onkeypress = function( parent ){
		return function(){
			/* Vire tout ce qu'il y a dans le div liste */
			RemoveAllChilds( parent.Liste,0 );
			
			
			/* Affiche les résultat après 1 seconde */
			clearTimeout( parent.Timer );
			
			parent.Timer = setTimeout( parent.recherche,1000 );
		}
	}(this)
	
	//RECHERCHE
	this.recherche = function(obj){
		return function(){
			
			/* Envoi la requete*/
				var RequeteRecherche = ObjXMLHttpRequest();
				RequeteRecherche.SendRequest( obj.pagerequest ,false,"&texte=" + encodeURIComponent( obj.Content.value ) );
				
				if ( RequeteRecherche.responseText != "error" ) {
					/*créé le div des mots trouvé*/
					var div = document.createElement('div');
					
					var liste= eval('('+RequeteRecherche.responseText+')');
					var divitem = "" ;
					
					/* s'il y a plusieurs items, liste est un tableau, ce n'est pas le cas s'il n'y a qu'une seule valeur */
					if(typeof(liste[0]) == "undefined"){ var elementseul = liste; liste = new Array(); liste[0] = elementseul; }
					
						for( var i = 0 ; i < liste.length ; i++ ){
							var divitem = DivSelect();
							
							divitem.appendChild( Text( liste[i][0] ) );
							
							divitem.texte = liste[i][0];
							divitem.id = liste[i][1];
							
							/*Si on clique sur le mot trouvé...*/
							divitem.onmousedown = function(){
								return function(){
									
									/* Balance l'action définit dans le parent du champ*/
									obj.Action(this.id,this.texte);
									
									this.parentNode.parentNode.removeChild(this.parentNode);
								}
							}(this)
							
							obj.Liste.appendChild( divitem );
						}
				}else{
							divitem = DivSelect();
							divitem.appendChild( Text( Langs['NoResult'] ) );
							obj.Liste.appendChild(divitem);
				}
				
					/*Ajoute le div dans le body*/
					document.body.appendChild(obj.Liste);
					var pos = findPos(obj.Content);
					
					/* STYLE DE LA LISTE */
					obj.Liste.style.position = "absolute";
					obj.Liste.style.top = ( pos.y+ obj.Content.offsetHeight + 1 )+"px" ;
					obj.Liste.style.left = pos.x+"px";
					obj.Liste.style.minWidth = obj.Content.offsetWidth+"px";
			}
	}(this)
	if( Default ){
		this.value = Default;
		var RequeteRecherche = ObjXMLHttpRequest();
		RequeteRecherche.SendRequest( this.pagerequest , false , "&id="+Default );
		
		if ( RequeteRecherche.responseText != "error" ) {
			this.value = Default;
			this.Content.value = RequeteRecherche.responseText;
		}
	}
}
/* Champ avec recherche pendant la saisie */
function FieldSelecter(pagerequest,id,Default){
	
	this.Content = Div();
	// cree le champ 
	this.Field = document.createElement("input");
	this.Field.disabled = true;
	this.Field.setAttribute("type" , "text");
	this.Field.setAttribute("id" , id);
		this.Content.appendChild( this.Field );
	
	//modifier
	this.modifier = LinkButton( Langs['Modify'] );
		this.Content.appendChild( this.modifier );
	
	this.pagerequest = pagerequest;
	this.Liste = Div();
	this.Liste.className = "ListeFieldRecherche";
	this.Timer = 0;
	
	//Container
	this.Liste.field = document.createElement("input");
	this.Liste.field.setAttribute("type" , "text");
	this.Liste.appendChild( this.Liste.field );
	
	//resultats de recherche
	this.Items = Div();
	this.Liste.appendChild( this.Items );
	
	//Liste des pages dispo
	this.Pages = Div("pages");
	this.Liste.appendChild( this.Pages );
	this.ConstructPages = function( num ){
		var change_page = function(obj){
			return function(){
			RemoveAllChilds( obj.Items,0 );
			obj.page = this.page;
			///affiche precedent suivant
			if( obj.page >0 ){
				precedent.style.display = "block";
			}else{
				precedent.style.display = "none";
			}
			precedent.page = obj.page-1;
			if( obj.page < obj.numpages-1  ){
				suivant.style.display = "block";
			}else{
				suivant.style.display = "none";
			}
			suivant.page = obj.page+1;
			///
			obj.recherche();
			}
		}(this)
		////PRECEDENT
			var precedent = LinkSpan("<");
				if( this.page >0 ){
					precedent.style.display = "block";
				}else{
					precedent.style.display = "none";
				}
				precedent.page = this.page-1;
				precedent.onclick = change_page;
				this.Pages.appendChild( precedent );
		////liste pages
		for( var i = 0 ; i < num ; i++ ){
			var lien = LinkSpan(i+1);
			lien.page = i;
			lien.onclick = change_page;
			this.Pages.appendChild( lien );
		}
		////SUIVANT
			var suivant = LinkSpan(">");
				if( this.page < this.numpages-1  ){
					suivant.style.display = "block";
				}else{
					suivant.style.display = "none";
				}
				suivant.page = this.page+1;
				suivant.onclick = change_page;
				this.Pages.appendChild( suivant );
	}
	//Init Pages
	this.page = 0;
	this.numpages = 0;
	this.limit = 5;
	
	// BOUTON VALIDER
	var fermer = Button( Langs["Close"] );
		this.Liste.appendChild( fermer );
		
		//Si on clique sur valider...
		fermer.onmousedown = function(){
			this.parentNode.parentNode.removeChild(this.parentNode);
		}
	
	
	this.modifier.onclick = function( parent ){
		return function(){
			/* Vire tout ce qu'il y a dans le div liste */
			RemoveAllChilds( parent.Items,0 );
			parent.recherche();
		}
	}(this)
	this.Liste.field.onkeypress = function( parent ){
		return function(){
			// Vire tout ce qu'il y a dans le div liste 
			RemoveAllChilds( parent.Items,0 );
			
			
			// Affiche les résultat après 1 seconde
			clearTimeout( parent.Timer );
			
			parent.Timer = setTimeout( parent.recherche,1000 );
		}
	}(this)
	
	var fieldTarget = this.Field;
	var parentTarget = this;

	this.choix = function(){
		
		if( this.checked ){
			//s'il est checked on ajoute à la liste
			if(typeof(parentTarget.value)=="undefined"){
				parentTarget.value = "";
			}
			
			
			fieldTarget.value += this.texte + ";";
			parentTarget.value += this.value + ";";
		}else{
			//s'il est pas checked on le retire de la liste
			
			var idSelected = parentTarget.value.split(";");
			var texteSelected = fieldTarget.value.split(";");
			
			fieldTarget.value = "";
			parentTarget.value = "";
			
			for( var j = 0 ; j < idSelected.length ; j++ ){
				if( idSelected[j] != this.value && idSelected[j] != "" && idSelected[j] != " " ){
					fieldTarget.value += texteSelected[j] + ";";
					parentTarget.value += idSelected[j] + ";";
				}

			}
		}
	}
	function Apply_Events( element ){
		element.onmouseover = function(){
			window.onmousedown = false;
		}
		element.onmouseout = function(){
			window.onmousedown = function(){
				document.body.removeChild( parentTarget.Liste );
				window.onmousedown = false;
				window.onmouseout = false;
				window.onmouseover = false;
			}
		}
		window.onmousedown = function(){
			document.body.removeChild( parentTarget.Liste );
		}

	}
	//RECHERCHE
	this.recherche = function(obj){
		return function(){
			/* Envoi la requete*/
			
				var RequeteRecherche = ObjXMLHttpRequest();
				RequeteRecherche.SendRequest( obj.pagerequest ,false,"&texte=" + encodeURIComponent( obj.Liste.field.value )+"&page="+obj.page+"&limit="+obj.limit );
				
				if ( RequeteRecherche.responseText != "error" ) {
					/*créé le div des mots trouvé*/
					///////////////////////////////////
					var RetourRequete = eval('('+RequeteRecherche.responseText+')');
					var liste = RetourRequete["datas"];
					
					Apply_Events(obj.Liste);
					/////Construction des pages
					if( obj.numpages == 0 && RetourRequete["nPages"] > 1){
						obj.numpages = RetourRequete["nPages"];
						obj.ConstructPages( RetourRequete["nPages"] );
					}
					
					var divitem = "" ;
					
					/* s'il y a plusieurs items, liste est un tableau, ce n'est pas le cas s'il n'y a qu'une seule valeur */
					if(typeof(liste[0]) == "undefined"){ var elementseul = liste; liste = new Array(); liste[0] = elementseul; }
					
						for( var i = 0 ; i < liste.length ; i++ ){
							var divitem = DivSelect();
							obj.Items.appendChild( divitem );
							var tab = new Tableau(2);
							divitem.appendChild(tab.Content);
							var checkbox = Checkbox();
								checkbox.texte = liste[i][0];
								checkbox.value = liste[i][1];
								checkbox.checked = false;
								
							//verifie si ce résultat a déjà été sélectionné dans une recherche précédente
							if( obj.value ){
								var arraySelected = obj.value.split(";");
								for( var j = 0 ; j < arraySelected.length ; j++ ){
									if( arraySelected[j] == checkbox.value ){
										checkbox.checked = true;
									}
								}
							}
							checkbox.onclick = obj.choix;
							
							tab.Add( checkbox );
							tab.Add( Text( liste[i][0] ) );
						}
				}else{
							var divitem = DivSelect();
							divitem.appendChild( Text( Langs['NoResult'] ) );
							obj.Items.appendChild(divitem);
				}
				/*Ajoute le div dans le body*/
				document.body.appendChild(obj.Liste);
				var pos = findPos(obj.Field);
				/* STYLE DE LA LISTE */
				obj.Liste.style.position = "absolute";
				obj.Liste.style.top = ( pos.y+ obj.Field.offsetHeight + 1 )+"px" ;
				obj.Liste.style.left = pos.x+"px";
				obj.Liste.style.minWidth = obj.Field.offsetWidth+"px";
			}
			

	}(this)
	this.Construct = function(){
		this.Field.value = "loading...";
		var Requete = ObjXMLHttpRequest();
		Requete.SendRequest( this.pagerequest , true , "&liste="+this.value );
		Requete.onreadystatechange = function(obj){
			return function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						obj.Field.value = this.responseText;
					}
				}
			}
		}(this)


	}
	
	
	if( typeof(Default) == "undefined" || Default == "undefined" ){
		Default = "";
	}
	if( Default ){
		this.value = Default;
		this.Construct();
	}
}
/* Select NORMAL */
function Select( param , id , Default , SensKeyValue){
	var Selecter = document.createElement("select");
	Selecter.setAttribute("id" , id);
	Selecter.setAttribute("name" , id);
	Selecter.Construct = function(param ,Default , SensKeyValue) {
		RemoveAllChilds( this , 0 );
		if( SensKeyValue){
			for( var key in param ){
				var option = document.createElement('option');
				option.setAttribute("value" , param[key] );
				option.appendChild( Text( key ) );
				Selecter.appendChild(option);
				if( param[key] == Default ){
					option.selected = true;
				}
				
			}
		}else{
			for( var key in param ){
				
				var option = document.createElement('option');
				option.setAttribute("value" , key );
				option.appendChild( Text( param[key] ) );
				Selecter.appendChild(option);
				if( key == Default ){
					option.selected = true;
				}
				
			}
		}
	}
	//Si Param est un string :
		if( typeof(param) == "string" ){
			var option = document.createElement('option');
				option.setAttribute("value" , "" );
				option.appendChild( Text( "chargement en cours..." ) );
				Selecter.appendChild(option);
				
			var RequeteSelect = ObjXMLHttpRequest();
			RequeteSelect.SendRequest( param ,true,"" );
			RequeteSelect.onreadystatechange = function(obj){
				return function(){
					if( this.readyState == 4 ){
						if( this.status == 200 ){
							Selecter.Construct(eval('('+this.responseText+')') ,Default , SensKeyValue);
						}
					}
				}
			}(this)
		}else{
			Selecter.Construct(param ,Default , SensKeyValue);
		}
	return Selecter;
}
/* Select Instantane */
function SelectInstant( param , id , Default ){
	this.Content = document.createElement("select");
	this.Content.setAttribute("id" , id);
	this.Construct = function(param, Default) {
	if( typeof(param) == "object" ){
		var liste = new Array();
		for( var a = 0 ; a < param.length ; a++ ){
			liste[a] = new Array();
			liste[a]['nom'] = Langs[ param[a] ];
			liste[a]['id'] = param[a];
		}
	//Si Param est une valeur :
	}else{
		var RequeteSelect = ObjXMLHttpRequest();
		RequeteSelect.SendRequest( param ,false,"" );
		var liste= eval('('+RequeteSelect.responseText+')');
	}
	
	for( var i = 0 ; i < liste.length ; i++ ){
		var option = document.createElement('option');
		
		option.setAttribute("value" , liste[i]['CID']);
		option.appendChild( Text( liste[i]['nom'] ) );
		this.Content.appendChild(option);
		if( liste[i]['CID'] == Default || liste[i]['nom'] == Default){
			option.selected = true;
		}
	}
	}
	  this.Construct(param , Default);
	  
	
}
/* DOUBLE DOUBLE DOUBLE SELECT */
/* completelist -> liste complète des choix ||||| elementsselected -> les choix deja selectionné */
function DoubleSelect(completelist,elementsselected,module,operation){
	this.Content = document.createElement('div');
	this.Content.className = "DoubleSelect";
	this.module=module;
	this.operation = operation;
	this.Infos = new Tableau(3);
	
	
	/* Les 2 boites de selection */
	this.InBox = document.createElement('select');
		this.InBox.setAttribute("multiple","multiple");
	this.OutBox = document.createElement('select');
		this.OutBox.setAttribute("multiple","multiple");
	
	/*Les boutons pour envoyer de droite à gauche */
	var boutons = new Tableau(1);
	
	var boutonToIn = LinkSpan("<");
	var boutonToOut = LinkSpan(">");
	
	boutons.Add( boutonToIn );
	boutons.Add( boutonToOut );
	
	this.Infos.Add(this.InBox);
	this.Infos.Add(boutons.Content);
	this.Infos.Add(this.OutBox);
	this.Content.appendChild(this.Infos.Content);
	
	if( typeof(completelist) == "string" ){
		var Requete = new ObjXMLHttpRequest();
		Requete.SendRequest( completelist , false , "" );
		if( Requete.responseText != "error" ){
			var completelist = eval('('+Requete.responseText+')');
		}else{
			var completelist = [];
		}
	}

	for( var i = 0 ; i < completelist.length ; i++ ){
		var selected = false;
		for( var j = 0 ; j < elementsselected.length ; j++ ){
			if( elementsselected[j]['id'] == completelist[i]['id'] ){
				selected = true;
			}
		}
		if( selected ){
			var option = document.createElement('option');
				option.setAttribute("value",completelist[i]['id']);
				option.appendChild( Text ( completelist[i]['nom'] ) );
			this.InBox.appendChild(option);
		}else{
			var option = document.createElement('option');
				option.setAttribute("value",completelist[i]['id']);
				option.appendChild( Text ( completelist[i]['nom'] ) );
			this.OutBox.appendChild(option);
		}
	}
	
		boutonToIn.onclick = function(obj) {
			return function(){
				var Options = obj.OutBox.options;
				/* parcours la liste des options pour voir si elles sont selected, et les envoi dans l'autre boite */
				for( var i = 0 ; i < Options.length ; i++ ){
					if( Options[i].selected ){
						/*envoi le cid de l'option (dugroupe) et donne la valeur true*/
						obj.Send( Options[i].value , true );
						obj.InBox.appendChild( Options[i] );
						/* quand on enleve un element, le prochain le remplace donc il faut pas passer au suivant */
						i--;
					}
				}
			}
		}(this)
		
		boutonToOut.onclick = function(obj) {
			return function(){
				var Options = obj.InBox.options;
				/* parcours la liste des options pour voir si elles sont selected, et les envoi dans l'autre boite */
				for( var i = 0 ; i < Options.length ; i++ ){
					if( Options[i].selected ){
						/*envoi le cid de l'option (dugroupe) et donne la valeur false*/
						obj.Send( Options[i].value , false );
						obj.OutBox.appendChild( Options[i] );
						/* quand on enleve un element, le prochain le remplace donc il faut pas passer au suivant */
						i--;
					}
				}
			}
		}(this)
	this.Send = function( CID , value ){
		this.RequetePermission = ObjXMLHttpRequest();
		this.RequetePermission.SendRequest(this.operation,false,"&module=" + this.module + "&id=" + CID + "&value=" + value );
		
	}
	
}

//////////////////////////////////////////////////////////////
////////////////Objets pour Sous Module SOcietes/////////////
//////////////////////////////////////////////////////////////
function SelectRelationnel( operation , table1 , table2 , elementsselected , explanations){
	
	
	this.Content = Div("SelectRelationnel");
	this.value = new String();
	this.array = new Array();
	this.Tableau = new Tableau(3,"top");
		this.Content.appendChild(this.Tableau.Content);
	
	var RequeteSelect = ObjXMLHttpRequest();
		RequeteSelect.SendRequest( operation ,false,"&table1="+table1+"&table2="+table2 );
		var Liste= eval('('+RequeteSelect.responseText+')');

	
		var select1 = Select( Liste[table1] , table1 );
		var select2 = Select( Liste[table2] , table2 );
		this.Tableau.Add( select1 );
		this.Tableau.Add( select2 );



	var Plus = Button("ajouter");
	Plus.onclick = function(obj){
		return function(ev){
			
			var arrayTmp = [ select1.selectedIndex , select2.selectedIndex ];
			var exists = false;
			for( var i in obj.array ){
				if( obj.array[i][0] == arrayTmp[0] && obj.array[i][1] == arrayTmp[1] ){
					exists = true;
					break;
				}
			}
			if( !exists ){
				obj.array.push( arrayTmp );
				obj.ConstructText();
			}
			if( obj.Action ){ obj.Action(ev); }
		}
		
	}(this)
	this.ConstructText = function(){
		RemoveAllChilds( this.Text , 0 );
		for( var i in this.array ){
			var div = Div();
				this.Text.appendChild(div);
				var tab_li = new Tableau(null);
					div.appendChild(tab_li.Content);
				var supprimer = LinkSpan("delete");
					tab_li.Add( supprimer );
					tab_li.Add( Text(select1.options[ this.array[i][0] ].text +" → "+ select2.options[ this.array[i][1] ].text) );
				supprimer.indexes = this.array[i];
				supprimer.parent = div;
				supprimer.onclick = function(obj){
					return function(ev){
						for( var i in obj.array ){
							if( obj.array[i] == this.indexes ){
								obj.array.splice( i , 1 );
								this.parent.parentNode.removeChild( this.parent );
							}
						}
						obj.ConstructString();
						if( obj.Action ){ obj.Action(ev); }
					}
				}(this)
		}
		this.ConstructString();
	}
	this.ConstructString = function(){
		this.value = "";
		for( var i in this.array ){
			this.value += select1.options[ this.array[i][0] ].value +"-"+ select2.options[ this.array[i][1] ].value +";";
		}
	}
	this.Tableau.Add(Plus);
	if(explanations){
	var ExpText = createElement( "i" , explanations );
		this.Content.appendChild(ExpText);
	}
	this.Text = Div();
		this.Content.appendChild(this.Text);

	////SI elements deja selectionnes///
	if( elementsselected ){
		//this.value = elementsselected;
		var arrayselected = elementsselected.split(";");
		for( var i in arrayselected ){
			if( arrayselected[i] != "" ){
			var tab = arrayselected[i].split("-");
			var collection1 = select1.options;
			var collection2 = select2.options;
			
			for( var j in collection1 ){
				if(collection1[j]){
					if( collection1[j].value == tab[0] ){
						break;
					}
				}
			}
			for( var k in collection2 ){
				if( collection2[k] ){
					if( collection2[k].value == tab[1] ){
						break;
					}
				}
			}
			var arrayTmp = [ j , k ];
			this.array.push(arrayTmp);
			
			}
		}
		
		this.ConstructText();
	}
	
	//////////////////
	
}

function SelectMonoRelationnel( operation , table1 , elementsselected, explanations, champ1, champ2){
	
	
	this.Content = Div("SelectRelationnel");
	this.value = new String();
	this.array = new Array();
	this.Tableau = new Tableau(3,"top");
		this.Content.appendChild(this.Tableau.Content);
	
	if (champ1 || champ2) {
		var varlist = "&champ1="+champ1+"&champ2="+champ2+"";
	}
	else { var varlist = ""; }
	var RequeteSelect = ObjXMLHttpRequest();
		RequeteSelect.SendRequest( operation ,false,"&table1="+table1+""+varlist );
		var Liste = eval('('+RequeteSelect.responseText+')');
		if (Liste) {
		var select1 = Select( Liste[table1] , table1 );

		this.Tableau.Add( select1 );


	var Plus = LinkSpan("add");
	Plus.onclick = function(obj){
		return function(){
			
			var arrayTmp = [ select1.selectedIndex ];
			var exists = false;
			for( var i in obj.array ){
				if( obj.array[i][0] == arrayTmp[0] ){
					exists = true;
					break;
				}
			}
			if( !exists ){
				obj.array.push( arrayTmp );
				obj.ConstructText();
			}
		}
		
	}(this)
	this.ConstructText = function(){
		RemoveAllChilds( this.Text , 0 );
		for( var i in this.array ){
			var div = Div();
				this.Text.appendChild(div);
			
			var supprimer = LinkSpan(" Delete", "selectmono");
				supprimer.indexes = this.array[i];
				supprimer.parent = div;
				supprimer.onclick = function(obj){
					return function(){
						for( var i in obj.array ){
							if( obj.array[i] == this.indexes ){
								obj.array.splice( i , 1 );
								this.parent.parentNode.removeChild( this.parent );
							}
						}
						obj.ConstructString();
						}
				}(this)
				var tab1 = new Tableau(2);
				tab1.Add(supprimer);
				tab1.Add(Text(select1.options[ this.array[i] ].text +""));
				div.appendChild(tab1.Content);
				}
		this.ConstructString();
	}
	this.ConstructString = function(){
		this.value = "";
		for( var i in this.array ){
			this.value += select1.options[ this.array[i] ].value +";";
		}
	}
	this.Tableau.Add(Plus);
			}
	if(explanations){
	var ExpText = createElement( "i" , explanations );
		this.Content.appendChild(ExpText);
	}
	this.Text = Div();
		this.Content.appendChild(this.Text);

	////SI elements deja selectionnes///
	if( elementsselected ){
		//this.value = elementsselected;
		var arrayselected = elementsselected.split(";");
		for( var i in arrayselected ){
			if( arrayselected[i] != "" ){
			var tab = arrayselected[i];
			var collection1 = select1.options;
			
			for( var j in collection1 ){
				if( collection1[j].value == tab ){
					break;
				}
			}

			var arrayTmp = [j];
			this.array.push(arrayTmp);
			
			}
		}
		
		this.ConstructText();
	}
	
	//////////////////
	
}

/* DOUBLE DOUBLE DOUBLE SELECT */
function DoubleSelectPassif(completelist,elementsselected,nom){
	this.Content = document.createElement('div');
	this.Content.className = "DoubleSelect";

	this.Infos = new Tableau(3);
	
	/*si elements selectionnees undefined...*/
	if( !elementsselected ){
	elementsselected = new Object();
	}
	
	/* Les 2 boites de selection */
	this.InBox = document.createElement('select');
		this.InBox.setAttribute("multiple","multiple");
		this.InBox.name = nom;
		this.InBox.id = nom;
	this.OutBox = document.createElement('select');
		this.OutBox.setAttribute("multiple","multiple");
	
	/*Les boutons pour envoyer de droite à gauche */
	var boutons = new Tableau(1);
	
	var boutonToIn = LinkSpan("<");
	var boutonToOut = LinkSpan(">");
	
	boutons.Add( boutonToIn );
	boutons.Add( boutonToOut );
	
	this.Infos.Add(this.InBox);
	this.Infos.Add(boutons.Content);
	this.Infos.Add(this.OutBox);
	this.Content.appendChild(this.Infos.Content);
	
	if( typeof(completelist) == "string" ){
		var Requete = new ObjXMLHttpRequest();
		Requete.SendRequest( completelist , false , "" );
		if( Requete.responseText != "error" ){
			var completelist = eval('('+Requete.responseText+')');
		}else{
			var completelist = [];
		}
	}

	for( var i = 0 ; i < completelist.length ; i++ ){
		var selected = false;
		for( var j = 0 ; j < elementsselected.length ; j++ ){
			if( elementsselected[j]['id'] == completelist[i]['id'] ){
				selected = true;
			}
		}
		if( selected ){
			var option = document.createElement('option');
				option.setAttribute("value",completelist[i]['id']);
				option.appendChild( Text ( completelist[i]['nom'] ) );
			this.InBox.appendChild(option);
		}else{
			var option = document.createElement('option');
				option.setAttribute("value",completelist[i]['id']);
				option.appendChild( Text ( completelist[i]['nom'] ) );
			this.OutBox.appendChild(option);
		}
	}
	
		boutonToIn.onclick = function(obj) {
			return function(){
				var Options = obj.OutBox.options;
				/* parcours la liste des options pour voir si elles sont selected, et les envoi dans l'autre boite */
				for( var i = 0 ; i < Options.length ; i++ ){
					if( Options[i].selected ){
						obj.InBox.appendChild( Options[i] );
						/* quand on enleve un element, le prochain le remplace donc il faut pas passer au suivant */
						i--;
					}
				}
			}
		}(this)
		
		boutonToOut.onclick = function(obj) {
			return function(){
				var Options = obj.InBox.options;
				/* parcours la liste des options pour voir si elles sont selected, et les envoi dans l'autre boite */
				for( var i = 0 ; i < Options.length ; i++ ){
					if( Options[i].selected ){
						obj.OutBox.appendChild( Options[i] );
						/* quand on enleve un element, le prochain le remplace donc il faut pas passer au suivant */
						i--;
					}
				}
			}
		}(this)
	
}
function SelectColor(){
	///////////////////////COLOR/////////////////////////
	var selecter = document.createElement("select");
	var colors = new Array("#000000","#8b0000","#ff0000","#ffa500","#a52a2a","#ffff00","#008000","#808000","#00ffff","#3399ff","#00008b","#4b0082","#ee82ee","#ffffff");
	
	for( var i = 0 ; i < colors.length ; i++ ){
		var option = document.createElement("option");
		option.style.backgroundColor = colors[i];
		option.value = colors[i];
		selecter.appendChild(option);
	}

	return selecter;
	
}
function SubmitButton(value){
	var bouton = document.createElement("input");
	bouton.setAttribute("type" , "button");
	bouton.setAttribute("value" , value);
	return bouton;
}
function Loading(){
	this.Content = document.createElement("div");
	this.text = document.createElement("span");
	this.Content.appendChild(this.text);
}

function Tableau(NumOfColumns,VAlign,Align){
	this.NumOfColumns = NumOfColumns;
	if( VAlign ){
	this.VAlign = VAlign;
	}
	this.Content = document.createElement('table');
	this.Tbody = document.createElement('tbody');
	if( Align ){
	this.Content.align = Align;
	}
	this.Content.appendChild(this.Tbody);
	this.Col = 1;
	/* fonction d'ajout de contenu au tableau */
	this.Add = function( element , width , zone ){
		/* si on s'apprete à ajouter un element en debut de ligne, on créé celle ci */
		if( this.Col == 1 ){

			var tr = document.createElement('tr'); this.Tbody.appendChild(tr);
		}
		/*création de la cellule, avec le contenu à l'interieur */
		var td = document.createElement('td');
		if( this.VAlign ){
			td.setAttribute("valign",this.VAlign);	
		}
		if( width ){
			td.setAttribute("width" , width );
		}
		if( zone ){
			td.setAttribute('name',zone);
			td.className = zone;
		}else{
			td.className = "Col"+this.Col;
		}
		if( element ){
			td.appendChild(element);
		}
		this.Tbody.lastChild.appendChild(td);
		/* si le nombre de colonnes est null on fait qu'une ligne*/
		if( this.NumOfColumns != null ){
		/*si on arrive à la fin de la ligne, la prochaine cellule sera dans une nouvelle ligne */
			if( this.Col == this.NumOfColumns ){
				this.Col = 1;
			}else{
				this.Col++;
			}
		}else{
			this.Col++;
		}
	}
}
Tableau.prototype.VTransforme = function(){};




function RemoveAllChilds(target,decalage){
	if( !decalage ){ decalage = 0 ; }
	if(target != undefined){
		while(target.childNodes.length>=(decalage+1)){
		target.removeChild(target.childNodes[decalage]);
		}
	}
}
function TextEditable( text , elementButton ){
	this.Content = Div();
	this.Text = text;
	
	this.Infos = new Tableau(3);
	
	this.Field = Text( text );
	
	if( elementButton ){
		this.Modif = elementButton;
	}else{
		this.Modif = SubmitButton("modifier");
	}
	
	this.Infos.Add( this.Modif );
	this.Infos.Add( this.Field );
	this.Content.appendChild(this.Infos.Content);
	this.Action = new Function();
	
	this.Modif.onclick = function(obj){
		return function(){
			
			//Récupere le parent
			var parent = obj.Field.parentNode;
			//Si le texte est en dur, transformation en Input//
			if( obj.Field.nodeName == "#text" ){
				var value = obj.Field.nodeValue;
				//Supprime le texte ou le champ
				parent.removeChild( obj.Field );
				//Créé un champ avec la meme valeur que le texte
				obj.Field = Field('element');
				obj.Field.value = value;
				//met le champ dans le parent
				parent.appendChild( obj.Field );
			}else if( obj.Field.nodeName == "INPUT" ){
				/* S'IL SE REMET EN ECRITURE NORMAL IL LANCE L'ACTION */
				obj.Action();
				var value = obj.Field.value;
				//Supprime le texte ou le champ
				parent.removeChild( obj.Field );
				//Créé un text avec la meme valeur que le champ
				obj.Field = Text( value );
				//met le texte dans le parent
				parent.appendChild( obj.Field );
			}else{
				alert("problem TextEditable");	
			}
		}
	}(this)
}


Date.prototype.dateToFrench = function(dateSelected){
	var MonthList = new Array("janvier", "f\351vrier", "mars", "avril", "mai", "juin", "juillet", "ao\373t", "septembre", "octobre", "novembre", "d\351cembre");
	var DayList = new Array("Dim","Lun", "Mar", "Mer", "Jeu", "Ven", "Sam");
	
	var annee = this.getFullYear();
	var mois = MonthList[ this.getMonth() ];
	var jour = this.getDate();
	var jourdelasemaine = DayList[ this.getDay() ];
		
	return jourdelasemaine + " " + jour + " " + mois + " " + annee ;
	
}
/* Quand on tape sur entrer dans un champ pâr ex */
function Enter(ev){
	keycode=null;
	if (window.event){
		keycode = window.event.keyCode;
	}else if (ev){
		keycode = ev.which;
	}
	if (keycode==13){
	return true;
	}
}
function ucwords( str ) {
    return str.replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase ( ); } );
}
/* Desactiver tous les elements d'un container */
function Desactive( Container , Bool ){
	var liste = new Array( Container.getElementsByTagName('input') , Container.getElementsByTagName('textarea') , Container.getElementsByTagName('select') , Container.getElementsByTagName('iframe') );

	for( var i = 0 ; i < liste.length ; i++ ){
		for( var j = 0 ; j < liste[i].length ; j++ ){
			liste[i][j].disabled = Bool;
		}
	}
}
/* Champs de date */
function FieldsDate( id , TimeStamp , heure , horloge ){
	/*Héritage du Tableau*/
	this.Content = Div(id);
	if( !TimeStamp || TimeStamp == 0 ){
		var timestamp = new Date();
		this.Content.TimeStampPHP = timestamp.getTime()/1000;
		this.Content.TimeStamp = timestamp.getTime();
	}else{
		this.Content.TimeStampPHP = TimeStamp;
		this.Content.TimeStamp = TimeStamp*1000;
	}
	
	this.DateValue = new Date( this.Content.TimeStamp );
	
	this.MonthList = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
	this.DayList = new Array("Dim","Lun", "Mar", "Mer", "Jeu", "Ven", "Sam");
	this.NumOfDays= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	this.Today = new Date();
	this.YearsArray = new Array();
	this.DaysArray = new Array();
	for( var annee = this.Today.getFullYear() + 5 ; annee >= this.Today.getFullYear() - 100 ; annee-- ){
		this.YearsArray[annee] = annee ;
	}
	
	
		if ( this.DateValue.getFullYear()%4 == 0 && this.DateValue.getFullYear()%100 > 0 || this.DateValue.getFullYear()%400 == 0 ){
			this.NumOfDays[1]=29;
		}else{
			this.NumOfDays[1]=28;
		}
		this.Year = Select( this.YearsArray , "year" , this.DateValue.getFullYear() , false );
		
		this.Month = Select( this.MonthList , "month" , this.DateValue.getMonth() , false );
		
		this.ConstructDays = function(){
			this.DaysArray = new Array();
			for( var day = 1 ; day <= this.NumOfDays[ this.DateValue.getMonth() ] ; day++ ){
				this.DaysArray[day] = day;
			}
		}
		this.ConstructDays();
		
		this.Day = Select( this.DaysArray , "day" , this.DateValue.getDate() , false );
		//
		this.Content.appendChild( this.Day );
		this.Content.appendChild( this.Month );
		this.Content.appendChild( this.Year );
		
		this.Month.onchange = function(obj){
			return function(){
				obj.DateValue.setMonth( this.value );
				obj.Content.TimeStamp = obj.DateValue.getTime();
				obj.Content.TimeStampPHP = obj.DateValue.getTime() / 1000;
				obj.ConstructDays();
				obj.Day.Construct( obj.DaysArray , obj.DateValue.getDate() );
			}
		}(this)
		
		this.Year.onchange = function(obj){
			return function(){
				obj.DateValue.setYear( this.value );
				obj.Content.TimeStamp = obj.DateValue.getTime();
				obj.Content.TimeStampPHP = obj.DateValue.getTime() / 1000;
			}
		}(this)
		this.Day.onchange = function(obj){
			return function(){
				obj.DateValue.setDate( this.value );
				obj.Content.TimeStamp = obj.DateValue.getTime();
				obj.Content.TimeStampPHP = obj.DateValue.getTime() / 1000;
			}
		}(this)
		
		if( heure ){
			
			/*Heures*/
			this.Hour = Field("hour");
			this.Hour.onchange = function(obj){
				return function(){
					obj.DateValue.setHours( this.value );
					obj.Content.TimeStamp = obj.DateValue.getTime();
					obj.Content.TimeStampPHP = obj.DateValue.getTime() / 1000;
				}
			}(this)
			if( this.DateValue.getHours() < 10 ){
				this.Hour.value = "0"+this.DateValue.getHours();
			}else{
				this.Hour.value = this.DateValue.getHours();
			}
				this.Hour.maxlength = 2 ;
				this.Hour.style.width = "20px" ;
				this.Hour.style.textAlign = "center" ;
				
				
			/*Minutes*/
			this.Minutes = Field("minutes");
			this.Minutes.onchange = function(obj){
				return function(){
					obj.DateValue.setMinutes( this.value );
					obj.Content.TimeStamp = obj.DateValue.getTime();
					obj.Content.TimeStampPHP = obj.DateValue.getTime() / 1000;
				}
			}(this)
			if( this.DateValue.getMinutes() < 10 ){
				this.Minutes.value = "0"+this.DateValue.getMinutes();
			}else{
				this.Minutes.value = this.DateValue.getMinutes();
			}
				this.Minutes.maxlength = 2 ;
				this.Minutes.style.width = "20px" ;
				this.Minutes.style.textAlign = "center" ;
				
			
			this.Content.appendChild( Text(" \340 ") );
			this.Content.appendChild( this.Hour );
			this.Content.appendChild( Text(":") );
			this.Content.appendChild( this.Minutes );
		}
}
function SelectTime(id,value){
	var hoursArray = new Array();
	for( var n = 0 ; n <= 24 ; n++ ){
		if( n < 10 ){
			hoursArray[ "0" + n ] = "0" + n;
		}else{
			hoursArray[ n ] = n;
		}
	}
	var minutesArray = new Array();
	for( var n = 0 ; n <= 55 ; n+=5 ){
		if( n < 10 ){
			minutesArray["0" + n] = "0" + n;
		}else{
			minutesArray[ n ] = n;
		}
	}
	if( value ){
		var tmp = value.split(":");
		var defaultHour = tmp[0];
		var defaultMin = tmp[1];
	}else{
		var defaultHour = "10";
		var defaultMin = "00";
	}
	
	var hours = Select( hoursArray , "" , defaultHour);
	var minutes = Select( minutesArray , "" , defaultMin);
	
	hours.onchange = function(){
		div.TimeStampPHP = hours.value +":"+ minutes.value ;
	}
	minutes.onchange = function(){
		div.TimeStampPHP = hours.value +":"+ minutes.value ;
	}
	var div = Div(id);
	div.TimeStampPHP = "";
	div.appendChild( hours );
	div.appendChild( Text(":") );
	div.appendChild( minutes );
	hours.onchange();
	
	return div;
}
function Message( title , text , operations , form){
	function Window(){
		this.Content = document.createElement('table');
			this.Content.width = "100%";
			this.Content.height = "100%";
			this.Content.style.height = "100%";
			this.Content.style.width = "100%";
			this.Content.style.position = "fixed";
			this.Content.style.top = "0";
			this.Content.style.left = "0";
		var tbody = document.createElement('tbody');
		var tr = document.createElement('tr');
		var td = document.createElement('td');
			td.align = "center";
			td.valign = "middle";
		this.Content.appendChild( tbody ); tbody.appendChild( tr ); tr.appendChild( td );
		
		
		var top = Div("Message_Top");
			
		var bottom = Div("Message_Bottom");
			
		var container = Div("Message_Container");

		var titre = H( 1 , Span( title ) );
		var comments = document.createElement('p'); comments.innerHTML = text;
		
		var instance = this;
		var fermer = AlphaFade.bind(instance);
		
		container.appendChild( titre );
		container.appendChild( comments );
		
		//Formulaire
		if( form ){
			var formulaire = createElement("form");
			var tab_Form = new Tableau(1);
				tab_Form.Content.className = "formulaire";
			for( var i in form ){
				var composant = form[i]["composant"]( form[i]["nom"] );
				if( form[i]["value"] ){
					composant.value = form[i]["value"];
				}
				if( form[i]["texte"] ){
					var txt = Text( form[i]["texte"] );
					tab_Form.Add( txt );
				}
				tab_Form.Add( composant );
				
			}
			formulaire.appendChild(tab_Form.Content);
			container.appendChild(formulaire);
		}
		
		///bouton ok, bouton annuler, les actions genre delete, etc.
		for( var i in operations ){
			var button = Button( operations[i]["button"] );
			if( operations[i]["action"] ){
				button.action = operations[i]["action"];
			}
			button.onclick = function(){
				if( this.action ){
					if( form ){
						this.action( formulaire );
					}else{
						this.action();
					}
				}
				fermer();
			}
			container.appendChild( button );
			
		}
		
		td.appendChild( top );
		td.appendChild( container );
		td.appendChild( bottom );
	}
	var Fenetre = new Window();
	document.body.appendChild( Fenetre.Content );
	
/*	if( operation ){
		var pathImages = "miseenpage/style/"+LireCookie('Style')+"/images/"+LireCookie('Lang')+"/composants/message/";
		var button = ImgButton( pathImages+"message_enregistrer.png" , pathImages+"message_enregistrer_on.png" );
		button.onclick = function(obj){
			return function(){
				var RequeteChangeSkin = ObjXMLHttpRequest();
				RequeteChangeSkin.SendRequest( operation ,false,"&membre=" + LireCookie('User') + "&value=" + obj.value );
				if( RequeteChangeSkin.responseText == "modified" ){
					obj.Disparait();
				}
			}
		}(this)
	tableau.Add( button );
	}
*/	
}
function AlphaFade( vitesse ){
	if( !vitesse ){ vitesse = -10; }
	if( !this.alpha){
		if(vitesse<0 || vitesse=="" || vitesse=="undefined") {
			
			this.alpha = 100;
		}
		if (vitesse>=0) {
			this.alpha = 0;
		}
	}
	
	var interval = setInterval(
					function(obj){
						return function(){
							obj.alpha = obj.alpha + vitesse;
							var alpha = obj.alpha;
							if( alpha > 0 && alpha <= 100){
								Opacite( obj.Content , alpha );
							}
							if (alpha >= 100) {
								clearInterval(interval);
							}						
							else{
								if (vitesse<0 && alpha == 0) {
								obj.Content.style.display = "none";
								obj.Content.parentNode.removeChild(obj.Content);
								delete(obj);
								clearInterval(interval);
								}
							}
						
						} 
					}(this),1);
}
function Opacite( element , alpha ){
		element.style.opacity = alpha / 100;
		//Test pour notre cher IE
		if (document.body.filters != undefined){
				element.style.filter = 'alpha(opacity:' + alpha + ')';
		}
}
function VerifEmail( email ){
	if( email.match(/^[a-zA-Z0-9\-_]+[a-zA-Z0-9\.\-_]*@[a-zA-Z0-9\-_]+\.[a-zA-Z\.\-_]{1,}[a-zA-Z\-_]+/) != null ){
		return true;
	}else{
		return false;
	}
}
function VerifPassword( password , password_confirmation){
	/* verifie si le password a au moins 6 caracteres*/
	if( password.length >= 6 ){
		/* si le mot de passe de confirmation est précisé*/
		if( password_confirmation ){
			/* si le mot de passe et le mot de passe de confirmation sont les mêmes */
			if( password == password_confirmation ){
				return true;
			}else{
				return Langs['PasswordConfirmationNotValid'];
			}
		}else{
			return true;
		}
	}else{
		return Langs['PasswordNotValid'];
	}
}
function ErrorMessage( text , Element ){
	this.Content = Div( "Message_Erreur" );
	this.Content.appendChild( Text( text ) );
	
	var pos = findPos(Element);
	/* STYLE DE LA LISTE */
	this.Content.style.backgroundColor = "#ffffff";
	this.Content.style.position = "absolute";
	this.Content.style.top = ( pos.y+ Element.offsetHeight + 1 )+"px" ;
	this.Content.style.left = pos.x+"px";
	this.Content.style.minWidth = Element.offsetWidth+"px";
}
function DebugMessage( text ){
	if( document.getElementById('MessageDebugger' ) == undefined ){
		this.Content = Div("MessageDebugger");
		document.body.appendChild(this.Content);
	}else{
		this.Content = document.getElementById('MessageDebugger' );
	}
	this.Content.innerHTML = text;
	
	/* STYLE DE LA LISTE */
	this.Content.style.backgroundColor = "#d94b06";
	this.Content.style.position = "absolute";
	this.Content.style.top = "0" ;
	this.Content.style.right = "0";
	this.Content.style.padding = "5px";
}

function Navigation(parent){
	this.Content = Div("operations");
	var index = undefined;
	
	var precedent = LinkSpan("precedent", "precedent");
	precedent.onclick = function(){
		if(typeof(index)=="undefined"){
			index = Historique.length - 1;
		}
			index--;
			if( index < 0 ){
				index = 0;
			}else{
				parent.Infos.innerHTML = Langs['Loading'];
				var RequeteBreve = ObjXMLHttpRequest();
				RequeteBreve.SendRequest( Historique[ index ]['operation'] ,false, Historique[ index ]['vars'] );
				var retour = eval('('+RequeteBreve.responseText+')');
				parent.nPages = retour.nPages;
				parent.Infos.innerHTML = retour.txt;
				
				
			}
		
		}
	var suivant = LinkSpan("suivant", "suivant");
	suivant.onclick = function(){
		if(typeof(index)=="undefined"){
			index = Historique.length - 1;
		}
			
			index++;
			if( index > Historique.length-1 ){
				index = Historique.length-1;
			}else{
				parent.Infos.innerHTML = Langs['Loading'];
				var RequeteBreve = ObjXMLHttpRequest();
				RequeteBreve.SendRequest( Historique[ index ]['operation'] ,false, Historique[ index ]['vars'] );
				var retour = eval('('+RequeteBreve.responseText+')');
				parent.nPages = retour.nPages;
				parent.Infos.innerHTML = retour.txt;
			}
	}
	
	
	/////////////RECHERCHE//////////////////
	var recherche = Field("recherche");
	recherche.className = "recherche";
	recherche.value = "recherche";
	if (parent.recherche) { recherche.value = parent.recherche;}
	if (parent.recherche=='disabled') {
		recherche.setAttribute("disabled","disabled" )
	}
	recherche.onkeypress = function(ev){
		if (ev.keyCode == 13){
			parent.recherche = this.value;
			parent.char = '';
			parent.page = '';
			/*
			parent.Infos.innerHTML = "chargement en cours...";
			var RequeteSearch = ObjXMLHttpRequest();
			RequeteSearch.SendRequest( parent.opsearch ,false,"&LIMIT=" + parent.limit + "&ORDER=" + parent.order + "&PAGE=" + parent.page+"&recherche="+ parent.recherche);
			var retour = eval('('+RequeteSearch.responseText+')');
			parent.nPages = retour.nPages;
			parent.Infos.innerHTML = retour.datas;*/
			searchpage(parent, parent.recherche);
			
		}
	}
	recherche.onfocus = function(ev){
		this.value = "";
	}
	//this.Content.appendChild(precedent);
	//this.Content.appendChild(suivant);

	
	
		///////////////LETTRAGE///////////////////
	var tablettrage = new Array("List","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");

		this.send = function(number) { 
		/*	parent.Infos.innerHTML = "chargement en cours...";
			var Requetelettrage = ObjXMLHttpRequest();
			Requetelettrage.SendRequest( parent.opsearch ,false,"&LIMIT=" + parent.limit + "&ORDER=" + parent.order + "&PAGE="+parent.page+"&lettrage="+this.char+"");
			var retour = eval('('+Requetelettrage.responseText+')');
			parent.nPages = retour.nPages;
			parent.Infos.innerHTML = retour.datas;
	*/		lettragepage(parent, number);
	}
	
	
	for (i=0; i<tablettrage.length; i++) {
		if( tablettrage[i] == "List" ){
		var lettre = LinkSpan(tablettrage[i], "lettragefirst");
		lettre.char = "List";
		}else{
		var lettre = LinkSpan(tablettrage[i], "lettrage");
		lettre.char = tablettrage[i];
		}
		lettre.onclick = function() {lettragepage(parent,this.char);}
	
		this.Content.appendChild(lettre);
		this.Content.appendChild(recherche);
	}
			
	
	var Historique = new Array();
	this.AddHistorique = function( operation , vars){
		var action = new Object();
		action.operation = operation;
		action.vars = vars;
		Historique.push( action );
		
	}

}

function ancreAppel(ancre)
		{
		self.location.hash=ancre;
		
		}


function searchpage(parent, number) {
				parent.recherche=number;
				parent.Construct();
			}

function findpage(parent, number) {
				parent.page=number;
				parent.Construct();
			}
			
function lettragepage(parent, number) {
				parent.char=number;
				parent.Construct();
			}

function requeteListage(operation, table, titreliste, limit, order, page, char, recherche, objet, id) {

	if (recherche =='disabled') { recherche ='';}
	var Requete = new ObjXMLHttpRequest();
	if (id) {
	Requete.SendRequest( operation ,false,"&table="+table+"&LIMIT=" + limit + "&ORDER=" + order + "&PAGE=" + page+ "&lettrage="+char+"&recherche="+ recherche+"&id="+id); }
	else {
	Requete.SendRequest( operation ,false,"&table="+table+"&LIMIT=" + limit + "&ORDER=" + order + "&PAGE=" + page+ "&lettrage="+char+"&recherche="+ recherche+""); }
	
	this.Content = new Div();
	Opacite(this.Content,100);
//	this.Content.appendChild( H(3,""+titreliste+"") );
		if( Requete.responseText != "error" ){
			var datas = eval('('+Requete.responseText+')');
			var peoples = new Div();
			peoples.innerHTML = datas['datas'];
			objet.nPages = datas['nPages'];
			objet.page = page;
			this.Content.appendChild(peoples);
		
		//this.ouvrir = AlphaFade;
			
		var numberPage = new ListeNumberPage(objet);
		var pagination = new Div("pagination");
		pagination.appendChild(numberPage.Content);
		this.Content.appendChild(pagination);
		
		}else{
		var peoples ="Aucun Résultat suite à votre requête";
		return peoples;
		}
		
		// this.ouvrir(7);
}


function ListeNumberPage(parent) {
		this.Content = Div();
			var number = Div();
			if (!parent.page) { parent.page = 0; }
			var currentpage = parent.page;
			var totalpage = parent.nPages;
			
			this.send = function(number) {
				findpage(parent, number);
			}
			
//début de liste
				
				if (currentpage>=0) {
					if (totalpage>1) {
						if (totalpage>1) {
						var numberpageprec = LinkSpan ("<", 'numberpage');
						this.Content.appendChild(numberpageprec);
						}
					if (currentpage== 0) {
					var numberpage = LinkSpan("1", "numberpageselected");	
					}
					else {
					var numberpage = LinkSpan("1", "numberpage");
					}
					var numbertemp = Span("...", "numberpage");
					if (currentpage>0) {
					numberpageprec.i = currentpage-1;
					numberpageprec.onclick = function() { findpage(parent,this.i); } }
					numberpage.onclick = function() { findpage(parent,0); }
					
					this.Content.appendChild(numberpage);
					if (currentpage>5){
					this.Content.appendChild(numbertemp); }
					}
					
					
					if (currentpage>0 || currentpage == totalpage) {
							var numberprec = currentpage+1;
					for (i=4; i>0; i--) {
						if (numberprec>0) {
							numberprec2 = numberprec-i;
							if (numberprec2 == currentpage+1) { var style= 'numberpageselected'; } else { var style = 'numberpage'; }
							if (numberprec2 > 1) {
							var numberpage = LinkSpan(numberprec2, ""+style+"");
							numberpage.i= numberprec2-1;
							numberpage.onclick = function() { findpage(parent, this.i); }
							this.Content.appendChild(numberpage);}
						}
					}
				}
								
							
					var currentinterval = currentpage+5;
					if (currentinterval<=totalpage) {
					var numbersuivfin = currentpage;
					for (i=0; i<=5; i++) {

						numbersuivfin = numbersuivfin+1;
					if (numbersuivfin == currentpage+1) { var style= 'numberpageselected'; } else { var style = 'numberpage'; }
						if (numbersuivfin!=1 && numbersuivfin<=totalpage-1 ) {
							var numberpage = LinkSpan(numbersuivfin, ""+style+"");
							numberpage.i= numbersuivfin-1;
							numberpage.onclick = function() { findpage(parent, this.i); }
							this.Content.appendChild(numberpage);
						}
						
					}
					}
				}
					
					
					
				if (currentpage+5>totalpage) {
						var numbersuivfin = currentpage;
						var numberprecfin = currentpage+1;

						for (p=1; p<=5; p++) {
							if (numbersuivfin<totalpage){
							numbersuivfin = numbersuivfin+1;
						if (numbersuivfin == currentpage+1) { var style= 'numberpageselected'; } else { var style = 'numberpage'; }	
							if (numbersuivfin<=totalpage-1 && numbersuivfin!=1) {
							var numberpage = LinkSpan(numbersuivfin, ""+style+"");
								numberpage.i= numbersuivfin-1;
							numberpage.onclick = function() { findpage(parent, this.i); }
							this.Content.appendChild(numberpage);}
								}
						}
		
						
				}

						var numberpagefin = LinkSpan (">", 'numberpage');
				if (totalpage == currentpage+1) { var style= 'numberpageselected'; } else { var style = 'numberpage'; }	
					var numberpagelast = LinkSpan(totalpage, ""+style+"");
					var numbertemp = Span("...", "numberpage");
					if (currentpage<totalpage-1) {
					numberpagefin.i = currentpage+1;
					numberpagefin.onclick = function() { findpage(parent, this.i);} }
						numberpagelast.i= totalpage-1; 
					numberpagelast.onclick = function() { findpage(parent, this.i); }
					if (currentpage< totalpage-7){
					this.Content.appendChild(numbertemp); }
					if (totalpage>1) {
					this.Content.appendChild(numberpagelast);
					this.Content.appendChild(numberpagefin);
					}
					
}






/* fonction qui permet à un object d'hériter d'object d'un autre aobject*/
function heritage(destination, source) { 

    for (var element in source) { 
        destination[element] = source[element]; 

    } 

}
/* fonction qui permet à une classe d'hériter d'object d'une autre classe*/
function heritage_prototype(destination, source ) { 

    for (var element in source) {
        destination.prototype[element] = source[element]; 
    } 

}
/* Liste des valeurs des champs à envoyer dans la requete AJAX */
function ListeValeurAEnvoyer( Container , type ){
	var liste = new Array( Container.getElementsByTagName('input') , Container.getElementsByTagName('textarea') , Container.getElementsByTagName('select') );
	var VARS = new Array();
	for( var i = 0 ; i < liste.length ; i++ ){
		for( var j = 0 ; j < liste[i].length ; j++ ){
			if( ( liste[i][j].parentNode.TimeStampPHP ) ){
				VARS[ liste[i][j].parentNode.id ] = liste[i][j].parentNode.TimeStampPHP;
			}else{
				if( liste[i][j].type != "button" && liste[i][j].type != "submit" ){
					if( liste[i][j].type == "checkbox" ){
						VARS[ liste[i][j].name ] = liste[i][j].checked;
					}else{
						VARS[ liste[i][j].name ] = encodeURIComponent( liste[i][j].value );
					}
				}
				
			}
		}
	}
	
	if( type == "object" ){
		return VARS;
	}else{
		var retour = new String();
		for( var i in VARS ){
			retour += "&"+ i +"="+ VARS[i];
		}
		
		return retour;
	}
}
/* Liste des valeurs des champs à envoyer dans la requete AJAX */
function ListeValeurAEnvoyerSansSelect( Container , type ){
	var liste = new Array( Container.getElementsByTagName('input') , Container.getElementsByTagName('textarea') );
	var VARS = new Array();
	for( var i = 0 ; i < liste.length ; i++ ){
		for( var j = 0 ; j < liste[i].length ; j++ ){
			if( ( liste[i][j].parentNode.TimeStampPHP ) ){
				VARS[ liste[i][j].parentNode.id ] = liste[i][j].parentNode.TimeStampPHP;
			}else{
				VARS[ liste[i][j].name ] = liste[i][j].value;
				
			}
		}
	}
	
	
	if( type == "object" ){
		return VARS;
	}else{
		var retour = new String();
		for( var i in VARS ){
			retour += "&"+ i +"="+ VARS[i];
		}
		
		return retour;
	}
}


function ListeMultiEnvoi( Container , type , champs, except ){
	if( !except ){ var except = ""; }
	var liste = new Array( Container.getElementsByTagName('input') , Container.getElementsByTagName('textarea') , Container.getElementsByTagName('select') );
	var VARS = new Array();
	
	for( var i = 0 ; i < liste.length ; i++ ){
		for( var j = 0 ; j < liste[i].length ; j++ ){
			var check ="";
				if (except!='' || except!='undefined') {

					var reg1=new RegExp("[ ,]+", "g");
					var tab = except.split(reg1);
					for(var h = 0 ; h < tab.length ; h++) {
						if (liste[i][j].name==tab[h] ) {
							check = true;
						}
					}
					if (check != true) {
						if (liste[i][j].name!='' && liste[i][j].name!='undefined'){
							if (liste[i][j].type!='button' && liste[i][j].type!='submit'){
							VARS[ liste[i][j].name ] = liste[i][j].value;
							}
						}
					}
				}
				else {
					if (liste[i][j].type!='button' && liste[i][j].type!='submit'){
					VARS[liste[i][j].name] = liste[i][j].value;
					}
				}
		}
	}
	
	
    if (champs!="undefined" || champs!='') {
		var reg=new RegExp("[ ,]+", "g");
		var tableau=champs.split(reg);
		var info2 = new String();
		for (var i in tableau ) {
			if (VARS[tableau[i]] == "") {
				info2 = "problem";
						return info2; 
			}
//			
		if (tableau[i]=="email") 
			{
			 var emailcheck= VerifEmail(""+VARS['email']+""); 
		 	if (emailcheck == false) { return false; }
			}

		}
		
		}

		if (VARS['email']!="") 
			{
			 var emailcheck= VerifEmail(""+VARS['email']+""); 
		 	if (emailcheck == false) { return false; }
			}
		


	if( type == "object" ){
		return VARS;
	} 
	else{ 
		var retour = new String();
			for( var i in VARS ){
				retour += "&"+ i +"="+ VARS[i];
			}
		return retour;
	}
	
}

function EnregistrePrefs( element , objects ){
	
	for( var i in ModulesDispo ){
		if( i == element.index ){
		
			for( var j in objects ){
					ModulesDispo[i].params[ j ] = encodeURIComponent(objects[j]);
			}
		/*enregistre les préférences de modules*/
		WritePrefs( ModulesDispo , "modules" );
		}else{
			for( var j in ModulesDispo[i].params.subModules ){
				if( j == element.index ){
					for( var o in objects ){
						if( ModulesDispo[i].params.subModules[j].params[ o ] ){
							ModulesDispo[i].params.subModules[j].params[ o ] = encodeURIComponent(objects[o]);
						}
					}
				//enregistre les préférences de modules
				WritePrefs( ModulesDispo , "modules" );
				}
			}
		}
	}
	for( var i in FlyingModules ){
		if( i == element.index ){
			for( var j in objects ){
					FlyingModulesDispo[i].params[ j ] = objects[j];
			}
		/*enregistre les préférences de modules*/
				WritePrefs( ModulesDispo , "flyingmodules" );
		}
	}
}
function WritePrefs( Variable , Type ){
		/*enregistre les préférences de modules*/
		var recmodules = new ObjXMLHttpRequest();
		recmodules.SendRequest("register_pref_modules",true,"&type="+Type+"&CID="+LireCookie('User')+"&modules="+JSON.stringify(Variable));
	
}
function RemoveModule( element ){
	for( var i in ModulesDispo ){
		if( i == element.index ){
			delete( ModulesDispo[i]);
			/*enregistre les préférences de modules*/
			var recmodules = new ObjXMLHttpRequest();
			recmodules.SendRequest("register_pref_modules",true,"&type=modules&CID="+LireCookie('User')+"&modules="+JSON.stringify(ModulesDispo));
		}
	}
	for( var i in FlyingModules ){
		if( FlyingModules[i] == element ){
			delete(FlyingModulesDispo[i]);
			/*enregistre les préférences de modules*/
			var recmodules = new ObjXMLHttpRequest();
			recmodules.SendRequest("register_pref_modules",true,"&type=flyingmodules&CID="+LireCookie('User')+"&modules="+JSON.stringify(FlyingModulesDispo));
		}
	}
}
/*AFFICHE LES ICONES MODULES */
function IconesModules(){
	this.Content = Div();
	var ContainerGeneral = this.Content;
	var ListeDesModules = new ListeModulesDisponibles();
	
	var Icones = Div("Icones");
	
	//OUVRIR MODULE
	this.Ouvrir_Module = function(){
				var prototype = eval(this.module.module_prototype);
				var module = eval(this.module.module);
				var path = this.module.module_path;
				/*prototype le module en fonction des options de prototypage*/
				module.prototype = new prototype;
				
				/*le module hérite des parametres de l'objet parent*/
				heritage_prototype( module , eval(this.module.params) );
				module.prototype.path = path;
				
				/*Vire l'interval pas supprimé sinon*/
				if( typeof(Module)!="undefined"){
					clearTimeout(Module.Interval);
				}
				
				/*créé le module*/
				Module = new module;
				Module.index = this.moduleIndex;
				SetCookie( "lastmodule" , this.moduleIndex );
								
				/*Affiche le module*/
				RemoveAllChilds(document.getElementById('Module'),0);
				document.getElementById('Module').appendChild(Module.Content);
				
				/*Déselectionne les autre icones de modules*/
				var collection = this.parentNode.getElementsByTagName("a");
				
				for( var i = 0 ; i < collection.length ; i++ ){
					if( collection[i] != this ){
						collection[i].className = "iconeModule";
					}else{
						this.className = "iconeModuleSelected";
					}
				}
	}
	
	
	//AJOUT DE MODULE
	Ajout_Module = function( module , i ){
		
		var script = document.createElement("script");  
		script.type = "text/javascript";  
		script.src  = "/modules/" + module.module_path + "/composants.js";
		document.body.insertBefore( script , document.body.firstChild );
		
		var icone = Link( Span(module.module_path) );
		icone.style.background = "transparent url(/modules/"+module.module_path+"/icones/icone.png) no-repeat scroll 0 0";
		icone.className = "iconeModule";
		
		/*donne à chaque icone les donnees de son module*/
		icone.module = module;
		icone.moduleIndex = i;
		
		/*Au clique de la souris, affiche le module*/
		icone.onmousedown = ouvrirmodule;

		/*affiche l'icone*/
		Icones.appendChild( icone );
		if( i == LireCookie("lastmodule") ){
			
			script.module = module;
			script.moduleIndex = i;
			script.onload = function() {icone.onmousedown();};
		}
	


	}
	var ajoutermodule = this.Ajout_Module;
	var ouvrirmodule = this.Ouvrir_Module;
	
	/*Bouton Modifier les modules*/
	var opened = false;
	
	//AGRANDIT LES MODULES DIPOS PLUS
	function Plus(){
		this.Content = Div();
		
		this.Construct = function(){
			RemoveAllChilds(this.Content,0);
			
			var add = ImgButton("/style/"+LireCookie('Style')+"/modules/modify.png","/style/"+LireCookie('Style')+"/modules/modify_on.png");
			/*Au clique de la souris, affiche le module*/
			add.onmousedown = function(obj){
				return function(){
					ListeDesModules.Open();
					obj.Editors();
				}
			}(this)
			this.Content.appendChild(add);
		}
		this.Construct();
		
		this.Editors = function(){
			RemoveAllChilds(this.Content,0);
			ContainerGeneral.insertBefore( this.Content , ListeDesModules.Content );
			
			this.Content.id = "boutons_modification";
			
			var bouton = LinkButton( "supprimer" , this.Delete_Modules);
			this.Content.appendChild(bouton);
			
			var bouton = LinkButton( "deplacer" , Move_Modules);
			this.Content.appendChild(bouton);
			
			var bouton = LinkButton( "fermer les modifications" , this.Close);
			this.Content.appendChild(bouton);
			
		}
		this.Delete_Modules = function(obj){
			return function(){
				RemoveAllChilds(obj.Content,0);
				
				var tableau = new Tableau(2);
				tableau.Add( Text( "suppression de modules en cours...") );
				var fermer = Button( "fermer");
				
				var parent = obj;
				fermer.onclick = function(){
					parent.Editors();
					parent.Undo_Delete_Modules();
				}
				tableau.Add( fermer );
				obj.Content.appendChild(tableau.Content);
				
				var collection = Icones.getElementsByTagName('a');
				
				for( var i in collection ){
					if ( collection[i].module ){
							var del = ImgButton("/style/"+LireCookie('Style')+"/modules/delete.png",
												"/style/"+LireCookie('Style')+"/modules/delete_on.png");
							del.id = "bouton_delete";
							del.target = collection[i];
							del.onclick = function(){
								this.target.parentNode.removeChild(this.target);
								delete( ModulesDispo[this.target.moduleIndex] );
								/*Envoi de la requete pour enregistrer les pref*/
								WritePrefs( ModulesDispo , "modules" );
							}
						collection[i].appendChild( del );
					}
				}
			}
		}(this)
		this.Undo_Delete_Modules = function(){
			var collection = Icones.getElementsByTagName('img');
			//Vire les boutons del des icones modules//
			
			for( var i = collection.length-1 ; i >= 0 ; i-- ){
				if( collection[i] ){
					if( collection[i].id == "bouton_delete" ){
						
						collection[i].parentNode.removeChild( collection[i] );
					}
				}
			}
		}
		
		function Move_Modules(){
		}
		this.Close = function(obj){
			return function(){
				ListeDesModules.Close();
				obj.Construct();
				plus.Content.id="";
				Icones.insertBefore( plus.Content , Icones.firstChild );
			}
		}(this)
	}
	
	/* parcourt la liste pour afficher les icones*/
	for( var i in ModulesDispo ){
		Ajout_Module( ModulesDispo[i] , i );
	}
	
	/*Boutons de modifications*/
	var plus = new Plus();
	Icones.insertBefore( plus.Content , Icones.firstChild );
	
	///AFFICHE LES MODULES DISPONIBLES ET AUTORISES
	function ListeModulesDisponibles(){
		this.Content = Div("ListeModules");
		this.Open = function(){
					this.AfficheListe = function(){
						Listemodules.Reset();
						Listemodules.Add( Langs['Loading'] );
						
						var TousLesModules= new ObjXMLHttpRequest();
						
						if( this.categorie ){
							//Rend le bouton en "selected" parcours tous les autres pour les mettre en normal
							var listescategories = CategoriesBox.Content.getElementsByTagName('li');
							this.parentNode.className = "categorie_selected";
							for( var i = 0 ; i < listescategories.length ; i++ ){
								if( listescategories[i] != this.parentNode ){
								listescategories[i].className = "categorie";
								}
							}
							//Requete
							TousLesModules.SendRequest("modulesdispos",false,"&categorie="+this.categorie);
						}else{
							//Rend le bouton en "selected" parcours tous les autres pour les mettre en normal
							var listescategories = CategoriesBox.Content.getElementsByTagName('li');
							for( var i = 0 ; i < listescategories.length ; i++ ){
								listescategories[i].className = "categorie";
							}
							listescategories[0].className = "categorie_selected";
							//Requete
							TousLesModules.SendRequest("modulesdispos",false,"");
						}
						
						Listemodules.Reset();
						
						var listedesmodules = eval("("+TousLesModules.responseText+")");
						
						for( var i in listedesmodules ){
							
							/*ajoute l'icone à la liste déroulante de modules*/
							
							var button = Link( Span(listedesmodules[i].module_path) );
							button.style.background = "transparent url(/modules/"+listedesmodules[i].module_path+"/icones/icone.png) no-repeat scroll 0 0";
							button.className = "iconeModule";
							button.style.backgroundPosition = "0 -50px";

							button.module = listedesmodules[i];
							button.module.index = i;
							Listemodules.Add( button ) ;
							
							button.onmouseover = function(ev){
									BarreEtat.innerHTML = "<h3>"+Langs[this.module.params.nom]+"</h3>";
									BarreEtat.innerHTML += this.module.description;
									BarreEtat.innerHTML += " | auteur : "+this.module.auteur;
							}
							button.onmouseout = function(){
								BarreEtat.innerHTML = "";
							}
							
							button.onclick = function(){
								/*vérifie si le module est déjà présent*/
								var exists = false;
								for( var i in ModulesDispo ){
									if( ModulesDispo[i]['module'] == this.module['module'] ){
										exists = true;
									}
								}
								
								if( !exists ){
									/*ajoute le module à MoudlesDispo pour pouvoir enregistrer la liste des module dans son fichier.modules*/
									
									ModulesDispo[this.module.index] = this.module;
									/*Envoi de la requete pour enregistrer les pref*/
									WritePrefs( ModulesDispo , "modules" );
									
									/*ajoute licone à la barre de modules*/
									Ajout_Module( this.module , this.module.index );
									
								}else{
									alert('existe déjà');
								}
							}
						}
					}
			var ModulesBox = Div("ModulesBox");
			this.Content.appendChild(ModulesBox);
			
			var title = H( 1 , "Parcourir les modules disponibles" );
			ModulesBox.appendChild(title);
			
			var CategoriesBox = new Liste("ListeCategories");
			ModulesBox.appendChild(CategoriesBox.Content);
			
			
			//AFICCHE LES CATEGORIES DE MODULES//
			var Requete_Categories= new ObjXMLHttpRequest();
			Requete_Categories.SendRequest( "modules_categories" ,false,"");
			var categories = eval('('+Requete_Categories.responseText+')');
			
			var bouton = LinkButton( Langs["All"] , this.AfficheListe );
			CategoriesBox.Add(bouton);
			for( var i in categories ){
				var bouton = LinkButton( Langs[categories[i]] , this.AfficheListe );
				bouton.categorie = categories[i];
				CategoriesBox.Add(bouton , "categorie" );
			}
			//
			
			var Listemodules = new Liste("ListeModulesDispo");
			ModulesBox.appendChild(Listemodules.Content);
			var BarreEtat = Div("BarreEtat");
			this.AfficheListe();
			ModulesBox.appendChild(BarreEtat);
			
		}
		this.Close = function(){
			//Vire les modules dispo//
			RemoveAllChilds(this.Content,0);
		}
	}
	
	/*affiche l'icone*/
	this.Content.appendChild(Icones);
	this.Content.appendChild(ListeDesModules.Content);
}
/*AFFICHE MODULES VOLANTS*/
function FenetresFlyingModules(){
	/* parcourt la liste pour afficher les icones*/
	for( var i in FlyingModulesDispo ){
		
				var prototype = eval(FlyingModulesDispo[i].module_prototype);
				var module = eval(FlyingModulesDispo[i].module);
				/*prototype le module en fonction des options de prototypage*/
				module.prototype = new prototype;
				
				/*le module hérite des parametres de l'objet parent*/
				heritage_prototype( module , eval(FlyingModulesDispo[i].params) );
				
				/*créé le module*/
				this[i] = new module;
				this[i].index = i;
				/*Affiche le module*/
				document.body.appendChild(this[i].Content);
	}
}
/*Ouvre un module SOLO*/
function CreateModule( Module ){
	var prototype = eval(Module.module_prototype);
	var module = eval(Module.module);
	/*prototype le module en fonction des options de prototypage*/
	module.prototype = new prototype;
	/*le module hérite des parametres de l'objet parent*/
	heritage_prototype(module,Module.params);
	/*Vire l'interval pas supprimé sinon*/
	if( typeof(Module)!="undefined"){
		clearTimeout(Module.Interval);
	}
	/*créé le module*/
	return new module;
}
/* PROTOTYPE DES MODULES*/
function Module_SingleConfiguration(){
	this.Content = Div();
	
	
	this.Requete = new ObjXMLHttpRequest();

	this.Initialisation = function(){
		/*vire l'interval sinon il en créé 15,000*/
		clearTimeout(this.Interval);
		this.Titre = Div("TitreModule")
		this.Titre.appendChild(Text(Langs[this.nom]));
		this.Content.appendChild(this.Titre);
		this.Infos = Div();
		this.Content.appendChild(this.Infos);
		
		var footer = Div("FooterModule");
		this.Content.appendChild(footer);
		
		this.Construct();
	}
	
	
}
function subModule_Single(){
	this.Content = Div();
	
	this.Requete = new ObjXMLHttpRequest();

	this.Initialisation = function(){
		/*vire l'interval sinon il en créé 15,000*/
		clearTimeout(this.Interval);
		this.Infos = Div();
		this.Infos.className = "Informations";
		this.Content.appendChild(this.Infos);
		this.Construct();
	}
	
	
}
function subModule_SingleWithTimer(){
	this.Content = Div();
	
	this.Initialisation = function(){
		clearTimeout(this.Interval);
		this.Infos = Div();
		this.Infos.className = "Informations";
		this.Infos.innerHTML = Langs['Loading'];
		
		this.Content.appendChild(this.Infos);
		
		var footer = Div("FooterModule");
		this.Content.appendChild(footer);
		this.Refresh();
		
	}
	this.Refresh = function(){
		/*vire l'interval sinon il en créé 15,000*/
		clearTimeout(this.Interval);
		this.Construct();
		this.Interval = setTimeout( function(obj){ return function(){ obj.Refresh(); }}(this), parseInt(this.delayrefresh));
		
	}
	
}
function Module_SingleWithTimer(){
	this.Content = Div();
	
	this.Initialisation = function(){
		this.Titre = Div("TitreModule");
		this.Titre.appendChild(Text(Langs[this.nom]));
		this.Content.appendChild(this.Titre);
		
		this.Infos = Div();
		this.Infos.className = "Informations";
		this.Content.appendChild(this.Infos);
		this.Infos.innerHTML = Langs['Loading'];
		
	
		var footer = Div("FooterModule");
		this.Content.appendChild(footer);
		this.Refresh();
		
	}
	this.Refresh = function(){
		/*vire l'interval sinon il en créé 15,000*/
		clearTimeout(this.Interval);
		this.Construct();
		this.Interval = setTimeout( function(obj){ return function(){ obj.Refresh(); }}(this), parseInt(this.delayrefresh));
		
	}
	
}
function Module_MultiConfiguration(){
	this.Content = Div();
	
	this.subModuleContent=Div();
	this.subModuleContent.className = "SubModule";
	
	this.CreateOnglets = function(){
		/* Creation des onglets */
		this.Onglets = Div("Onglets");
		this.Content.appendChild(this.Onglets);
		/*parcours la liste des submodules*/
		var Tab = new Tableau(10);
		var submodule_default = 0;
		for( var submodule in this.subModules ){
			/*création de l'onglet*/
			var onglet = document.createElement('a');
			var span = document.createElement('span');
			span.appendChild( Text( this.subModules[submodule].params.nom ) );
			onglet.appendChild( span );
			
			onglet.namesubmodule = this.subModules[submodule].params.nom;
			onglet.submodule = submodule;
			onglet.path = this.path;
			onglet.onclick = function(obj){
				return function(){
					//Met ce bouton en on et les autres en off
					var collection_boutons = Tab.Content.getElementsByTagName('a');
					this.className = "here";
					for( var i = 0 ; i < collection_boutons.length ; i++ ){
						if( collection_boutons[i] != this ){
							collection_boutons[i].className = "";
						}
					}
					////////////////////
					
					var onglets = obj.Onglets.getElementsByTagName("a");
					/*Vire tout ce que contient submodule*/
					RemoveAllChilds(obj.subModuleContent,0);
					var prototype = eval(obj.subModules[this.submodule].module_prototype);
					var module = eval(obj.subModules[this.submodule].module);
					/*définit le content du sous module, ici correspond au content du module parent*/
					module.prototype = new prototype;
					module.prototype.path = this.path;
					
					/*le module hérite des parametres de l'objet parent*/
					heritage_prototype( module , eval(obj.subModules[this.submodule].params) );
					
					module.prototype.Content = obj.subModuleContent;
					/*créé le submodule*/
					obj.subModule = new module;
					obj.subModule.index = this.submodule;

				}
				
			}(this)
			if( submodule_default == 0 ){
				onglet.onclick();
				submodule_default = 1;
			}
			Tab.Add(onglet);
			
		}
			this.Onglets.appendChild(Tab.Content);
	}
	
	this.Requete = new ObjXMLHttpRequest();

	this.Initialisation = function(){
		/*vire l'interval sinon il en créé 15,000*/
		clearTimeout(this.Interval);
		RemoveAllChilds(this.Content,0);
		RemoveAllChilds(this.Onglets,0);
		
		var titre = Div("TitreModule");
		titre.appendChild(Text(Langs[this.nom]));
		
		this.Content.appendChild(titre);
		this.CreateOnglets();
		this.Content.appendChild(this.subModuleContent);
		
		var footer = Div("FooterModule");
		this.Content.appendChild(footer);
	}
	
	
}
/* MODULE VOLANT*/
function Flying_Module(){
	this.Content = Div();
	this.Content.className = "FlyingModule";
		/*Barre de déplacement / fermeture*/
		this.Barre = new Bar();
		this.Content.appendChild(this.Barre.Content);
	
	this.Requete = new ObjXMLHttpRequest();
	this.Initialisation = function(){
		/*vire l'interval sinon il en créé 15,000*/
		clearTimeout(this.Interval);
		this.Content.style.left = this.x + "px";
		this.Content.style.top = this.y + "px";
		
		var instance = this;
		this.Barre.Close.onclick = function(obj){
			return function(){
				RemoveModule( obj );
				document.body.removeChild(obj.Content);
				/*vire l'interval sinon il en créé 15,000*/
				clearTimeout(obj.Interval);
			}
		}(this)
		this.Barre.Content.onmousedown = downMovable.bind(instance,instance.Barre.Content);
		
		
		this.Titre = Div("TitreModule");
		this.Titre.appendChild(Text(Langs[this.nom]));
		this.Content.appendChild(this.Titre);
		
		this.Infos = Div();
		this.Content.appendChild(this.Infos);
		
		var footer = Div("FooterModule");
		this.Content.appendChild(footer);
		this.Construct();
	}
		
	
}
/* MODULE VOLANT*/
function Flying_ModuleWithTimer(){
	this.Content = Div();
	this.Content.className = "FlyingModule";
		
	/*Barre de déplacement / fermeture*/
	this.Barre = new Bar();

	this.Content.appendChild(this.Barre.Content);
	
	this.Requete = new ObjXMLHttpRequest();
	this.Initialisation = function(){
		/*vire l'interval sinon il en créé 15,000*/
		clearTimeout(this.Interval);
		
		var instance = this;
		
		this.Barre.Close.onclick = function(obj){
			return function(){
				RemoveModule( obj );
				document.body.removeChild(obj.Content);
				/*vire l'interval sinon il en créé 15,000*/
				clearTimeout(obj.Interval);
			}
		}(this)
		this.Barre.Content.onmousedown = downMovable.bind(instance);
		
		this.Content.style.left = this.x + "px";
		this.Content.style.top = this.y + "px";
		
		this.Titre = Div("TitreModule");
		this.Titre.appendChild(Text(Langs[this.nom]));
		this.Content.appendChild(this.Titre);
		
		this.Infos = Div();
		this.Content.appendChild(this.Infos);
		
		var footer = Div("FooterModule");
		this.Content.appendChild(footer);
		this.Refresh();
		
	}
	this.Refresh = function(){
		/*vire l'interval sinon il en créé 15,000*/
		clearTimeout(this.Interval);
		this.Construct();
		this.Interval = setTimeout( function(obj){ return function(){ obj.Refresh(); }}(this), parseInt(this.delayrefresh));
		
	}
	
}
function downMovable(){
	document.body.appendChild(this.Content);
	Opacite( this.Content , 80 );
	document.onmousemove = function(obj){
		return function(ev){

			ev = ev || window.event;
			var mousePos = mouseCoords(ev);
			var X=mousePos.x-(obj.Barre.Content.offsetWidth/2);
			var Y=mousePos.y-(obj.Barre.Content.offsetHeight/2);
			if( Y < 0 ){ Y = 0; }
			obj.Content.style.top = Y+"px";
			obj.Content.style.left = X+"px";	

		}
	}(this)
	document.onmouseup = function(obj){
		return function(){
			var pos = findPos( obj.Content );
			EnregistrePrefs( obj , pos );
			document.onmousemove = function(){return false;}
			Opacite( obj.Content , 100 );
		}
	}(this)
 // cancel out any text selections
 document.body.focus();
 // prevent text selection in IE
 document.onselectstart = function () { return false; };
 // prevent IE from trying to drag an image
 this.Content.ondragstart = function() { return false; };
 // prevent text selection (except IE)
 return false;


}
function downMovableDOM( element ){
	element.style.cursor = "move";
	/*cherche le parent*/
	var parent = element.parentNode;
	while( parent.nodeName == "TD" || parent.nodeName == "TR" || parent.nodeName == "TBODY" ){
		parent = parent.parentNode;
	}
	
	
	element.onmousedown = function(ev){
		var containerOrigin = parent.parentNode;
		document.body.appendChild(parent);
		parent.style.position = "absolute";
		Opacite( parent , 80 );
		
		document.onmousemove = function(ev){
	
				ev = ev || window.event;
				var mousePos = mouseCoords(ev);
				var X=mousePos.x-(element.offsetWidth/2);
				var Y=mousePos.y-(element.offsetHeight/2);
				if( Y < 0 ){ Y = 0; }
				parent.style.top = Y+"px";
				parent.style.left = X+"px";
				
			
				/* Cible en dessous de la souris*/
				var areas = document.getElementsByName("AREA");
				for( var i in areas ){
						var pos = findPos(areas[i]);
						if( mousePos.x > pos.x && mousePos.y > pos.y && mousePos.x < ( pos.x + areas[i].offsetWidth) && mousePos.y < ( pos.y + areas[i].offsetHeight) && !areas[i].firstChild){
							areas[i].className = "AREA_on";
							areas[i].style.width = parent.offsetWidth.toString() + "px";
							areas[i].style.height = parent.offsetHeight.toString() + "px";
							var instance = areas[i];
							break;
						}else{
							var instance = containerOrigin;
							areas[i].className = "AREA";
						}
				}
					document.onmouseup = function(){
							instance.appendChild( parent );
							instance.className = "AREA";
							parent.style.position = "static";
							document.onmousemove = function(){return false;}
							Opacite( parent , 100 );
					}
		}
		document.onmousemove(ev);
	 // cancel out any text selections
	 document.body.focus();
	 // prevent text selection in IE
	 document.onselectstart = function () { return false; };
	 // prevent IE from trying to drag an image
	 element.ondragstart = function() { return false; };
	 // prevent text selection (except IE)
	 return false;
	}

}
function MiniArea(){
	var area = document.createElement("div");
	area.setAttribute("name","AREA");
	area.className = "MINIAREA";
	return area;
}
function findPos(obj) {
	var curleft = 0;
	var curtop = 0;
	
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
return {x:curleft,y:curtop};
}
	
function Params_Editor(){
	this.EditButton = LinkSpan("EditButton");
	this.EditButton.onclick = function(obj){
		return function(){
			obj.OpenEditor();
			
		}
	}(this)
	this.Editor = Div();
	this.OpenEditor = function(){
		
		this.Editor =Div("ParametersEditor");
		var params = new Tableau(2);
			
		for( var i in this.parametresEditable ){
			params.Add( Text( this.parametresEditable[i].texte) );
			if( this.parametresEditable[i].type == Field){
				var element = this.parametresEditable[i].type( i , this[i] );
			}
			if( this.parametresEditable[i].type == Select){
				var element = this.parametresEditable[i].type( this.parametresEditable[i].options , i );
			}
			params.Add( element );
		}
		this.Editor.appendChild( params.Content );
		var button = Button( "enregistrer" );
		button.onclick = function(obj){
			return function(){

				obj.ReduceEditor();
			}
		}(this)
		
		this.Editor.appendChild( button );
		var annuler = Button( "annuler" );
		annuler.onclick = function(obj){
			return function(){

				obj.Cancel();
			}
		}(this)
		
		this.Editor.appendChild( annuler );
		this.Content.replaceChild( this.Editor , this.EditButton );
		
	}
	this.ReduceEditor = function(){
		var liste = ListeValeurAEnvoyer(this.Editor , "object");
		EnregistrePrefs( this , liste );
		for( var i in liste ){
			this[i] = liste[i];
			
		}
		this.Content.replaceChild( this.EditButton , this.Editor );
		this.Construct();
	}
	this.Cancel = function(){
		this.Content.replaceChild( this.EditButton , this.Editor );
	}
	this.Content.appendChild(this.EditButton);
}

function Liste_Pages(){
		
		var pages = Div("pages");
		if( this.page > 0 ){
			var button = LinkSpan( "precedente" );
			button.onclick = function(obj){
				return function(){
					obj.page--;
					obj.Construct();
				}
			}(this)
			pages.appendChild( button );
		}
		if( this.page + 1 < this.nPages ){
			var button = LinkSpan( "suivante" );
			button.onclick = function(obj){
				return function(){
					obj.page++;
					obj.Construct();
				}
			}(this)
			pages.appendChild( button );
		}
		this.Infos.appendChild( pages );
}


function Bar(){
	this.Content = Div();
	this.Content.className = "Bar";
	this.Close = LinkButton( "close" );
	this.Content.appendChild(this.Close);
	
}
function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
		
	};
}
function ChaineAleatoire( nombreCaracteres ){
	var parts = new Array();
	var texte = new String();
	parts[0] = [48,57];
	parts[1] = [65,90];
	parts[2] = [97,122];
	for( var i = 0 ; i < nombreCaracteres ; i++ ){
		var part = parts[Math.round(Math.random()*2)];
		var char = String.fromCharCode( Math.round( Math.random()* (part[1]-part[0]) + part[0] ) );
		texte += char;
	}
	return texte;
}
function resizeIframe(){
	var padding = 10;
	if ( this.contentWindow.document.body.offsetHeight + (padding * 2) > this.offsetHeight ){
		this.style.height = ( this.contentWindow.document.body.offsetHeight+ (padding * 2) )+"px";
	}
}

function CheckInt(variable)
{
var exp = new RegExp("^[0-9.]+$","g");
return exp.test(variable);
} 

function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}
