
//var urlAddress = "http://www.arisal.org";
//var pageName = "ARISAL"; 

function addToFavorites(anchor){
	if (window.external){
		window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
		}
	return(false);
	} 
function addHome(anchor){
	if(msie){
		anchor.style.behavior='url(#default#homepage)'; 
		anchor.setHomePage(anchor.getAttribute('href'));
		}
	else{
		alert("Utilisateur de Firefox, glissez l'icon à gauche de l'adresse url dans la petite maison de démarrage");
		}
	}	

/**********************************************************************************************
	FONCTIONS GENERALES OUTILS
**********************************************************************************************/

/*	test du nagigateur*/
	var msie = navigator.userAgent.indexOf('MSIE') != -1 ? true : false;

/* pour ie : on cache les selects qui ont un z-index sup豩eur �out les div existant */
	function G_aff_select(visibl){if(msie){selects = document.getElementsByTagName("select");for (i = 0; i != selects.length; i++) {selects[i].style.visibility = visibl;}}}

/* renvoi les informations sur la page et le positionnement */
	function G_getPageSize(){
		var xScroll, yScroll, vScroll, hScroll, windowWidth, windowHeight,pageWidth, pageHeight;
		if (window.innerHeight && window.scrollMaxY) {xScroll = document.body.scrollWidth;yScroll = window.innerHeight + window.scrollMaxY;}
		else if (document.body.scrollHeight > document.body.offsetHeight){xScroll = document.body.scrollWidth;yScroll = document.body.scrollHeight;}
		else {xScroll = document.body.offsetWidth;yScroll = document.body.offsetHeight;}
		if (self.innerHeight){windowWidth = self.innerWidth;windowHeight = self.innerHeight;}
		else if (document.documentElement && document.documentElement.clientHeight) {windowWidth = document.documentElement.clientWidth;windowHeight = document.documentElement.clientHeight;}
		else if (document.body){windowWidth = document.body.clientWidth;windowHeight = document.body.clientHeight;}
		if(yScroll < windowHeight){pageHeight = windowHeight;}else{pageHeight = yScroll;}
		if(xScroll < windowWidth){pageWidth = windowWidth;}else{pageWidth = xScroll;}
		if (self.pageYOffset) {vScroll = self.pageYOffset; hScroll = self.pageXOffset;}
		else if (document.documentElement && document.documentElement.scrollTop){vScroll = document.documentElement.scrollTop;hScroll = document.documentElement.scrollLeft;}
		else if (document.body) {vScroll = document.body.scrollTop;hScroll = document.body.scrollLeft;}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight, hScroll , vScroll);
		return arrayPageSize;
		}

/* une petite pause s'impose pour ie */
	function pause(numberMillis) {
		var now = new Date();
		var exitTime = now.getTime() + numberMillis;
		while (true) {
			now = new Date();
			if (now.getTime() > exitTime)
				return;
			}
		}

/* cr蠴ion en live de la BoxUp si n'existe pas.
	 <div id="overlay"></div>
	 <div id="MyBoxUp"><div id="MyBoxUpClose"><img src="../images/close.gif" onclick="" /></div>
		<div id="MyBoxUpFrame"></div>
	 </div>
*/

	var BoxUpLeft="0";//left coordinate of boxup
	var BoxUpTop="0";//top coordinate of buxup
	var xpos=0; // mouse x position
	var ypos=0; // mouse y position
	var domStyle=null; // span DOM object with style 

	function initMyBoxUp(){
		if(!G_obj('MyBoxUp')){
			var arrayPageSize = G_getPageSize();
			
			var objBody = document.getElementsByTagName("body").item(0);
			var objMyBoxUpOverlay = document.createElement("div");
			objMyBoxUpOverlay.setAttribute('id','overlay');
			objMyBoxUpOverlay.style.display = 'none';
			objMyBoxUpOverlay.style.position = 'absolute';
			objMyBoxUpOverlay.style.top = '0';
			objMyBoxUpOverlay.style.left = '0';
			objMyBoxUpOverlay.style.zIndex = '90';

			objBody.insertBefore(objMyBoxUpOverlay, objBody.firstChild);

			var objMyBoxUp = document.createElement("div");
			objMyBoxUp.setAttribute('id','MyBoxUp');
			objMyBoxUp.style.display = 'none';
			objMyBoxUp.style.position = 'absolute';
			objMyBoxUp.style.zIndex = '100';	
			objBody.insertBefore(objMyBoxUp, objMyBoxUpOverlay.nextSibling);

			var objLink = document.createElement("div");
			objLink.setAttribute('id','MyBoxUpClose');
			objMyBoxUp.appendChild(objLink);

			var objLink1 = document.createElement("img");
			objLink1.setAttribute('id','MyBoxUpCloseImg');
			objLink1.setAttribute('alt','');
			objLink1.setAttribute('src','images/closeBtn.gif');
			objLink1.style.cursor = 'pointer';
			objLink1.onclick = function () {hideMyBoxUp(); return false;}
			objLink.appendChild(objLink1);
	
			var objFrame = document.createElement("iframe");
			objFrame.setAttribute('id','MyBoxUpFrame');
			objMyBoxUp.appendChild(objFrame);
			}
		}

