	function fadeIn(objId,opacity) {  if (document.getElementById) {    obj = document.getElementById(objId);    if (opacity <= 100) {      setOpacity(obj, opacity);      opacity += 25;      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);    }  }}function setOpacity(obj, opacity) {  opacity = (opacity == 100)?99.999:opacity;  obj.style.filter = "alpha(opacity:"+opacity+")";  obj.style.KHTMLOpacity = opacity/100;  obj.style.MozOpacity = opacity/100;  obj.style.opacity = opacity/100;}
	
	//Fonction d'autocomplétion de formulaire contact
	function ch_mail(letters)
	{
		
		if(letters.length < 1) 
		{
			$('mail_r').innerHTML = '';
		}
		if(letters.length > 1) 
		{
		var url = './ajax.php?act=ch_mail';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'mail_search='+letters,
                onComplete: gestionReponse
            });
		}
	
		function gestionReponse(xhr)
		{
			if (xhr.status == 200)
			{
				$('mail_r').innerHTML = xhr.responseText;
			}
  	   	else
  	  	 {
 	     	  $('mail_r').innerHTML = xhr.status;
 	   	}
		}

	}
	function aff_list_mail()
	{
		$('cl_mail').setStyle({ display: 'none' });	
		$('list_mail').setStyle({ display: '' });	
	}
	function aff_cl_mail()
	{
		$('list_mail').setStyle({ display: 'none' });	
		$('cl_mail').setStyle({ display: '' });	
	}	
	function aff_list_obj()
	{
		$('cl_obj').setStyle({ display: 'none' });	
		$('list_obj').setStyle({ display: '' });	
	}
	function aff_cl_obj()
	{
		$('list_obj').setStyle({ display: 'none' });	
		$('cl_obj').setStyle({ display: '' });	
	}		
	
	//Fonction d'autosearch google
	function google(image)
	{
		$('google').innerHTML = '<a href="#" onClick="window.open(\'google.php?img='+image+'\',\'Recherche : '+image+'\' , \'status=yes,scrollbars=no,resizable=yes,width=720,height=600\')" class="vert">(Rechercher ?)</a>';
	}
	
	
	
	//Fonction entré dans un champ d'un formulaire
	function enter_input(valeur, id_input)
	{
		$('Mail_qui').value = valeur;
		$('mail_r').innerHTML = '';
	}
	
	
	//Fonction de tri catégorie objet
		function tri_objets(cat)
		{

		var url = './ajax.php?act=tri_objets';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'cat='+cat,
                onComplete: gestionReponse1
            });
		}
	
		function gestionReponse1(xhr)
		{
			if (xhr.status == 200)
			{
				$('liste_objets').innerHTML = xhr.responseText;
			}
  	   		else
  	  		{
 	   		    $('liste_objets').innerHTML = xhr.status;
 	  	 	}
		}	
		//Fonction de tri catégorie objet page profil
		function tri_objets_profil(cat, mail_member)
		{

		var url = './ajax.php?act=tri_objets_profil';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'cat='+cat+'&mail_member='+mail_member,
                onComplete: gestionReponse1
            });
		}
	
		function gestionReponse1(xhr)
		{
			if (xhr.status == 200)
			{
				$('liste_objets').innerHTML = xhr.responseText;
			}
  	   		else
  	  		{
 	   		    $('liste_objets').innerHTML = xhr.status;
 	  	 	}
		}	
						
		//Fonction de tri liste d'amis
		function tri_amis(tri, id_member)
		{

		var url = './ajax.php?act=tri_amis';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'tri='+tri+'&id_member='+id_member,
                onComplete: gestionReponse2
            });
		}
	
		function gestionReponse2(xhr)
		{
			if (xhr.status == 200)
			{
				$('liste_amis').innerHTML = xhr.responseText;
			}
  	   	else
  	  	 {
 	     	  $('liste_amis').innerHTML = xhr.status;
 	   	}
	}
	
	//Fonction de switch account.php
	function switch_account(quoi, tri, id_account)
	{    
		var url = './ajax.php?act=switch_account';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'quoi='+quoi+'&tri='+tri+'&id_account='+id_account,
                onComplete: gestionReponse3
            });
		}
	
		function gestionReponse3(xhr)
		{
		if (xhr.status == 200)
		{
				$('tab_account').innerHTML = xhr.responseText;
		}
  	   	else
  	  	 {
 	     	  $('tab_account').innerHTML = xhr.status;
 	   	}
	}
	//Fonction de switch profil
	function switch_profil(quoi, id_account)
	{    
		var url = './ajax.php?act=switch_profil';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'quoi='+quoi+'&id_account='+id_account,
                onComplete: gestionReponse36
            });
		}
	
		function gestionReponse36(xhr)
		{
		if (xhr.status == 200)
		{
			fadeIn('bloc_profil', 20);
			$('bloc_profil').innerHTML = xhr.responseText;
		}
  	   	else
  	  	 {
			  fadeIn('bloc_profil', 20);
 	     	  $('bloc_profil').innerHTML = xhr.status;
 	   	}
	}	
	//Fonction d'affichage des options pour mes comptes
	function aff_options(id_ligne)
	{
		if(document.getElementById(id_ligne).style.display == 'none')
		{
			$(id_ligne).setStyle({ display: '' });
		}
		else
		{
			$(id_ligne).setStyle({ display: 'none' });
		}
	}
	
	//Répondre billico messages
	function ins_ps(pseudo)
	{
		$('comment').value = '@'+pseudo+' : ';
	}	
	
	//Fonction désaffichage des options pour mes comptes
	function des_options(id_ligne)
	{
		$(id_ligne).setStyle({ display: 'none' });
	}
	//Relancer le contact pour une demande d'acceptation
	function rel_cont(id_tr, mail_cont, id_account)
	{
		$('RE'+id_tr).innerHTML = '<form method="POST" onsubmit="rel_cont2(\''+id_tr+'\', \''+mail_cont+'\', \''+id_account+'\')"><p> Message à transmettre :  <input type="text" name="message" id="message" size="40" class="input-acc" /> <input type="button" value="OK" class="ok-acc" onclick="rel_cont2(\''+id_tr+'\', \''+mail_cont+'\', \''+id_account+'\')" ></p></form>';	
	Tip();
		
	}	
	//Relancer le contact pour une demande de remboursement
	function rel_cont2(id_tr, mail_cont, id_account)
	{
		var message = $F("message");
		var url = './ajax.php?act=rel_cont';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'id_tr='+id_tr+'&mail_cont='+mail_cont+'&message='+message+'&id_account='+id_account,
                onComplete: gestionReponse4
            });
	
	function gestionReponse4(xhr)
	{
		if (xhr.status == 200)
		{
			$('RE'+id_tr).innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('RE'+id_tr).innerHTML = xhr.status;
 	   }
	}
	}
	//Fonction de tri catégorie objet
	function env_compte(id_cpt)
	{

		var url = './ajax.php?act=env_cpt';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'id_cpt='+id_cpt,
                onComplete: gestionReponse4
            });
		}
	
		function gestionReponse4(xhr)
		{
			if (xhr.status == 200)
			{
				$('env_cpt').innerHTML = xhr.responseText;
			}
  	   		else
  	  		{
 	   		    $('env_cpt').innerHTML = xhr.status;
 	  	 	}
		}		
	
	
	
	//Relancer le contact pour une demande d'acceptation
	function renv_accept(id_tr, mail_cont,id_account)
	{
 	   $('DEL'+id_tr).innerHTML =  '<span onClick="des_options(\''+id_tr+'\');">Fermer</span>';
		var url = './ajax.php?act=renv_accept';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'id_tr='+id_tr+'&mail_cont='+mail_cont+'&id_account='+id_account,
                onComplete: gestionReponse5
            });
	
	function gestionReponse5(xhr)
	{
		if (xhr.status == 200)
		{
			$('RENV'+id_tr).innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('RENV'+id_tr).innerHTML = xhr.status;
 	   }
	}
	}
	//Réactuser une ligne
	function reac_ligne(id_tr)
	{
						
		var url = './ajax.php?act=reac_ligne';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'id_tr='+id_tr,
                onComplete: gestionReponse9
            });
	
	function gestionReponse9(xhr)
	{
		if (xhr.status == 200)
		{
			$('ligne_'+id_tr).innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('ligne_'+id_tr).innerHTML = xhr.status;
 	   }
	}
	}	
	//Relancer le contact pour une demande d'acceptation
	function clo_det(id_tr, mail_cont, id_account)
	{
						
		var url = './ajax.php?act=clo_det';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'id_tr='+id_tr+'&mail_cont='+mail_cont+'&id_account='+id_account,
                onComplete: gestionReponse6
            });
	
	function gestionReponse6(xhr)
	{
		if (xhr.status == 200)
		{
			$('CLO'+id_tr).innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('CLO'+id_tr).innerHTML = xhr.status;
 	   }
	}
		reac_ligne(id_tr);
	}
	//1 ère étape de solde d'une dette
	function sol_det(id_tr, mail_cont, id_account)
	{
		$('SOL'+id_tr).innerHTML = '<form method="POST" onsubmit="sol_det2(\''+id_tr+'\', \''+mail_cont+'\')"><p> Montant remboursé : <input type="text" name="cbien" id="cbien" size="5" class="input-acc" /> <input type="button" value="OK" class="ok-acc" onclick="sol_det2(\''+id_tr+'\', \''+mail_cont+'\', \''+id_account+'\')" ></p></form>';
		
	Tip();
	}
	//2 ème étape de solde d'une dette
	function sol_det2(id_tr, mail_cont,id_account)
	{
		var cbien = $F("cbien");
		var url = './ajax.php?act=sol_det';
  		var myAjax = new Ajax.Request(
 		url,
            {
    		 	method:       'post',
     			asynchronous: true,
      			contentType:  'application/x-www-form-urlencoded',
 				encoding: 'ISO-8859-1', 				
       			parameters: 'id_tr='+id_tr+'&mail_cont='+mail_cont+'&cbien='+cbien+'&id_account='+id_account,
                onComplete: gestionReponse8
            });
	
	function gestionReponse8(xhr)
	{
		if (xhr.status == 200)
		{
			$('SOL'+id_tr).innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('SOL'+id_tr).innerHTML = xhr.status;
 	   }
	}
		reac_ligne(id_tr);
	}
	
	
	
	//Notez l'utilisateur après une transaction
	function not_mem(note, mail_cont,id_tr)
	{
						
		var url = './ajax.php?act=not_mem';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'id_tr='+id_tr+'&mail_cont='+mail_cont+'&note='+note,
                onComplete: gestionReponse6
            });
	
	function gestionReponse6(xhr)
	{
		if (xhr.status == 200)
		{
			$('NOT'+id_tr).innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('NOT'+id_tr).innerHTML = xhr.status;
 	   }
	}
	}

	//Système détoile
	function etoi(note , id_tr)
	{
		$('etoile'+id_tr).className = 'et_'+note+'';
	}
	
	//Supprimer un prêt
	function del_pret(id_tr, mail_cont)
	{
		 $('DEL'+id_tr).innerHTML = 'Etes-vous certain ? <a href="#" onClick="del_pret2(\''+id_tr+'\', \''+mail_cont+'\');" class="vert">OUI</a> | <a href="#" onClick="des_options(\''+id_tr+'\');" class="rouge">NON</a>';
		 
	Tip();
	}
	
	//Supprimer un prêt
	function del_pret2(id_tr, mail_cont)
	{
						
		var url = './ajax.php?act=del_pret';
  		var myAjax = new Ajax.Request(
 		url,
            {
                method: 'POST',
       			parameters: 'id_tr='+id_tr+'&mail_cont='+mail_cont,
                onComplete: gestionReponse30
            });
	
	function gestionReponse30(xhr)
	{
		if (xhr.status == 200)
		{
			$('DEL'+id_tr).innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('DEL'+id_tr).innerHTML = xhr.status;
 	   }
	}
		   $('ligne_'+id_tr).setStyle({ display: 'none' });
		   $(id_tr).setStyle({ display: 'none' });
	}		
	
	//Ajouter un commentaire sur le wall d'un membre
	function ad_com(id_member)
	{
		
		var comment = escape($F("comment"));
		var url = './ajax.php?act=ad_com';
  		var myAjax = new Ajax.Request(
 		url,
            {
    		 	method:       'post',
     			asynchronous: true,
      			contentType:  'application/x-www-form-urlencoded',
 				encoding: 'ISO-8859-1', 				
       			parameters: 'id_member='+id_member+'&comment='+comment,
                onComplete: gestionReponse9
            });
	
	function gestionReponse9(xhr)
	{
		if (xhr.status == 200)
		{
			$('result_com').innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('result_com').innerHTML = xhr.status;
 	   }
 	   	$("comment").value='';
 	    aff_com(id_member);	
	}
	}
	//Ajouter un commentaire sur le wall d'un membre
	function aff_com(id_profil)
	{
		
		var url = './ajax.php?act=aff_com';
  		var myAjax = new Ajax.Request(
 		url,
            {
    		 	method:       'post',
     			asynchronous: true,
      			contentType:  'application/x-www-form-urlencoded',
 				encoding: 'ISO-8859-1', 				
       			parameters: 'id_profil='+id_profil,
                onComplete: gestionReponse10
            });
	
	function gestionReponse10(xhr)
	{
		if (xhr.status == 200)
		{
			$('list_comment').innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('list_comment').innerHTML = xhr.status;
 	   }
	}
	}	
	//Ajouter un commentaire sur le wall d'un membre
	function jeveux(id_objet)
	{
		
		var url = './ajax.php?act=jeveux';
  		var myAjax = new Ajax.Request(
 		url,
            {
    		 	method:       'post',
     			asynchronous: true,
      			contentType:  'application/x-www-form-urlencoded',
 				encoding: 'ISO-8859-1', 				
       			parameters: 'id_objet='+id_objet,
                onComplete: gestionReponse180
            });
	
	function gestionReponse180(xhr)
	{
		if (xhr.status == 200)
		{
			$('je_ve'+id_objet).innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('je_ve'+id_objet).innerHTML = xhr.status;
 	   }
	}
	}		
	
	
	//Textarea limité
	var Ecrire = function Ecrire(id, message)
	{
  	  if (document.getElementById) document.getElementById(id).innerHTML = message;
	}

	var TextareaLong = function TextareaLong(Objet,TailleMax,IdAffichage)
	{
 	   TailleObj = Objet.value.length
 	   if (TailleObj > TailleMax )
 	   {
    	    Objet.value = Objet.value.substring(0,TailleMax);
    	    TailleObj = TailleMax;
  	  }
  		  Ecrire(IdAffichage, TailleMax-TailleObj);
	}
	//Supression mail imp
	function del_mail_imp(key)
	{
		$('mail_'+key).innerHTML = '';
	}
  /* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
   see documentation or authors website for more details */

function sack(file) {
	this.xmlhttp = null;

	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createAJAX();
}
 