
   function checkjour(date)
   {
   	return [true, ''];
   	if (date.getDay()==6) return [true, '']; else return [false, ''];
   }


   function file_old(fichier) {
	var data=null;
	var xhr_object=null;
	if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else return(false);
	xhr_object.open("GET",fichier,false);
	xhr_object.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xhr_object.send(data);
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
	}


	function file(fichier,d,chargement)
	{
	    var data=null;
	    var xhr_object=null;

	    if(window.XMLHttpRequest)
	    	xhr_object=new XMLHttpRequest();
	    else if
	    	(window.ActiveXObject) xhr_object=new ActiveXObject("Microsoft.XMLHTTP");
	    else
	    	return(false);

	    xhr_object.open("POST",fichier,true);
	    xhr_object.onreadystatechange = function()
	    {
		    if(xhr_object.readyState==4)
		    {
			    if(xhr_object.status==200)
			    {
				    if(d!="")
				    	writediv(xhr_object.responseText,d);
				    //$('#'+d).fadeOut(function(){$(this).html(xhr_object.responseText).fadeIn();});
				    if($('#datePickerEspagne').length != 0 || $('#datePickerFrance').length != 0)
					   	datePickerLoader();
			    }
		    }
		    else
		    {
		    	if(chargement!=""){
				    if(d!="" && d.search("suivi_")==-1 && d.search("commu")==-1 && d.search("invit")==-1 && d.search("wait_header")==-1 && document.getElementById(chargement))
				    writediv('<div class="loading" style="text-align:center;"><img src="design/site_12/images/loader.gif" alt="loading" /><br />Recherche en cours...</div>',chargement);
		    	}
			}
	    }
	    xhr_object.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	    xhr_object.send(data);
	}

	function writediv(texte,div)
	{
		if (document.getElementById(div)) {
			document.getElementById(div).innerHTML = texte;
		}
	}

	function majcsvcb(code_csv,code_resa,date_paiement,authnum,montant_paiement)
	{
		reponse = file_old('/js.php?method=majcsvcb&code_csv='+encodeURIComponent(code_csv)+'&code_resa='+encodeURIComponent(code_resa)+'&date_paiement='+encodeURIComponent(date_paiement)+'&authnum='+encodeURIComponent(authnum)+'&montant_paiement='+encodeURIComponent(montant_paiement));
		//if(reponse=='1') alert("Ok");
	}

	function ajax(methode,param2)
	{
		if (methode == "chkMailExist") {
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		if (methode=="change_etat_relance") {
			var note = encodeURIComponent(document.getElementById('etat_relance_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}

		if (methode=="change_etat_alerte") {
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"","chargement");
		}
		else if (methode=="maj_note_interne")
		{
			var note = encodeURIComponent(document.getElementById('note_interne_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		else if (methode=="maj_note_propo")
		{
			var note = encodeURIComponent(document.getElementById('note_interne_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		else if (methode=="maj_note_agence")
		{
			var note = encodeURIComponent(document.getElementById('note_agence_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		else if (methode=="maj_note_annul")
		{
			var note = encodeURIComponent(document.getElementById('note_annul_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		else if (methode=="change_annule")
		{
			var note = encodeURIComponent(document.getElementById('annule_info_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		else if (methode=="get_anchor")
		{
			//reponse=file('/js.php?method='+methode+'&param='+document.location.hash,"liste_location","chargement");
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(document.location.hash),"","chargement");
		}
		else if (methode=="liste_client")
		{
			taille = document.info_client.partie_client.value.length;
			param1 = document.info_client.partie_client.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1,"liste_client","chargement");
			}
		}
		else if (methode=="liste_location")
		{
			taille = document.info.partie.value.length;
			param1 = document.info.partie.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1,"liste_location","chargement");
			}
		}
		else if (methode=="liste_gest_client")
		{
			taille = document.form_gest_resa.partie_client.value.length;
			param1 = document.form_gest_resa.partie_client.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1+'&param2='+param2,"liste_client","chargement");
			}
		}
		else if (methode=="liste_gest_client_propo")
		{
			taille = document.fait_propo.nom_cl.value.length;
			param1 = document.fait_propo.nom_cl.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1+'&param2='+param2,"liste_client","chargement");
			}
		}
		else if (methode=="frm_selection")
		{
			taille = document.frm_selection.partie_client.value.length;
			param1 = document.frm_selection.partie_client.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1+'&param2='+param2,"liste_client","chargement");
			}
		}
		else if (methode=="ajout_animal")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infoanimal_'+param2,"chargement");
			}
		}
		else if (methode=="contrat_recu")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'inforesa_'+param2,"chargement");
			}
		}
		else if (methode=="bon_recu")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infobon_'+param2,"chargement");
			}
		}
		else if (methode=="contrat_online")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'',"chargement");
			}
		}
		else if (methode=="priorite")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infoloc_'+param2,"chargement");
			}
		}
		else if (methode=="fiche_ok")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infoloc_'+param2,"chargement");
			}
		}
		else if (methode=="fiche_ok_agence")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infoagence_'+param2,"chargement");
			}
		}
		else if (methode=="panier")
		{
			if($('#sel_'+param2).attr('checked') == true)
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infopanier_'+param2,"chargement");
			else
				reponse = file('/js.php?method=unsetThisSelection&param2='+param2,'','');
		}
		else if (methode == 'unsetThisSelection')
		{
			reponse = file('/js.php?method=unsetThisSelection&param2='+param2,'','');
		}
		else if (methode=="change_duree_tarifs")
		{
			reponse = file('/js.php?method='+methode+'&param2='+param2,'table_tarifs',"table_tarifs");

		}
		else if (methode=="change_mois_tarifs")
		{
			reponse = file('/js.php?method='+methode+'&param2='+param2,'table_tarifs',"table_tarifs");

		}
		else if (methode=="change_date_tarifs")
		{
			reponse = file('/js.php?method='+methode+'&param2='+param2,'table_tarifs',"table_tarifs");

		}
		else if (methode.search("change_")>-1 && methode!="change_page" && methode!="change_ordre" && methode!="change_dep_detail" && methode!="change_duree_detail")
		{
		    reponse = file('/js.php?method='+methode+'&param='+param2,"","");
		    //mettre a jour bouton recherche
		    //document.location.href=''+reponse+'';
		}
		else if (methode=="dm_add")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="dm_suppr")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="us_add")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="us_suppr")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="al_add")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="al_suppr")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="planning_0")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),param2,"");
		}
		else if (methode=="planning_1")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),param2,"");
		}
		else if (methode=="invisible")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"","");
		}
		else if (methode=="verifie_achat")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"","");
		}
		else if (methode=="selection_side")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"selection_side");
		}
		else if (methode=="resultats2")
		{
			reponse = file_old('/js.php?method='+methode+'&param='+encodeURIComponent(param2));
			//alert(reponse);
			document.location.href=reponse;
		}
		else
		{
		    reponse = file('/js.php?method='+methode+'&param='+param2,"contenu","resultats_recherche");
		}
	}


	function init_calendar()
	{
		if(document.getElementById("datepicker1"))
	    {
	    	$( "#datepicker1" ).datepicker({numberOfMonths: 3,beforeShowDay: checkjour,onSelect: function(dateText, inst) { ajax('questions','depart_'+dateText); }});
	    	var def1 = file_old('/js.php?method=calendar_default&param=1');
	    	var def2 = file_old('/js.php?method=calendar_default&param=2');
	    	var def3 = file_old('/js.php?method=calendar_default&param=3');
	    	var dep = file_old('/js.php?method=calendar_dep');
	    	$( "#datepicker1" ).datepicker( "setDate" , dep );
			$( "#datepicker1" ).datepicker( "option", "minDate", new Date(def1 , def2, def3) );
			$( "#datepicker1" ).datepicker( "option", "maxDate", new Date(2011 , 11, 31) );
	    }

	    if(document.getElementById("datepicker2"))
	    {
	    	$( "#datepicker2" ).datepicker({numberOfMonths: 3,beforeShowDay: checkjour,onSelect: function(dateText, inst) { ajax('change_dep','depart_'+dateText); }});
	    	var def1 = file_old('/js.php?method=calendar_default&param=1');
	    	var def2 = file_old('/js.php?method=calendar_default&param=2');
	    	var def3 = file_old('/js.php?method=calendar_default&param=3');
	    	var dep = file_old('/js.php?method=calendar_dep');
	    	$( "#datepicker2" ).datepicker( "setDate" , dep );
			$( "#datepicker2" ).datepicker( "option", "minDate", new Date(def1 , def2, def3) );
			$( "#datepicker2" ).datepicker( "option", "maxDate", new Date(2011 , 11, 31) );
	    }
	}