function BoxUpPickIt(evt) {
   // accesses the element that generates the event and retrieves its ID
   if (window.addEventListener) { // w3c
	  var objectID = evt.target.id;
      if (objectID.indexOf('MyBoxUpClose') != -1){
         var dom = document.getElementById('MyBoxUp');
         BoxUpLeft=evt.pageX;
         BoxUpTop=evt.pageY;
				 G_obj('MyBoxUpFrame').style.display = 'none';

         if (dom.offsetLeft){
           BoxUpLeft = (BoxUpLeft - dom.offsetLeft); BoxUpTop = (BoxUpTop - dom.offsetTop);
          }
       }
	  // get mouse position on click
	  xpos = (evt.pageX);
	  ypos = (evt.pageY);
	}   
   else { // IE
	  var objectID = event.srcElement.id;
      BoxUpLeft=event.offsetX;
      BoxUpTop=(event.offsetY);
	  // get mouse position on click
	  var de = document.documentElement;
      var b = document.body;
      xpos = event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
      ypos = event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
   // verify if this is a valid element to pick  
   if (objectID.indexOf('MyBoxUpClose') != -1){
      domStyle = document.getElementById('MyBoxUp').style;
    }
   if (domStyle) { 
      return false;
    }
   else {
      domStyle = null;
      return;
    }
 }

function BoxUpDragIt(evt) {
   if (domStyle) {
      if (window.Event) {
         domStyle.left = (evt.clientX-BoxUpLeft + document.body.scrollLeft)+'px';
         domStyle.top = (evt.clientY-BoxUpTop + document.body.scrollTop)+'px';
       } 
      else {
         domStyle.left = (event.clientX-BoxUpLeft + document.body.scrollLeft)+'px'; 
         domStyle.top = (event.clientY-BoxUpTop + document.body.scrollTop)+'px';
       }
    pause(100);
    } 
 }

function BoxUpDropIt() {
   if (domStyle) { 
      domStyle = null;
			G_obj('MyBoxUpFrame').style.display = 'block';
    }
 }


/* Appel de la boxup. */

	function showMyBoxUp(MyBoxUpWidth, MyBoxUpHeight, MySrc , tag){
		initMyBoxUp();
		G_obj('MyBoxUpFrame').src = MySrc;
		pause(500);
		var arrayPageSize = G_getPageSize();
		if(MyBoxUpWidth == ''){MyBoxUpWidth = (arrayPageSize[0] > 100 ? arrayPageSize[0] - 100 : 50);}
		if(MyBoxUpHeight == ''){MyBoxUpHeight = (arrayPageSize[3] > 100 ? arrayPageSize[3] - 100 : 50);}

		G_obj('overlay').style.height = (arrayPageSize[1] + 'px');
		G_obj('overlay').style.width = arrayPageSize[0] + 'px';
		G_obj('overlay').style.display = 'block';
		var MyBoxUptop = arrayPageSize[5] + ((arrayPageSize[3] - MyBoxUpHeight) / 2);
		var MyBoxUpLeft = ((arrayPageSize[0] - MyBoxUpWidth) / 2);

		G_obj('MyBoxUpFrame').style.height = (MyBoxUpHeight-30) + "px";

		G_obj('MyBoxUp').style.top = (MyBoxUptop < 0) ? "0px" : MyBoxUptop + "px";
		G_obj('MyBoxUp').style.left = (MyBoxUpLeft < 0) ? "0px" : MyBoxUpLeft + "px";
    BoxUpLeft=(MyBoxUptop < 0) ? 0 : MyBoxUptop;
    BoxUpTop=(MyBoxUpLeft < 0) ? 0 : MyBoxUpLeft;

		G_obj('MyBoxUp').style.width = MyBoxUpWidth + (msie ? "":"px");
		G_obj('MyBoxUp').style.height = MyBoxUpHeight + (msie ? "":"px");

		if(tag == 1){
			G_obj('MyBoxUpCloseImg').onclick = function () { hideMyBoxUp(); window.location.href = window.location.href ;}
			}
		else{
			G_obj('MyBoxUpCloseImg').onclick = function () {hideMyBoxUp(); return false;}
			}

		if (msie){pause(250);} 
		G_aff_select('hidden');
		G_obj('MyBoxUp').style.display = 'block';
		document.onmousedown = BoxUpPickIt;
		document.onmousemove = BoxUpDragIt;
		document.onmouseup = BoxUpDropIt;		
		}		

	function showMyBoxUpFile(MyBoxUpWidth, MyBoxUpHeight, MySrc , Myvalue){
		MySrc = MySrc + '&selected='+Myvalue;
		showMyBoxUp(MyBoxUpWidth, MyBoxUpHeight, MySrc);
		}

/* appel box up local */

	function showMyBoxUpError(MyBoxUpWidth, MyBoxUpHeight, Mymess){
		initMyBoxUp();
//		G_obj('MyBoxUpFrame').src = 'popup.php';
	  G_obj('MyBoxUpFrame').style.height = 'auto';
	  var testFrame = G_obj('MyBoxUpFrame');
    var doc = testFrame.contentDocument;
    if (doc == undefined || doc == null)
      doc = testFrame.contentWindow.document;

    doc.open();
    doc.innerHTML = '';
    doc.write('<?xml version="1.0" encoding="utf-8"?>');
    doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
    doc.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" dir="ltr" lang="fr">');
    doc.write('	<head>');
    doc.write('		<title></title>');
    doc.write('		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
    doc.write('		<link rel="stylesheet" href="style/default_popupalert.css" />');
    doc.write('	</head>');
    doc.write('	<body>');
    doc.write(Mymess);
    doc.write('	</body>');
    doc.write('	</html>');
    doc.close();
		var arrayPageSize = G_getPageSize();
		if(MyBoxUpWidth == ''){MyBoxUpWidth = (arrayPageSize[0] > 200 ? arrayPageSize[0] - 200 : 100);}
		if(MyBoxUpHeight == ''){MyBoxUpHeight = (arrayPageSize[3] > 200 ? arrayPageSize[3] - 200 : 100);}

		G_obj('overlay').style.height = (arrayPageSize[1] + 'px');
		G_obj('overlay').style.width = arrayPageSize[0] + 'px';
		G_obj('overlay').style.display = 'block';
		var MyBoxUptop = arrayPageSize[5] + ((arrayPageSize[3] - MyBoxUpHeight) / 2);
		var MyBoxUpLeft = ((arrayPageSize[0] - MyBoxUpWidth) / 2);

		G_obj('MyBoxUp').style.top = (MyBoxUptop < 0) ? "0px" : MyBoxUptop + "px";
		G_obj('MyBoxUp').style.left = (MyBoxUpLeft < 0) ? "0px" : MyBoxUpLeft + "px";
		G_obj('MyBoxUp').style.width = MyBoxUpWidth + (msie ? "":"px");
		G_obj('MyBoxUp').style.height = MyBoxUpHeight + (msie ? "":"px");
		if (msie){pause(250);} 
		G_aff_select('hidden');
		G_obj('MyBoxUp').style.display = 'block';
		setTimeout("hideMyBoxUp();",7000);
		}



/* fermeture de la boxup. */
		
	function hideMyBoxUp(){
		G_obj('MyBoxUp').style.display = 'none';
		G_obj('MyBoxUpFrame').src = '';
		G_obj('overlay').style.display = 'none';
		G_aff_select('visible');
		}

/* Selection des contacts. */

	function addContactList(uid, formulaire , champs){
		var tmplistuid = document.forms[formulaire].elements[champs].value;
		var newlistuid = '';
		var nbnewuid = 0;
		if(tmplistuid == ''){
			newlistuid = uid;
			G_obj('member_'+uid).className = "Active";
			nbnewuid = 1;
			}
		else{		
			listuid = tmplistuid.split(",");
			var nbuid = listuid.length;
			var present = false;
			for(i=0;i<nbuid;i++){
				if(listuid[i] == uid){
					// il est pr貥nt : le supprimer
					present = true;
					G_obj('member_'+uid).className = "Inactive";
					}
				else{
					newlistuid = newlistuid+(newlistuid != '' ? ',':'')+listuid[i];
					nbnewuid++;
					}
				}
			if(present == false){
				newlistuid = newlistuid+(newlistuid != '' ? ',':'')+uid;
				G_obj('member_'+uid).className = "Active";
				nbnewuid++;
				}				
			}
		document.forms[formulaire].elements[champs].value = newlistuid;
		G_obj('nbReslut').innerHTML = nbnewuid;
		}

	function addGroupList(uid, formulaire , champs){
		var tmplistuid = document.forms[formulaire].elements[champs].value;
		var newlistuid = '';
		var nbnewuid = 0;
		if(tmplistuid == ''){
			newlistuid = uid;
			G_obj('member_'+uid).className = "Active";
			nbnewuid = 1;
			}
		else{		
			listuid = tmplistuid.split(",");
			var nbuid = listuid.length;
			var present = false;
			for(i=0;i<nbuid;i++){
				if(listuid[i] == uid){
					// il est pr貥nt : le supprimer
					present = true;
					G_obj('member_'+uid).className = "Inactive";
					}
				else{
					newlistuid = newlistuid+(newlistuid != '' ? ',':'')+listuid[i];
					nbnewuid++;
					}
				}
			if(present == false){
				newlistuid = newlistuid+(newlistuid != '' ? ',':'')+uid;
				G_obj('member_'+uid).className = "Active";
				nbnewuid++;
				}				
			}
		document.forms[formulaire].elements[champs].value = newlistuid;
		G_obj('nbGroupReslut').innerHTML = nbnewuid;
		}
		
/* Ajout d'un selectform */

	function AddSelectId(champs , formulaire){
		// recup象tion du nombre de groupe total
		var TbIdGroup = document.forms[formulaire].elements['listid'].value.split('|');
		TbIdGroup.pop();
		var TbNomGroup = document.forms[formulaire].elements['listnom'].value.split('|');
		var nbtotalgroup = TbIdGroup.length;
		var usedgroup = new Array();
		var restgroup = new Array();
		restgroup = TbIdGroup;
		var restgroupname = new Array();
		var i;

		if(nbtotalgroup > 0){
			restgroupname = new Array();
			for(i=0;i<nbtotalgroup;i++){
				restgroupname[TbIdGroup[i]] = TbNomGroup[i];
				}
			}

		i=0;
		var k=0;
		while(G_obj('div_'+champs+i)){
			var idtestgroup = document.forms[formulaire].elements[champs+''+i].options[document.forms[formulaire].elements[champs+''+i].selectedIndex].value;
			var addtmp = true;
			for(var j=0;j<usedgroup.length;j++){if(usedgroup[j] == idtestgroup){addtmp = false;}}
			if(addtmp == true){
				usedgroup[k] = idtestgroup;
				k++;
				}
			i++;
			}

		var nbusedgroup = usedgroup.length;
	
		var objContent = G_obj('div_'+champs+'content');
		objContent.innerHTML = '';
		var k = 0;
		
		if(nbusedgroup > 0){
			for(i=0;i<nbusedgroup;i++){
				var nbrest = restgroup.length;
				if(usedgroup[i] != 'NULL' && nbrest > 0){
					var objdiv = document.createElement("div");
					objdiv.setAttribute('id', 'div_'+champs+k);
					objdiv.className = 'divSelectContent';
					objContent.appendChild(objdiv);
						
					var objselect = document.createElement("select");	
					objselect.setAttribute('name', champs+k);
					objselect.setAttribute('id', champs+k);
					objselect.style.width = '304px';
					objselect.onchange = function () {verifForm(document.forms[formulaire].elements[champs+k]);AddSelectId(champs , formulaire);}
					objdiv.appendChild(objselect);

					var objoption = document.createElement("option");	
					objoption.setAttribute('value', 'NULL');
					objoption.innerHTML = 'Ajouter...';
					objselect.appendChild(objoption);

					for(j=0;j<nbrest;j++){
						if(restgroup[j] != 'NULL'){
							var objoption = document.createElement("option");	
							objoption.setAttribute('value', restgroup[j]);
							objoption.innerHTML = restgroupname[restgroup[j]];
							if(usedgroup[i] == restgroup[j]){
								objoption.setAttribute('selected', 'selected');
								restgroup[j] = 'NULL';
								}
							objselect.appendChild(objoption);
							}
						}
					k++;
					}
				}
			}

		var affblank = 0;
		nbrest = restgroup.length;
		for(j=0;j<nbrest;j++){if(restgroup[j] != 'NULL'){affblank = 1; break;}}

		if(affblank == 1){
			var nbrest = restgroup.length;
			var objdiv = document.createElement("div");
			objdiv.setAttribute('id', 'div_'+champs+k);
			objdiv.className = 'divSelectContent';
			objContent.appendChild(objdiv);
						
			var objselect = document.createElement("select");	
			objselect.setAttribute('name', champs+k);
					objselect.setAttribute('id', champs+k);
			objselect.style.width = '304px';
			objselect.onchange = function () {verifForm(document.forms[formulaire].elements[champs+k]);AddSelectId(champs , formulaire);}
			objdiv.appendChild(objselect);

			var objoption = document.createElement("option");	
			objoption.setAttribute('value', 'NULL');
			objoption.innerHTML = 'Ajouter...';
			objoption.setAttribute('selected', 'selected');
			objselect.appendChild(objoption);

			for(j=0;j<nbrest;j++){
				if(restgroup[j] != 'NULL'){
					var objoption = document.createElement("option");	
					objoption.setAttribute('value', restgroup[j]);
					objoption.innerHTML = restgroupname[restgroup[j]];
					objselect.appendChild(objoption);
					}
				}
			}
		}
		
/* ouverture d'une page dans une nouvelle fen鳲e */

	var NewWindow = '';
	function openWindow(MySrc) {
		if (!NewWindow.closed && NewWindow.location) {
			NewWindow.location.href = MySrc;
			NewWindow.focus();
			} else {
			NewWindow = this.open(MySrc,'_blank', '');
			}
		}
		
/* gestion des onglets */
	function ShowBoxFlip(noflip){
		if(G_obj('BoxFlipContent')){
			var Tabs = G_obj('BoxTabs').getElementsByTagName('li');
			var nbTabs = Tabs.length;
			for(var i=0;i<nbTabs-1;i++){
				G_obj('BoxFlip_'+i).className = 'BoxFlip';
				Tabs[i].className = 'normal';
				}
			G_obj('BoxFlip_'+noflip).className = 'BoxFlipCurrent';
			Tabs[noflip].className = 'current';

			}
		}
		
	function UpdatePosition(champs, champsdest_name){
		champs.form.elements[champsdest_name].options.length = 0;
			var choix=new Option('En premier', '');
		  champs.form.elements[champsdest_name].options[champs.form.elements[champsdest_name].options.length] = choix;

			if(champs.value != ''){
				if(TbCateg[champs.value]){
					for(var i= 0;i <TbCateg[champs.value].length;i++){
						if(TbCateg[champs.value][i] != undefined){
							var choix=new Option('après'+TbCateg[champs.value][i], i);
						  champs.form.elements[champsdest_name].options[champs.form.elements[champsdest_name].options.length] = choix;
						  }
						}
					}
				}
			}

	function OpenReply(mess){
		if(G_obj('DivMessFils_'+mess)){
			if(G_obj('DivMessFils_'+mess).style.display == 'block'){
				G_obj('DivMessFils_'+mess).style.display = 'none';
				}
			else{
				G_obj('DivMessFils_'+mess).style.display = 'block';
				}
			}
		}

	function CountAllMessage(){
		var tbParent = G_obj('messages').getElementsByTagName('ul');
		if(tbParent.length > 0){
			for(i=0; i<tbParent.length;i++){
				if(tbParent[i].id.substring(0,12) == 'DivMessFils_'){
					if(G_obj('DivMessNbFils_'+tbParent[i].id.substring(12))){
						G_obj('DivMessNbFils_'+tbParent[i].id.substring(12)).innerHTML = CountMessage('DivMessFils_'+tbParent[i].id.substring(12));
						}
					}
				}
			}
//		G_obj('contentspecial').innerHTML = contentspecial;	
		}

	function CountMessage(ide){
		var numb = 0;
		var tab = G_obj(ide).getElementsByTagName('ul');
		if(tab.length > 0){
			for(j=0; j<tab.length;j++){
				if(tab[j].id.substring(0,14) == 'DivMessParent_'){numb++;}
				}
			}
		return numb;
		}
	
	function OpenMessageAdded(){
		if(MessAdded != ''){
			get_parent_mess(MessAdded , '');
			if(parent_found != ''){
				OpenAll(parent_found);
				OpenCorps(MessAdded , 1);
				}
			}
		}

	var parent_found = '';
	
	function get_parent_mess(id_mess , old_id){
		var parent_mess = G_obj('DivMessParent_'+id_mess).parentNode;
		if(parent_mess.id != 'messages'){
			var new_id = parent_mess.id.split('_')[1];
			OpenCorps(new_id , 0);
			parent_found = new_id;
			get_parent_mess(new_id , id_mess);
			}
		}
	
	function OpenAll(mess){
		if(mess == ''){
			var divsearch = 'messages';
			}
		else{
			var divsearch = 'DivMessFils_'+mess;
			G_obj('DivMessFils_'+mess).style.display = 'block';
//			G_obj('DivMessContent_'+mess).style.display = 'block';
			}

		var tbParent = G_obj(divsearch).getElementsByTagName('ul');

		if(tbParent.length > 0){
			for(i=0; i<tbParent.length;i++){
				if(tbParent[i].id.substring(0,12) == 'DivMessFils_'){
					tbParent[i].style.display = 'block';
//					G_obj('DivMessContent_'+tbParent[i].id.substring(12)).style.display = 'block';
					}
				else{
//					G_obj('DivMessContent_'+tbParent[i].id.substring(14)).style.display = 'block';
					}
				}
			}
		if(mess != ''){
//			window.location.href='#DivMess_'+mess;
			}
		G_obj('BtnOpenAll').style.display = 'none';
		G_obj('BtnCloseAll').style.display = 'block';
		}

	function CloseAll(mess){
		var divsearch = 'messages';
		var tbParent = G_obj(divsearch).getElementsByTagName('ul');
		if(tbParent.length > 0){
			for(i=0; i<tbParent.length;i++){
				if(tbParent[i].id.substring(0,12) == 'DivMessFils_'){
					tbParent[i].style.display = 'none';
					}
				}
			}
		G_obj('BtnOpenAll').style.display = 'block';
		G_obj('BtnCloseAll').style.display = 'none';
		}

	function openDivMess(tbdiv){
		}

	function OpenCorps(mess , act){
		if(G_obj('DivMessContent_'+mess).style.display == 'block'){
			G_obj('DivMessContent_'+mess).style.display = 'none';
			G_obj('img_'+mess).src = 'images/right.gif';
			}
		else{
			if(G_obj('ImgRead_'+mess).src.substring(G_obj('ImgRead_'+mess).src.lastIndexOf('/')+1) == 'icn_favo_on.gif'){
				if(act == 1){
					PostUpdateStatus(mess);
					}
				}
			G_obj('DivMessContent_'+mess).style.display = 'block';
			G_obj('img_'+mess).src = 'images/down.gif';
			}
		}
		
	function PostUpdateStatus(id_post){
		if(id_post != ''){
			var xhr = getXhr();
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4 && xhr.status == 200){
					if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
					else{
						G_obj('ImgRead_'+id_post).src = 'images/icn_favo_'+(xhr.responseText.trim() == 1?'off':'on')+'.gif';
						}
					}
				}
			xhr.open("POST","?module=account&action=board_post",true);
			xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
			xhr.send('update_post='+id_post);
			}
		}
		
		function MailUpdateStatus(id_post){
			if(id_post != ''){
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
						else{
							G_obj('ImgRead_'+id_post).src = 'images/icn_mail_'+xhr.responseText.trim()+'.gif';
						}
					}
				}
				xhr.open("POST","?module=account&action=board_post",true);
				xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
				xhr.send('update_mail='+id_post);
			}
		}

function addLoadEvent(func){	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}

function AddElement(formulaire , dest , uid){
	var listuid = document.forms[formulaire].elements[dest].value;
	if(uid.checked == true){document.forms[formulaire].elements[dest].value = listuid + (listuid != '' ? ',':'') + uid.value;}
	else{var tbuid = listuid.split(',');var nb = tbuid.length;listuid = '';
		if(nb>0){for(i=0;i<nb;i++){if(tbuid[i] != uid.value){listuid = listuid + (listuid != '' ? ',':'') + tbuid[i];}}}
		document.forms[formulaire].elements[dest].value = listuid;
		}
	verifForm(document.forms[formulaire].elements[dest]);
	}

function FCKeditor_OnComplete( editorInstance ){
  editorInstance.Events.AttachEvent( 'OnBlur', DoSomething ) ;
	}

	function DoSomething( editorInstance ){
    var oEditor = FCKeditorAPI.GetInstance( editorInstance.Name ) ;
		if(document.forms['constant']){
			var MyForm = document.forms[document.forms['constant'].elements['formulaire'].value];
			MyForm.elements[editorInstance.Name].value = oEditor.GetXHTML( true );
			verifForm(MyForm.elements[editorInstance.Name]);
			}
		}
	
function UpdateParentForm(formu , champs , val){
	window.parent.document.forms[formu].elements[champs].value = val;
	window.parent.hideMyBoxUp();
	window.parent.verifForm(window.parent.document.forms[formu].elements[champs]);
	}
	
	function resend_mail_validation(mail){
		if(mail != ''){
			var xhr = getXhr();
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4 && xhr.status == 200){
					if(xhr.responseText.trim() == 'false'){alert("Problème lors de l'envoi.");}
					else{
						alert("Mail envoyé.");
						}
					}
				}
			xhr.open("POST","?module=account&action=validate_creation",true);
			xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" );
			xhr.send('user_resend_to='+mail);
			}
		}