function save_langue(clef,langue)
{
    var trad = HTMLentities(document.getElementById('trad_'+langue+'_'+clef).value);
    reponse = file('/js.php?method=langue&clef='+clef+'&langue='+langue+'&trad='+ encodeURIComponent(trad));
}

function change_cara(code_cara,champs,value)
{
	reponse = file('/js.php?method=change_cara&code_cara='+code_cara+'&champs='+champs+'&value='+encodeURIComponent(value),"","");
}

function tri_cara(tpl_cara,tableau)
{
	reponse = file_old('/js.php?method=tri_cara&tpl_cara='+tpl_cara+'&tableau='+tableau);
	if(reponse=='ok') {alert('l\'ordre  bien t enregistr');document.location='/?page=gest_ordre_cara&id='+tpl_cara;}else{alert('Un problme est surevenu lors de l\'enregistrement')}
}

var numb = '0123456789IB-';
function isValid(parm,val) {
if (parm == "") return true;
for (i=0; i<parm.length; i++) {
if (val.indexOf(parm.charAt(i),0) == -1) return false;
}
return true;
}

function isNumber(parm) {return isValid(parm,numb);}

function valide_search_code_log()
{
	if(document.getElementById('recherche_rapide').value!='IB-' && document.getElementById('recherche_rapide').value!='IB-xxxx' && isNumber(document.getElementById('recherche_rapide').value) )
	{
		document.location='/?l='+document.getElementById('recherche_rapide').value.replace(/IB-/g,'');
		reponse = file('/js.php?method=clean_selection',"","");
	}
	else alert('Code invalide');
}