var FileOnglet = '';

function OpenRessource(ide) {
	var url = "?module=files&action=view&file_id="+ide+"";
		if (!FileOnglet.closed && FileOnglet.location) {
			FileOnglet.focus();
			} else {
			FileOnglet = this.open(url,'FileOnglet', '');
			}
		}

	function ShowCategorie(idcat){
		var Tabs = G_obj('DivListDoc').getElementsByTagName('div');
		var nbTabs = Tabs.length;
		for(var i=0;i<nbTabs;i++){
			var Tmp = Tabs[i].id.split("_");
			if(Tmp[2] == idcat || idcat == 'all'){
				G_obj(Tabs[i].id).style.visibility = 'visible';
				G_obj(Tabs[i].id).style.display = 'block';
				}
			else{
				G_obj(Tabs[i].id).style.visibility = 'hidden';
				G_obj(Tabs[i].id).style.display = 'none';
				}
			}

		var Tabs = G_obj('DivLinkDoc').getElementsByTagName('a');
		var nbTabs = Tabs.length;
		for(var i=0;i<nbTabs;i++){
			G_obj(Tabs[i].id).className = 'categorieoff';
			}
		G_obj('categ_'+idcat).className = 'categorieon';

		}
	
	function DeleteMember(MyId , MyModule, MyUrlBack){
		if(MyId != ''){
			showMyBoxUp(300, 200, '?module='+MyModule+'&action=members&do=delete_member&delete='+MyId+''+MyUrlBack+'');
			}
		}

	function ValidateMember(MyId , MyModule){
		if(MyId != ''){
			var xhr = getXhr();
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4 && xhr.status == 200){
					if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
					else{
						G_obj('icn_member_active_'+MyId).src = 'images/icn_page_active_'+xhr.responseText.trim()+'.gif';
					}
				}
			}
		xhr.open("GET","?module="+MyModule+"&action=members&do=validate&id="+MyId+"",true);
		xhr.send(null);
		}
	}

	function InfoListFieldUpdate(MyId, MyTable , MyElement){
		if(MyId != ''){
			if(MyElement == 'delete'){
				showMyBoxUp(300, 200, '?module=admin&action=fields&do='+MyElement+'&dest='+MyTable+'&delete='+MyId+'');
				}
			else{
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
						else{window.location.href = window.location.href;}
						}
					}
				xhr.open("POST","?module=admin&action=fields&do="+MyElement+"",true);
				xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
				xhr.send('id='+MyId+'&dest='+MyTable);
				}
			}
		}

	function InfoListUpdate(MyId, MyForm , MyElement , MyValue){
		if(MyId != ''){
			if(MyElement == 'delete'){
				showMyBoxUp(300, 200, '?module=editor&action='+MyElement+'&dest='+MyForm+'&delete='+MyId+'');
				}
			else{
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
						else{
							if(MyElement == 'menu_page' || MyElement == 'up' || MyElement == 'down'){
								window.location.href = window.location.href;
								}
							else{
								G_obj(MyForm+'_'+MyElement+'_'+MyId).src = 'images/icn_'+MyElement+'_'+xhr.responseText.trim()+'.gif';
								}
							}
						}
					}
				xhr.open("POST","?module=editor&action=ajaxupdate",true);
				xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
				xhr.send('id='+MyId+'&form='+MyForm+'&element='+MyElement+((MyValue)?'&value='+MyValue+'':''));
				}
			}
		}

	function OpenMenu(mid){
		if(mid == 'all'){
			if(document.forms['PageGlobalList'].elements['close'].value == 0){
				var DivStat = 'none';
				var DivImg = './images/right.gif';
				G_obj('img_all').src= './images/right.gif';
				document.forms['PageGlobalList'].elements['close'].value = 1;
				}
			else{			
				var DivStat = 'block';
				var DivImg = './images/down.gif';
				G_obj('img_all').src= './images/down.gif';
				document.forms['PageGlobalList'].elements['close'].value = 0;
				}

			var tb_div = G_obj('PageGlobalList').getElementsByTagName("div");
			for(var i=0;i < tb_div.length ; i++){
				if(tb_div[i].id.substring(0,5) == 'menu_'){
					tb_div[i].style.display = DivStat;
					G_obj('img_'+tb_div[i].id+'').src = DivImg;
					}
				}
			}
		else{
			if(G_obj('menu_'+mid).style.display == 'block'){
				G_obj('menu_'+mid).style.display = 'none';
				G_obj('img_menu_'+mid).src= './images/right.gif';
				}
			else{
				G_obj('menu_'+mid).style.display = 'block';
				G_obj('img_menu_'+mid).src= './images/down.gif';
				}
			}
		}

	function OpenCateg(mid){
		if(mid == 'all'){
			if(document.forms['FieldGlobalList'].elements['close'].value == 0){
				var DivStat = 'none';
				var DivImg = './images/right.gif';
				G_obj('img_all').src= './images/right.gif';
				document.forms['FieldGlobalList'].elements['close'].value = 1;
				}
			else{			
				var DivStat = 'block';
				var DivImg = './images/down.gif';
				G_obj('img_all').src= './images/down.gif';
				document.forms['FieldGlobalList'].elements['close'].value = 0;
				}

			var tb_div = G_obj('FieldGlobalList').getElementsByTagName("div");
			for(var i=0;i < tb_div.length ; i++){
				if(tb_div[i].id.substring(0,5) == 'menu_'){
					tb_div[i].style.display = DivStat;
					G_obj('img_'+tb_div[i].id+'').src = DivImg;
					}
				}
			}
		else{
			if(G_obj('categ_'+mid).style.display == 'block'){
				G_obj('categ_'+mid).style.display = 'none';
				G_obj('img_categ_'+mid).src= './images/right.gif';
				}
			else{
				G_obj('categ_'+mid).style.display = 'block';
				G_obj('img_categ_'+mid).src= './images/down.gif';
				}
			}
		}
		
	function InfoListUpdateSpecial(Mydest , MyId, MyForm , MyElement , MyValue){
		if(MyId != ''){
			if(MyElement == 'delete'){
				showMyBoxUp(300, 200, '?module='+Mydest+'&action='+Mydest+'_page&'+MyValue+'&do='+MyElement+'&dest='+MyForm+'&delete='+MyId+'');
				}
			else{
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
						else{
							if(MyElement == 'is_index' || MyElement == 'up' || MyElement == 'down'){
								window.location.href = window.location.href;
								}
							else{
								G_obj(MyForm+'_'+MyElement+'_'+MyId).src = 'images/icn_'+MyElement+'_'+xhr.responseText.trim()+'.gif';
								}
							}
						}
					}
				xhr.open("POST","?module="+Mydest+"&action="+Mydest+"_page&"+MyValue+"&do=ajaxupdate",true);
				xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
				xhr.send('id='+MyId+'&form='+MyForm+'&element='+MyElement);
				}
			}
		}

	function InfoMessageUpdate(MyId, MyForm , MyElement, MyDate , MyHour){
		if(MyElement == 'add' || MyElement == 'edit'){
			if(!MyHour){MyHour = '';}
			showMyBoxUp(500, 400, '?module=account&action=agenda&do='+MyForm+'_'+MyElement+'&date='+MyDate+'&start='+MyHour+'&event_id='+MyId+'');
			}

		else if(MyElement == 'partage'){
			showMyBoxUp('', '', '?module=account&action=agenda&do='+MyForm+'_'+MyElement+'&date='+MyDate+'&event_id='+MyId+'');
			}

		else if(MyId != ''){
//			if(MyElement == 'not_show' || MyElement == 'quit' || MyElement == 'join'){
				showMyBoxUp(300, 200, '?module=account&action=agenda&do='+MyForm+'_'+MyElement+'&event_id='+MyId+'&date='+MyDate+'');

/*				}
			else{
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
						else{
							if(MyElement == 'is_index' || MyElement == 'up' || MyElement == 'down'){
								window.location.href = window.location.href;
								}
							else{
								G_obj(MyForm+'_'+MyElement+'_'+MyId).src = 'images/icn_'+MyElement+'_'+xhr.responseText.trim()+'.gif';
								}
							}
						}
					}
				xhr.open("POST","?module=account&action=agenda&do=ajaxupdate",true);
				xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
				xhr.send('id='+MyId+'&form='+MyForm+'&element='+MyElement);
				}
*/
			}
		}


// --------------------------------------------------------------------------------
// suis la souris ou pas ?
// --------------------------------------------------------------------------------
	
	function followmouse(e){
		var xcoord=0, ycoord=0, arrayPageSize = G_getPageSize();
		var mouseX = (typeof e != "undefined") ? e.pageX - arrayPageSize[4]: event.clientX;
	  var mouseY = (typeof e != "undefined") ? e.pageY - arrayPageSize[5]: event.clientY;
	  var divWidth = G_obj('InfoBulle').clientWidth;
	  var divHeight = G_obj('InfoBulle').clientHeight;
	  var scrollL = arrayPageSize[4];
	  var scrollT = arrayPageSize[5];
		var docwidth = arrayPageSize[0];
		var docheight = arrayPageSize[1];
	  var top = mouseY; 
	  var bottom = docheight - mouseY;
	  var left = mouseX;
	  var right = docwidth - mouseX;
	  if (right > divWidth + 10){xcoord = scrollL + mouseX + 10;}
	  else if (left > divWidth + 10){xcoord = mouseX + scrollL - divWidth - 10;}
	  else{if (left > right){xcoord = mouseX + scrollL - divWidth - 10;}else{xcoord = scrollL+mouseX + 10;}}
	  if ( bottom > divHeight + 10){ycoord += scrollT + mouseY + 10;}else{ycoord += scrollT + mouseY + 10;}
		if (xcoord + divWidth > docwidth  + scrollL){xcoord = docwidth + scrollL - divWidth;}
		if (ycoord + divHeight > docheight + scrollT){ycoord = docheight + scrollT - divHeight;}
		if (ycoord - scrollT < 0){ycoord = scrollT;}
		if (xcoord - scrollL < 0){xcoord = scrollL;}
		G_obj('InfoBulle').style.left=xcoord+"px";
		G_obj('InfoBulle').style.top=ycoord+"px";
		if (G_obj('InfoBulle').style.display=="none"){G_obj('InfoBulle').style.display="inline";}
		}