function cal_aff_semaine(classname,style)
{
	var lis=document.getElementsByTagName('li');
	for(var i=0; i<lis.length; i++)
	{
		if(lis[i].className==classname) lis[i].style.background=style;
	}
}
function radio_value(r){
	if(r){
		for(var i=0;i<r.length;i++){ if(r[i].checked) return r[i].value; }
	}
}
function HTMLentities(texte)
{
	texte = texte.replace(/&/g,'&amp;'); // 38 26
	texte = texte.replace(//g,'&euro;'); // 34 22
	texte = texte.replace(/"/g,'&quot;'); // 34 22
	texte = texte.replace(/\'/g,'&#39;'); // 39 27
	texte = texte.replace(/</g,'&lt;'); // 60 3C
	texte = texte.replace(/>/g,'&gt;'); // 62 3E
	texte = texte.replace(/\^/g,'&circ;'); // 94 5E
	texte = texte.replace(//g,'&lsquo;'); // 145 91
	texte = texte.replace(//g,'&rsquo;'); // 146 92
	texte = texte.replace(//g,'&ldquo;'); // 147 93
	texte = texte.replace(//g,'&rdquo;'); // 148 94
	texte = texte.replace(//g,'&bull;'); // 149 95
	texte = texte.replace(//g,'&ndash;'); // 150 96
	texte = texte.replace(//g,'&mdash;'); // 151 97
	texte = texte.replace(//g,'&tilde;'); // 152 98
	texte = texte.replace(//g,'&trade;'); // 153 99
	texte = texte.replace(//g,'&scaron;'); // 154 9A
	texte = texte.replace(//g,'&rsaquo;'); // 155 9B
	texte = texte.replace(//g,'&oelig;'); // 156 9C
	texte = texte.replace(//g,'&#357;'); // 157 9D
	texte = texte.replace(//g,'&#382;'); // 158 9E
	texte = texte.replace(//g,'&Yuml;'); // 159 9F
	// texte = texte.replace(/ /g,'&nbsp;'); // 160 A0
	texte = texte.replace(//g,'&iexcl;'); // 161 A1
	texte = texte.replace(//g,'&cent;'); // 162 A2
	texte = texte.replace(//g,'&pound;'); // 163 A3
	//texte = texte.replace(/ /g,'&curren;'); // 164 A4
	texte = texte.replace(//g,'&yen;'); // 165 A5
	texte = texte.replace(//g,'&brvbar;'); // 166 A6
	texte = texte.replace(//g,'&sect;'); // 167 A7
	texte = texte.replace(//g,'&uml;'); // 168 A8
	texte = texte.replace(//g,'&copy;'); // 169 A9
	texte = texte.replace(//g,'&ordf;'); // 170 AA
	texte = texte.replace(//g,'&laquo;'); // 171 AB
	texte = texte.replace(//g,'&not;'); // 172 AC
	texte = texte.replace(//g,'&shy;'); // 173 AD
	texte = texte.replace(//g,'&reg;'); // 174 AE
	texte = texte.replace(//g,'&macr;'); // 175 AF
	texte = texte.replace(//g,'&deg;'); // 176 B0
	texte = texte.replace(//g,'&plusmn;'); // 177 B1
	texte = texte.replace(//g,'&sup2;'); // 178 B2
	texte = texte.replace(//g,'&sup3;'); // 179 B3
	texte = texte.replace(//g,'&acute;'); // 180 B4
	texte = texte.replace(//g,'&micro;'); // 181 B5
	texte = texte.replace(//g,'&para'); // 182 B6
	texte = texte.replace(//g,'&middot;'); // 183 B7
	texte = texte.replace(//g,'&cedil;'); // 184 B8
	texte = texte.replace(//g,'&sup1;'); // 185 B9
	texte = texte.replace(//g,'&ordm;'); // 186 BA
	texte = texte.replace(//g,'&raquo;'); // 187 BB
	texte = texte.replace(//g,'&frac14;'); // 188 BC
	texte = texte.replace(//g,'&frac12;'); // 189 BD
	texte = texte.replace(//g,'&frac34;'); // 190 BE
	texte = texte.replace(//g,'&iquest;'); // 191 BF
	texte = texte.replace(//g,'&Agrave;'); // 192 C0
	texte = texte.replace(//g,'&Aacute;'); // 193 C1
	texte = texte.replace(//g,'&Acirc;'); // 194 C2
	texte = texte.replace(//g,'&Atilde;'); // 195 C3
	texte = texte.replace(//g,'&Auml;'); // 196 C4
	texte = texte.replace(//g,'&Aring;'); // 197 C5
	texte = texte.replace(//g,'&AElig;'); // 198 C6
	texte = texte.replace(//g,'&Ccedil;'); // 199 C7
	texte = texte.replace(//g,'&Egrave;'); // 200 C8
	texte = texte.replace(//g,'&Eacute;'); // 201 C9
	texte = texte.replace(//g,'&Ecirc;'); // 202 CA
	texte = texte.replace(//g,'&Euml;'); // 203 CB
	texte = texte.replace(//g,'&Igrave;'); // 204 CC
	texte = texte.replace(//g,'&Iacute;'); // 205 CD
	texte = texte.replace(//g,'&Icirc;'); // 206 CE
	texte = texte.replace(//g,'&Iuml;'); // 207 CF
	texte = texte.replace(//g,'&ETH;'); // 208 D0
	texte = texte.replace(//g,'&Ntilde;'); // 209 D1
	texte = texte.replace(//g,'&Ograve;'); // 210 D2
	texte = texte.replace(//g,'&Oacute;'); // 211 D3
	texte = texte.replace(//g,'&Ocirc;'); // 212 D4
	texte = texte.replace(//g,'&Otilde;'); // 213 D5
	texte = texte.replace(//g,'&Ouml;'); // 214 D6
	texte = texte.replace(//g,'&times;'); // 215 D7
	texte = texte.replace(//g,'&Oslash;'); // 216 D8
	texte = texte.replace(//g,'&Ugrave;'); // 217 D9
	texte = texte.replace(//g,'&Uacute;'); // 218 DA
	texte = texte.replace(//g,'&Ucirc;'); // 219 DB
	texte = texte.replace(//g,'&Uuml;'); // 220 DC
	texte = texte.replace(//g,'&Yacute;'); // 221 DD
	texte = texte.replace(//g,'&THORN;'); // 222 DE
	texte = texte.replace(//g,'&szlig;'); // 223 DF
	texte = texte.replace(//g,'&agrave;'); // 224 E0
	texte = texte.replace(//g,'&aacute;'); // 225 E1
	texte = texte.replace(//g,'&acirc;'); // 226 E2
	texte = texte.replace(//g,'&atilde;'); // 227 E3
	texte = texte.replace(//g,'&auml;'); // 228 E4
	texte = texte.replace(//g,'&aring;'); // 229 E5
	texte = texte.replace(//g,'&aelig;'); // 230 E6
	texte = texte.replace(//g,'&ccedil;'); // 231 E7
	texte = texte.replace(//g,'&egrave;'); // 232 E8
	texte = texte.replace(//g,'&eacute;'); // 233 E9
	texte = texte.replace(//g,'&ecirc;'); // 234 EA
	texte = texte.replace(//g,'&euml;'); // 235 EB
	texte = texte.replace(//g,'&igrave;'); // 236 EC
	texte = texte.replace(//g,'&iacute;'); // 237 ED
	texte = texte.replace(//g,'&icirc;'); // 238 EE
	texte = texte.replace(//g,'&iuml;'); // 239 EF
	texte = texte.replace(//g,'&eth;'); // 240 F0
	texte = texte.replace(//g,'&ntilde;'); // 241 F1
	texte = texte.replace(//g,'&ograve;'); // 242 F2
	texte = texte.replace(//g,'&oacute;'); // 243 F3
	texte = texte.replace(//g,'&ocirc;'); // 244 F4
	texte = texte.replace(//g,'&otilde;'); // 245 F5
	texte = texte.replace(//g,'&ouml;'); // 246 F6
	texte = texte.replace(//g,'&divide;'); // 247 F7
	texte = texte.replace(//g,'&oslash;'); // 248 F8
	texte = texte.replace(//g,'&ugrave;'); // 249 F9
	texte = texte.replace(//g,'&uacute;'); // 250 FA
	texte = texte.replace(//g,'&ucirc;'); // 251 FB
	texte = texte.replace(//g,'&uuml;'); // 252 FC
	texte = texte.replace(//g,'&yacute;'); // 253 FD
	texte = texte.replace(//g,'&thorn;'); // 254 FE
	texte = texte.replace(//g,'&yuml;'); // 255 FF

	return texte;
}

function datePickerLoader()
{
    $(function () {
        var daysToDisable = [0,1,2,3,4,5,7];
 		$.datepicker.setDefaults( $.datepicker.regional[ "fr" ] );
        $('#datePickerEspagne').datepicker({
            beforeShowDay: disableSpecificWeekDays,
            showWeek: true,
            altField: "#departEspagne",
			altFormat: "yy-mm-dd",
			minDate: 0
        });
        function disableSpecificWeekDays(date) {
            var day = date.getDay();
            for (i = 0; i < daysToDisable.length; i++) {
                if ($.inArray(day, daysToDisable) != -1) {
                    return [false];
                }
            }
            return [true];
        }
		$('#datePickerFrance').datepicker({
            showWeek: true,
            altField: "#departFrance",
			altFormat: "yy-mm-dd",
			minDate: 0
        });
    });
}

function validMail(email)
{
	var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');
	if(reg.test(email))
		return true ;
	else
		return false;
}

/*FORMULAIRE ENVOYER A UN AMI*/
function share(methode, code_loc)
{
	ajaxShare(methode, code_loc) ;
	$('#fullGrayForm').show() ;
	$('#fullGray').fadeTo('fast', 0.5) ;
}

function ajaxShare(methode, code_loc)
{
	if(methode == 'send')
	{
		var mailError = false ;
		var mailAdresses = '' ;
		var nbAdresses = 0 ;

		$('input[name*="dst_"]').each(function()
		{
			if($(this).val() == 'E-mail du destinataire')
			{
				$(this).parent('tr').remove() ;
			}
			else if(!validMail($(this).val()))
			{
				$(this).css('border-color' , '#CC0000') ;
				mailError = true ;
			}
			else
			{
				$(this).css('border-color' , '#DDDDDD') ;
				mailAdresses = mailAdresses + $(this).val() + ',';
				nbAdresses ++ ;
			}
		});

		if (mailError)
			alert('Une ou plusieurs adresses sont invalides, veuillez vrifier votre saisie') ;
		else if(nbAdresses < 1)
			alert('Vous devez saisir au moins une adresse e-mail valide')
		else
		{
			$.post('/design/site_12/inscription.php',
			{
				methode:methode,
				mailAdresses: mailAdresses,
				code_loc: code_loc
			},
			function(data)
			{
				$('#fullGrayForm').html(data) ;
			});
		}
	}
	else
	{
		$.post('/design/site_12/inscription.php',
		{
			methode:methode,
			email: $('#email').val(),
			nom: $('#nom').val(),
			prenom: $('#prenom').val(),
			genre: $('input[name="genre"]:checked').val(),
			email_id: $('#email_id').val(),
			pwd: $('#pwd').val(),
			code_loc: code_loc
		},
		function(data)
		{
			$('#fullGrayForm').html(data) ;
		});
	}
}

function clearField(data, element)
{
	if(element.val() == data)
		element.val('').css('color', '#000');
}

function unclearField(data, element)
{
	if(element.val() == '')
		element.val(data).css('color', '#999');
}

function addDst()
{
	var nbInput = $('#dstTab input[name*="dst_"]').size() ;
	if(nbInput == 1)
	{
		/*Ajout de la ligne avec le champs et l'image en invisible*/
		$('#lastLine').before('<tr><td><input style="height:0;display:none;" type="text" name="dst_'+nbInput+'" value="E-mail du destinataire" onfocus="clearField(\'E-mail du destinataire\', $(this))" onblur="unclearField(\'E-mail du destinataire\', $(this))"></td><td align="right"><img style="height:0;display:none;cursor:pointer" src="/design/site_12/images/rmv_dst.png" alt="Supprimer un destinataire" onclick="rmvDst()" ></td></tr>') ;
		/*Animation du champs*/
		$('#dstTab input[name="dst_'+(nbInput)+'"]').animate({height:'30px', opacity : 'toggle'}, 150);
		/*Animation du bouton supprimer*/
		$('#dstTab input[name="dst_'+(nbInput)+'"]').parent().next().find('img').animate({height:'32px', opacity : 'toggle'}, 150);
	}
	else if(nbInput <= 9)
	{
		$('#lastLine').before('<tr><td><input style="height:0;display:none;" type="text" name="dst_'+nbInput+'" value="E-mail du destinataire" onfocus="clearField(\'E-mail du destinataire\', $(this))" onblur="unclearField(\'E-mail du destinataire\', $(this))"></td><td></td></tr>') ;
		$('#dstTab input[name="dst_'+(nbInput)+'"]').animate({height:'30px', opacity : 'toggle'}, 150);
	}
}

function rmvDst()
{
	var nbInput = $('#dstTab input[name*="dst_"]').size() ;
	if(nbInput == 2)
	{
		$('#dstTab input[name="dst_'+(nbInput - 1)+'"]').parent().next().find('img').animate({height:'0', opacity : 0}, 150);
		$('#dstTab input[name="dst_'+(nbInput - 1)+'"]').animate({height:'0', opacity : 0}, 150, function(){$('tr#lastLine').prev('tr').remove()});
	}
	else if(nbInput > 2)
	{
		$('#dstTab input[name="dst_'+(nbInput - 1)+'"]').animate({height:'0', opacity : 0}, 150, function(){$('tr#lastLine').prev('tr').remove()});
	}
}
/*FORMULAIRE ENVOYER A UN AMI*/