// --------------------------------------------------------------------------------
// Affichage des infos bulles
// --------------------------------------------------------------------------------

	function F_show(message , objet){
		if(G_obj(objet)){
			var posX = findPosX(G_obj(objet));
			var posY = findPosY(G_obj(objet));
			if(objet.substring(0, 9) == 'boxEvent_'){
				G_obj('InfoBulle').style.top = posY + 'px';
				}
			else{
				G_obj('InfoBulle').style.top = (posY+G_obj(objet).offsetHeight) + 'px';
				}
			G_obj('InfoBulle').style.left = posX + 'px';
			}
		else{
			document.onmousemove = followmouse;
			}
		G_obj('InfoBulle').innerHTML = '' + message + '';
		G_obj('InfoBulle').style.display = "block";
		G_obj('InfoBulle').style.visibility = "visible";
		G_aff_select('hidden');
		}

// --------------------------------------------------------------------------------
// On cache les infos bulles
// --------------------------------------------------------------------------------

	function F_hide(){
		document.onmousemove = "";
		G_obj('InfoBulle').style.display = "none";
		G_obj('InfoBulle').style.visibility = "hidden";
		G_obj('InfoBulle').style.left="-1000px";
		G_obj('InfoBulle').innerHTML = " ";
		G_aff_select('visible');
		}		

	var X;
	var Y;
	document.write('<div id="InfoBulle" onmouseout="F_hide();"></div>');

/*

	var doon = 0;
	var actualobjet = '';
	
	function F_showAgenda(objet){
		if(actualobjet != objet){
			actualobjet = objet;
			doon = 0;
			}
		if(doon == 0){
			var posX = findPosX(G_obj(objet));
			var posY = findPosY(G_obj(objet));
			G_obj('InfoAgenda').style.top = posY + 'px';
			G_obj('InfoAgenda').style.left = (posX) + 'px';
			G_obj('InfoAgenda').innerHTML = G_obj(objet+'_content').innerHTML;
			G_obj('InfoAgenda').style.display = "block";
			G_obj('InfoAgenda').style.visibility = "visible";
			G_obj('InfoAgenda').className = G_obj(objet).className;
			G_aff_select('hidden');
			G_obj('InfoAgenda').onclick = function () {F_showAgenda(objet);}
			doon = 1;
			}
		else{
			G_obj('InfoAgenda').style.display = "none";
			G_obj('InfoAgenda').style.visibility = "hidden";
			G_obj('InfoAgenda').style.left="-1000px";
			G_obj('InfoAgenda').innerHTML = " ";
			G_aff_select('visible');
			doon = 0;
			}
		}

	document.write('<div id="InfoAgenda"></div>');

*/
	
  function findPosX(obj){
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
	  }

  function findPosY(obj){
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
	  }
	
	function UpdateLink(idlink){
		var xhr = getXhr();
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){ return true;}
			}
		xhr.open("GET","?module=links&action=increase_links&id_link="+idlink+"",true);
		xhr.send(null);
		}
	
	function doAjax(MyModule, MyForm , MyElement, MyId){
		var xhr = getXhr();
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
				else{
					if(MyElement == 'is_droite' || MyElement == 'is_gauche'){
						if(xhr.responseText.trim() == 1){
							G_obj('link_1_'+MyId).checked = true;
							G_obj('link_2_'+MyId).checked = false;
							}
						else{
							G_obj('link_2_'+MyId).checked = true;
							G_obj('link_1_'+MyId).checked = false;
							}
						}
					else{
						G_obj(MyForm+'_'+MyElement+'_'+MyId).src = 'images/icn_'+MyElement+'_'+xhr.responseText.trim()+'.gif';
						}
					}
				}
			}
		xhr.open("GET","?module="+MyModule+"&action="+MyElement+"&id="+MyId+"",true);
		xhr.send(null);
		}

	function OpenMailDetail(mail_id){
		if(mail_id == 'all'){
			}
		else{
			if(G_obj('MailContent_'+mail_id)){
				var disp = G_obj('MailContent_'+mail_id).style.display;
				if(disp.toLowerCase() == 'block'){
					G_obj('MailContent_'+mail_id).style.display = 'none';
					G_obj('MailPuce_'+mail_id).src= 'images/right.gif';
					}
				else{
					G_obj('MailContent_'+mail_id).style.display = 'block';
					G_obj('MailPuce_'+mail_id).src= 'images/down.gif';
					
					if(G_obj('ImgRead_'+mail_id).src.substr((G_obj('ImgRead_'+mail_id).src.lastIndexOf("/")+1)) == 'icn_mail_1.gif'){
						MailUpdateStatus(mail_id);
						}
					}
				}
			}
		}
		
	function PermuteDetails(champs){
		if(champs.value == ''){
			G_obj('divSize_1').style.display = 'none';
			G_obj('divSize_2').style.display = 'none';
			G_obj('divSize_0').style.display = 'none';
			G_obj('divOption_0').style.display = 'none';
			G_obj('divOption_1').style.display = 'none';
			G_obj('divOption_2').style.display = 'none';
			}
		else if(champs.value == 0){
			G_obj('divSize_1').style.display = 'block';
			G_obj('divSize_2').style.display = 'block';
			G_obj('divSize_0').style.display = 'block';
			G_obj('divOption_0').style.display = 'none';
			G_obj('divOption_1').style.display = 'none';
			G_obj('divOption_2').style.display = 'none';
			}
		else if(champs.value == 1){
			G_obj('divSize_1').style.display = 'none';
			G_obj('divSize_2').style.display = 'none';
			G_obj('divSize_0').style.display = 'none';
			G_obj('divOption_0').style.display = 'block';
			G_obj('divOption_1').style.display = 'block';
			G_obj('divOption_2').style.display = 'block';
			}
		else if(champs.value == 5){
			G_obj('divSize_1').style.display = 'none';
			G_obj('divSize_2').style.display = 'none';
			G_obj('divSize_0').style.display = 'none';
			G_obj('divOption_0').style.display = 'none';
			G_obj('divOption_1').style.display = 'none';
			G_obj('divOption_2').style.display = 'none';
			}
		}
		
	function CheckNewOption(champs){
		var TbOption = G_obj('divOption_2').getElementsByTagName('input');
		var nbInput = TbOption.length;

		var tbOptionIndex = Array();
		var tbOptionId = Array();
		var tbOptionValue = Array();
		
		for(var i=0;i<nbInput;i++){
			if(TbOption[i].id.substring(0,16) == 'field_option_id_'){
				tbOptionIndex[TbOption[i].id.substring(16)] = TbOption[i].id.substring(16);
				tbOptionId[TbOption[i].id.substring(16)] = TbOption[i].value;
				}			
			if(TbOption[i].id.substring(0,19) == 'field_option_value_'){
				tbOptionValue[TbOption[i].id.substring(19)] = TbOption[i].value;
				}
			}
		
		var content = '';
		var dest = '';
		var nbOption = tbOptionIndex.length;
		for(var i=0;i<nbOption;i++){
			content = content + "<div id='div_field_option_"+tbOptionIndex[i]+"' class='divSelectContent'>\n"+
								 "<input type=\"hidden\" id=\"field_option_id_"+tbOptionIndex[i]+"\" name=\"field_option_id_"+tbOptionIndex[i]+"\" value=\""+tbOptionId[i]+"\" />\n"+
								 "<input type=\"input\" size=\"25\" id=\"field_option_value_"+tbOptionIndex[i]+"\" name=\"field_option_value_"+tbOptionIndex[i]+"\" value=\""+tbOptionValue[i]+"\" onblur=\"CheckNewOption(this); verifForm(this);\" onkeypress=\"return handleEnter(event);\" />\n"+
								 "</div>\n";

			if(i == nbOption-1){
				// c'est la derniere
				if(tbOptionValue[i] != ''){
					content = content + "<div id='div_field_option_"+(i+1)+"' class='divSelectContent'>\n"+
										 "<input type=\"hidden\" id=\"field_option_id_"+(i+1)+"\" name=\"field_option_id_"+(i+1)+"\" value=\"\" />\n"+
										 "<input type=\"input\" size=\"25\" id=\"field_option_value_"+(i+1)+"\" name=\"field_option_value_"+(i+1)+"\" value=\"\" onblur=\"CheckNewOption(this); verifForm(this);\" onkeypress=\"return handleEnter(event);\" />\n"+
										 "</div>\n";
					dest = i+1;
					}
				else{
					dest = i;
					}
				}
			}
		
		content = content + "<input type=\"button\" value=\""+_L_JS_ADD_OPTION+"\" class=\"Activate\" onclick=\"CheckNewOption(this);\" />\n";
		G_obj('divOption_2').innerHTML = content;
		}

function UpdatePositionField(champs, categ){
	document.forms['NewField'].elements[categ].options.length = 1;
	if(document.forms['NewField'].elements['categ_'+champs.value]){
		var MyOption = document.forms['NewField'].elements['categ_'+champs.value].value.split(",");
		var nbOption = MyOption.length;
		for(var i=0;i<nbOption;i++){
			var choix=new Option(MyOption[i], (i+1));
		  document.forms['NewField'].elements[categ].options[document.forms['NewField'].elements[categ].options.length] = choix;
			}
		}
	}

	function ChangeNotifs(MyUid , MyField, MyValue){
		if(MyField != ''){
			var xhr = getXhr();
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4 && xhr.status == 200){
					if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
					else{
						if(G_obj('img_field_'+MyField)){
							G_obj('img_field_'+MyField).src= 'images/icn_page_active_'+MyValue+'.gif';
							document.getElementsByName('hidden_field_'+MyField)[0].value = Math.abs(MyValue-1);
							}
					}
				}
			}
			xhr.open("POST","?module=account&action=profile&do=ajaxupdate",true);
			xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
			xhr.send('uid='+MyUid+'&field='+MyField+'&champs=value&value='+MyValue);
		}
	}

	function ChangeField(MyUid , MyField , MyChamps , MyValue){
		if(MyField != ''){
			if(G_obj('img_field_'+MyField)){
				G_obj('img_field_'+MyField).src= 'images/blank.gif';
				}
			var xhr = getXhr();
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4 && xhr.status == 200){
					if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
					else{
						if(G_obj('img_field_'+MyField)){
							G_obj('img_field_'+MyField).src= 'images/icn_page_active_1.gif';
							}
					}
				}
			}
			xhr.open("POST","?module=account&action=profile&do=ajaxupdate",true);
			xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
			xhr.send('uid='+MyUid+'&field='+MyField+'&champs='+MyChamps+'&value='+MyValue);
			}
		}

	function ChangeMainField(MyUid , MyField , MyValue){
		if(MyField != ''){
			if(G_obj('img_field_'+MyField)){
				G_obj('img_field_'+MyField).src= 'images/blank.gif';
				}
			var xhr = getXhr();
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4 && xhr.status == 200){
					if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
					else{
						if(G_obj('img_field_'+MyField)){
							G_obj('img_field_'+MyField).src= 'images/icn_page_active_1.gif';
							}
					}
				}
			}
			xhr.open("POST","?module=account&action=profile&do=ajaxdataupdate",true);
			xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
			xhr.send('uid='+MyUid+'&field='+MyField+'&value='+MyValue);
			}
		}
		
	function VerifSizeUserField(champs , size){
		if(champs.value.length > size){
			champs.value = champs.value.substring(0,size);
			if(G_obj('img_field_'+champs.name)){
				G_obj('img_field_'+champs.name).src= 'images/icn_alert_red.gif';
				}
			}
		else{
			G_obj('img_field_'+champs.name).src= 'images/icn_alert_green.gif';
			}
		}

	function ChangeStatusBox(Myid){
		if(Myid != ''){
			var xhr = getXhr();
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4 && xhr.status == 200){
					if(xhr.responseText.trim() == 'false'){alert("erreur : "+xhr.responseText);}
					else{
						if(xhr.responseText.trim() == 1){
							if(G_obj('ImgUserBoxIndex'+Myid)){
								G_obj('ImgUserBoxIndex'+Myid).src= 'images/boxdown.gif';
								}
							if(G_obj('UserBoxIndexContent'+Myid)){
								G_obj('UserBoxIndexContent'+Myid).style.display='block';
								}
							}
						else{
							if(G_obj('ImgUserBoxIndex'+Myid)){
								G_obj('ImgUserBoxIndex'+Myid).src= 'images/boxright.gif';
								}
							if(G_obj('UserBoxIndexContent'+Myid)){
								G_obj('UserBoxIndexContent'+Myid).style.display='none';
								}
							}
						}
					}
				}
			xhr.open("POST","?module=account&action=profile&do=ajaxproperty",true);
			xhr.setRequestHeader( "Content-type" , "application/x-www-form-urlencoded" ); 
			xhr.send('id='+Myid);
			}
		}

	var NewWindow = '';

	function print_special(){
		var MyUrl = window.location.href;
		if(MyUrl.indexOf("?") == -1){MyUrl = MyUrl + "?print";}else{MyUrl = MyUrl + "&print";}			
		if (!NewWindow.closed && NewWindow.location) {
				NewWindow.focus();
				NewWindow.location.href = MyUrl;
			} else {
				NewWindow = this.open(MyUrl,'NewWindow', '');
			}
		}

