// JavaScript Document
function storeCaret(ftext) {
	if (ftext.createTextRange) 
	{
		ftext.caretPos = document.selection.createRange().duplicate();
	}
}



function insertsmilie(smilieface) {
	var t = document.formul.message;
	if (t.createTextRange && t.caretPos) 
	{
		var caretPos = t.caretPos;
			caretPos.text = smilieface;
			t.focus();
	}
	else 
	{
		t.value+=smilieface;
		t.focus();
	}
}


function verifAnnonce(annonce){
    if( annonce.value == '' ){
        alert(langue67);
        return false;
    }
    else{
        return true;
    }
}

function verifPseudoMessage(pseudo)
{ 
	rep = file('include/pages/MOD_MESSAGERIE/ajax/verifPseudo.php?pseudo='+pseudo);
	if( rep == 0 )
	{
		alert(pseudo+' n\'existe pas.');
		document.getElementById('submitMessage').style.visibility="hidden";
	}
	else
	{
		document.getElementById('submitMessage').style.visibility="visible";
	}
}

function cocheDecocheTout(form){
	//alert(forms);
        //form = document.getElementById(forms);
	var toto = 0;
	for (i=0 ; i<= form.length-1 ; i++)
	{
            if (form[i].type == 'checkbox'){
                if( form[i].checked )
                {
                        form[i].checked = false;
                        toto = 2;
                }
                else{
                        form[i].checked = true;
                        toto = 1;
                }
            }
	}
	
	if( toto == "1" ){
		writediv('coche',langue1);
	}
	else if( toto == "2" ){
		writediv('coche',langue2);
	}
}

function cocheDecocheToutSondage(form,nom){
	//alert(forms);
        //form = document.getElementById(forms);
	var toto = 0;
	for (i=0 ; i<= form.length-1 ; i++)
	{
            if (form[i].type == 'checkbox'){
                if( form[i].checked && form[i].name != nom)
                {
                        form[i].checked = false;
                        toto = 2;
                }
                /*else{
                        form[i].checked = true;
                        toto = 1;
                }*/
            }
	}
	
	if( toto == "1" ){
		writediv('coche',langue1);
	}
	else if( toto == "2" ){
		writediv('coche',langue2);
	}
}

function liste_regionResi(pays){
    var rep = file('include/pages/MOD_INSCRIPTION/ajax/liste_region.php?pays='+pays);
	writediv("liste_region", rep);
	if( rep.indexOf("onChange") == '-1' ){
		//alert(rep.indexOf("onChange"));
		//liste_ville(file('include/pages/MOD_INSCRIPTION/ajax/get_region_par_pays.php?pays='+pays),pays);
		if( rep.indexOf("----") == '-1' ){
			rep = file('include/pages/MOD_INSCRIPTION/ajax/get_departement_par_pays.php?pays='+pays);
			liste_ville(rep);
		}
		else{
			liste_ville_champs_vide();
		}
	}
	else{
		liste_ville_select_vide();
	}
}

function liste_regionResiMA_RECHERCHE_DETAILLE(pays){
    var rep = file('include/pages/MOD_PROFIL_DETAILLE/ajax/liste_region_ma_recherche.php?pays='+pays);
	writediv("liste_region_ma_recherche", rep);
	if( rep.indexOf("onChange") == '-1' ){
		//alert(rep.indexOf("onChange"));
		//liste_ville(file('include/pages/MOD_INSCRIPTION/ajax/get_region_par_pays.php?pays='+pays),pays);
		if( rep.indexOf("----") == '-1' ){
			rep = file('include/pages/MOD_PROFIL_DETAILLE/ajax/get_departement_par_pays_ma_recherche.php?pays='+pays);
			liste_villeMA_RECHERCHE_DETAILLE(rep);
		}
		else{
			liste_ville_champs_videMA_RECHERCHE_DETAILLE();
		}
	}
	else{
		liste_ville_select_videMA_RECHERCHE_DETAILLE();
	}
}


function liste_regionResiMA_RECHERCHE_Simple(pays){
    var rep = file('include/pages/MOD_PROFIL_DETAILLE/ajax/liste_region_ma_rechercheSimple.php?pays='+pays+'&i=1');
	var rep2 = file('include/pages/MOD_PROFIL_DETAILLE/ajax/liste_region_ma_rechercheSimple.php?pays='+pays+'&i=2');
	var rep3 = file('include/pages/MOD_PROFIL_DETAILLE/ajax/liste_region_ma_rechercheSimple.php?pays='+pays+'&i=3');
	writediv("liste_region_ma_recherche", rep);
	writediv("liste_region_ma_recherche2", rep2);
	writediv("liste_region_ma_recherche3", rep3);
}


function liste_villeMA_RECHERCHE_DETAILLE(departement){
    rep =file('/include/pages/MOD_PROFIL_DETAILLE/ajax/liste_ville_ma_recherche.php?departement='+departement);
	writediv("liste_ville_ma_recherche", rep);
}

function liste_ville_champs_videMA_RECHERCHE_DETAILLE(){
    writediv("liste_ville_ma_recherche", '<input type="text" class="select"style="width:100%;"id="villeResi" name="villeResi"/>');
}


function liste_ville_select_videMA_RECHERCHE_DETAILLE(){
    writediv("liste_ville_ma_recherche", '<select name="villeResi" id="villeResi" class="select" style="width:100%;"/><option value="-1">'+langue3+'</option></select>');
}

function liste_regionResiRECHERCHE_DETAILLE(pays){
    var rep = file('include/pages/MOD_RECHERCHE_DETAILLE/ajax/liste_region.php?pays='+pays+'&id=1');
	writediv("regionResi1", rep);
	var rep = file('include/pages/MOD_RECHERCHE_DETAILLE/ajax/liste_region.php?pays='+pays+'&id=2');
	writediv("regionResi2", rep);
	var rep = file('include/pages/MOD_RECHERCHE_DETAILLE/ajax/liste_region.php?pays='+pays+'&id=3');
	writediv("regionResi3", rep);
}
function liste_departementRECHERCHE_DETAILLE(region,id){
    writediv("departementResi"+id, file('include/pages/MOD_RECHERCHE_DETAILLE/ajax/liste_departement.php?region='+region+'&id='+id));
}

function liste_villeRECHERCHE_DETAILLE(departement,id){
    writediv("villeResi"+id, file('include/pages/MOD_RECHERCHE_DETAILLE/ajax/liste_ville.php?departement='+departement+'&id='+id));
}

function liste_departement(region){
    writediv("liste_departement", file('include/pages/MOD_INSCRIPTION/ajax/liste_departement.php?region='+region));
}

function liste_ville(departement){
    writediv("liste_ville", file('include/pages/MOD_INSCRIPTION/ajax/liste_ville.php?departement='+departement));
}

function liste_ville_champs_vide(){
    writediv("liste_ville", '<input type="text" class="select"style="width:100%;"id="villeResi"  onBlur="verifForm(this.form);" name="villeResi"/>');
}


function liste_ville_select_vide(){
    writediv("liste_ville", '<select name="villeResi" id="villeResi" class="select" style="width:100%;"/><option value="-1">'+langue3+'</option></select>');
}

function liste_regionOri(pays){
    if( pays == '61' || pays == '285' ){
		rep = file('include/pages/MOD_INSCRIPTION/ajax/liste_region_ori.php?pays='+pays);
		document.getElementById('listeProfil_regionOri').style.visibility='visible';
		writediv("liste_region_ori", rep);
	/*if( rep.indexOf("onChange") == '-1' ){
		//liste_ville(file('include/pages/MOD_INSCRIPTION/ajax/get_region_par_pays.php?pays='+pays),pays);
		if( rep.indexOf("----") == '-1' ){
			rep = file('include/pages/MOD_INSCRIPTION/ajax/get_departement_par_pays.php?pays='+pays);
			liste_ville(rep);
		}
		else{
			liste_ville_champs_vide();
		}
	}
	else{
		liste_ville_select_vide();
	}*/
	}
	else{
		document.getElementById('listeProfil_regionOri').style.visibility='hidden';
	}
	/*rep = file('include/pages/MOD_INSCRIPTION/ajax/liste_region_ori.php?pays='+pays);
	document.getElementById('listeProfil_regionOri').style.visibility='visible';
	writediv("liste_region_ori", rep);*/
}

function liste_regionOri_couple(pays,compteur){
    if( pays == '61' || pays == '285' ){
		rep = file('include/pages/MOD_INSCRIPTION/ajax/liste_region_ori_couple.php?pays='+pays+'&compteur='+compteur);
		document.getElementById('listeProfil_regionOri_couple_'+compteur).style.visibility='visible';
		//writediv("liste_region_ori_couple_"+compteur, rep);
		document.getElementById("liste_region_ori_couple_"+compteur).innerHTML = rep;
	/*if( rep.indexOf("onChange") == '-1' ){
		//liste_ville(file('include/pages/MOD_INSCRIPTION/ajax/get_region_par_pays.php?pays='+pays),pays);
		if( rep.indexOf("----") == '-1' ){
			rep = file('include/pages/MOD_INSCRIPTION/ajax/get_departement_par_pays.php?pays='+pays);
			liste_ville(rep);
		}
		else{
			liste_ville_champs_vide();
		}
	}
	else{
		liste_ville_select_vide();
	}*/
	}
	else{
		document.getElementById('listeProfil_regionOri_couple_'+compteur).style.visibility='hidden';
	}
}

function liste_departementOri(region){
    writediv("liste_departementOri", file('include/pages/MOD_INSCRIPTION/ajax/liste_departement.php?region='+region));
}

function liste_villeOri(departement){
    writediv("liste_villeOri", file('include/pages/MOD_INSCRIPTION/ajax/liste_ville.php?departement='+departement));
}

function liste_ville_champs_vide_ori(){
    writediv("liste_villeOri", '<input type="text" class="select"style="width:100%;"id="villeResi"  onBlur="verifForm(this.form);" name="villeResi"/>');
}


function liste_ville_select_vide_ori(){
    writediv("liste_ville", '<select name="villeResi" id="villeResi" class="select" style="width:100%;"/><option value="-1">'+langue3+'</option></select>');
}
/*
function liste_departementResi(pays){
    /*if(pays == '61' || pays == '285')
	{
		//rep = file('include/pages/MOD_INSCRIPTION/ajax/getVille.php?pays='+pays);
		rep = '<table cellpadding="0" cellspacing="0"><tr><td style="width: 180px;">Ma ville</td><td><input type="text" name="regionResi" class="inputTexte" onBlur="afficheVille(\'liste_regionResi\',this.value);"/></td></tr></table>';
		writediv("liste_regionResi", rep);
	/*}
	else
	{
		writediv("liste_regionResi", file('include/pages/MOD_INSCRIPTION/ajax/liste_region.php?pays='+pays));	
	}
}*/

function listeProfil_departementResi(region){
    writediv("listeProfil_departementResi", file('include/pages/MOD_PROFIL_DETAILLE/ajax/liste_departement.php?region='+region));
}

function listeProfil_regionOri(pays){
    if(pays == '61')
	{
		document.getElementById('listeProfil_regionOri').style.display='block';
		writediv("listeProfil_regionOri", file('include/pages/MOD_PROFIL_DETAILLE/ajax/liste_region.php?pays='+pays));	
	}
	else
	{
		if(document.getElementById('listeProfil_regionOri').style.display == 'block')
			document.getElementById('listeProfil_regionOri').style.display='none';	
	}
}

function listeProfil_regionResi(pays){
    //alert('pays : '+pays);
	/*if(pays == '61')
	{
		document.getElementById('listeProfil_regionResi').style.display='block';*/
		writediv("listeProfil_regionResi", file('include/pages/MOD_PROFIL_DETAILLE/ajax/liste_region.php?pays='+pays));	/*
	}
	else
	{
		if(document.getElementById('listeProfil_regionResi').style.display == 'block')
			document.getElementById('listeProfil_regionResi').style.display='none';	
	}*/
}

/*function listeProfil_villeResi(departement)
{
	if(departement == '61')
	{
		document.getElementById('listeProfil_ville').style.display='block';
		writediv("listeProfil_ville", file('include/pages/MOD_PROFIL_DETAILLE/ajax/liste_ville.php?departement='+departement));	
	}
	else
	{
		if(document.getElementById('listeProfil_ville').style.display == 'block')
			document.getElementById('listeProfil_ville').style.display='none';	
	}
}*/

function listeProfil_villeResi(departement)
{	
	//alert('departement : '+departement);
	writediv("listeProfil_ville", file('include/pages/MOD_PROFIL_DETAILLE/ajax/liste_ville.php?departement='+departement));	
}
function writediv(element, texte)
{
    document.getElementById(element).innerHTML = texte;
}

function file(fichier)
{
    if(window.XMLHttpRequest) // FIREFOX
        xhr_object = new XMLHttpRequest();
    else if(window.ActiveXObject) // IE
        xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
    else
        return(false);
   
    xhr_object.open("GET", fichier, false);
    try{
        xhr_object.send(null);
    }catch(e){}
    if(xhr_object.readyState == 4)
        return(xhr_object.responseText);
    else
        return(false);
}

function favoris()
{
	UrlSite = 'http://www.chocomeet.com';
    NomSite = 'Chocomeet.com - Meilleur site de rencontre Afro-Antillais et MÃ©tis ouvert Ã  tous!';
    /*if (document.all) {
        window.external.AddFavorite(url, title);
        t.sty;
        le.behavior='url(#default#homepage)';
        t.setHomePage(url);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(title, url, "");
    }
    else if(window.opera && window.print){
        var bookmark_element = document.createElement('a');
        bookmark_element.setAttribute('href', url);
        bookmark_element.setAttribute('title', title);
        bookmark_element.setAttribute('rel', 'sidebar');
        bookmark_element.click();
    }*/
    /*if ( navigator.appName != 'Microsoft Internet Explorer' )
    { window.sidebar.addPanel("Chocomeet.com - Meilleur site de rencontre Afro-Antillais et MÃ©tis ouvert Ã  tous!","http://www.chocomeet.com",""); }
    else{ window.external.AddFavorite('http://www.chocomeet.com','Chocomeet.com - Meilleur site de rencontre Afro-Antillais et MÃ©tis ouvert Ã  tous!'); }
    /*else {
        alert('Votre navigateur n\'est pas compatible, merci d\'appuyer simultanÃ©ment sur les touches CTRL+D');
    }*/

    //NomSite = lien.getAttribute('title');
	//UrlSite = lien.getAttribute('href');
	if(window.sidebar) window.sidebar.addPanel(NomSite,UrlSite,""); //Mozilla, FireFox,...
	else if (window.external) alert ("Utilisez CTRL + D \n pour ajouter " + NomSite + " dans vos favoris !"); //Internet explorer Windows
	else if (document.all && (navigator.userAgent.indexOf('Win') < 0)) alert ("Utilisez POMME + D \n pour ajouter " + NomSite + " dans vos favoris !"); //Internet explorer MAC
	else if (window.opera && window.print) alert ("Utilisez CTRL + D \n pour ajouter " + NomSite + " dans vos favoris !"); //Opera
	else alert ("Cette fonction n'est pas disponible pour votre navigateur.");


}

function changeStatut(statut,idClient)
{
	var rep = file('./include/pages/MOD_STATUT/changeStatut.php?statut='+statut+'&idClient='+idClient);
	if( rep == '-1' ){
		alert(langue48);
	}
    else{
        $.post("/cometchat/cometchat_send.php",{statusmessage:rep},function(){});
        $("#cometchat_userstab_icon").removeClass("cometchat_user_available2");$("#cometchat_userstab_icon").removeClass("cometchat_user_busy2");$("#cometchat_userstab_icon").removeClass("cometchat_user_invisible2");
        switch(statut){
            case "1": statut = "available"; $("#cometchat_userstab_icon").addClass("cometchat_user_available2"); $("#cometchat_userstab_text").html("C. Messenger ("+onlineNumber+")"); $(".cometchat_optionsstatus_avilable").css('text-decoration','underline');$(".cometchat_optionsstatus_busy").css('text-decoration','none');$(".cometchat_optionsstatus_invisible").css('text-decoration','none');  break;
            case "6": statut = "offline"; $("#cometchat_userstab_icon").addClass("cometchat_user_invisible2"); $("#cometchat_userstab_text").html("D&eacute;connect&eacute;(e)"); $(".cometchat_optionsstatus_avilable").css('text-decoration','none');$(".cometchat_optionsstatus_busy").css('text-decoration','none');$(".cometchat_optionsstatus_invisible").css('text-decoration','underline'); break;
            default: statut = "busy"; $("#cometchat_userstab_icon").addClass("cometchat_user_busy2"); $("#cometchat_userstab_text").html("C. Messenger ("+onlineNumber+")"); $(".cometchat_optionsstatus_avilable").css('text-decoration','none');$(".cometchat_optionsstatus_busy").css('text-decoration','underline');$(".cometchat_optionsstatus_invisible").css('text-decoration','none');break;
        }

        $(".cometchat_statustextarea").val(rep);
        $.post("/cometchat/cometchat_send.php",{status:statut},function(){});
    }

    
}

function enregistre_value(value,nom){
	var rep = file('./include/pages/MOD_PROFIL_DETAILLE/modifPreferences.php?reponse='+value+'&nom='+nom);
}

function enregistrePreferences(reponse,idQuestion){
	var rep = file('./include/pages/MOD_PROFIL_DETAILLE/modifPreferences.php?reponse='+reponse+'&idQuestion='+idQuestion);	
}

function enregistreMusique(reponse,idClient,idMusique){
	var rep = file('./include/pages/MOD_PROFIL_DETAILLE/modifMusiques.php?reponse='+reponse+'&idMusique='+idMusique+'&idClient='+idClient);
}

function enregistreCinema(reponse,nom,idCinema){
	var rep = file('./include/pages/MOD_PROFIL_DETAILLE/modifCinema.php?reponse='+reponse+'&nom='+nom+'&idCinema='+idCinema);	
}

function enregistreLecture(reponse,nom,idLecture){
	var rep = file('./include/pages/MOD_PROFIL_DETAILLE/modifLecture.php?reponse='+reponse+'&nom='+nom+'&idLecture='+idLecture);	
}

function enregistreSports(reponse,nom,idSports){
	var rep = file('./include/pages/MOD_PROFIL_DETAILLE/modifSports.php?reponse='+reponse+'&nom'+nom+'&idSports='+idSports);
}

function enregistreRestaurants(reponse,nom,idRestaurant){
	var rep = file('./include/pages/MOD_PROFIL_DETAILLE/modifRestaurants.php?reponse='+reponse+'&nom'+nom+'&idRestaurant='+idRestaurant);
}



function enregistreLoisirs(reponse,nom,idLoisirs){
	var rep = file('./include/pages/MOD_PROFIL_DETAILLE/modifLoisirs.php?reponse='+reponse+'&nom'+nom+'&idLoisirs='+idLoisirs);
}

function deplacerMessage(idDossier,idMessage){
	if( idDossier != '0' )
	{
		var rep = file('./include/pages/MOD_MESSAGERIE/deplacerMessage.php?idDossier='+idDossier+'&idMessage='+idMessage);
		if( rep == '-1' )
		{
			alert(langue49);
		}
        else{
            alert(langue71);
        }
	}
}


function deplacerMessageOuvert(idDossier,idMessage,url){
	if( idDossier != '0' )
	{
		var rep = file('./include/pages/MOD_MESSAGERIE/deplacerMessage.php?idDossier='+idDossier+'&idMessage='+idMessage);
		if( rep == '-1' )
		{
			alert(langue49);
		}
        else{
            alert(langue71);
            window.location.replace(url);
        }
	}
}
function deplacerToutMessageCocherVers(idDossier,form,page){
	var nb=0;
	if( idDossier != '0' )
	{
		var toto = 0;
		for (i=0 ; i<= form.length-1 ; i++)
		{
			if (form[i].type == 'checkbox'){
				if( form[i].checked )
				{
					var nom = form[i].name;
					var id = nom.split('_');
					var rep = file('./include/pages/MOD_MESSAGERIE/deplacerMessage.php?idDossier='+idDossier+'&idMessage='+id[1]);
					nb++;
				}
			}
		}
	}
	
	if( nb > 0 ){
		if( nb > 1 ){
			alert(langue6);
		}
		else{
			alert(langue7);
		}
		window.location.replace('index.php?page='+page);
	}
	else{
		alert(langue50);
	}
}

function afficheVille(element,cp){
	var rep = file("include/pages/MOD_INSCRIPTION/ajax/getVille.php?cp="+cp);
	if( cp != '' ){
		if( rep != '-1' ){
			rep = '<table cellpadding="0" cellspacing="0"><tr><td style="width: 180px;"><a style="cursor:pointer;text-decoration:underline;" onClick="reInit(\''+element+'\');">'+langue8+'</a></td><td colspan="3"><input type="text" name="regionResi" class="inputTexte" value="'+rep+'"/></td></tr></table>';
			writediv(element,rep);
		}
		else{
			alert(langue51);
		}
	}
}
function reInit(element){
	var rep = '<table cellpadding="0" cellspacing="0"><tr><td style="width: 180px;">'+langue9+'</td><td colspan="3"><input type="text" name="regionResi" class="inputTexte" onBlur="afficheVille(\'liste_regionResi\',this.value);" /></td></tr></table>';
	writediv(element,rep);
}


function verifCodePostal(cp){
	var valid = 0;
	
	if( cp == ''){
		writediv("codePostalbox", "<span style='color:red'>"+langue10+"</span>");
		valid = 0;
	}
	/*else if( document.getElementById('paysResi').value == '61' || document.getElementById('paysResi').value == '285' ){
		
	}*/
	else{
		writediv("codePostalbox", "<span style='color:green'>"+langue11+"</span>");
		valid = 1;
	}
	
	return valid;
}

function verifPays(pays){
	var valid = 0;
	
	if( pays == '288' && pays == '284'){
		writediv("paysbox", "<span style='color:red'>*</span>");
		valid = 0;
	}
	else{
		writediv("paysbox", "<span style='color:green'>*</span>");
		valid=1;
	}
	
	return valid;
}

function verifDepartement(departement){
	var valid = 0;
	
	if( departement  == '-1'){
		writediv("regionbox", "<span style='color:red'>*</span>");
		valid = 0;
	}
	else{
		writediv("regionbox", "<span style='color:green'>*</span>");
		valid=1;
	}
	
	return valid;
}

function verifVille(departement){
	var valid = 0;
	
	if( departement  == '-1'){
		writediv("villebox", "<span style='color:red'>*</span>");
		valid = 0;
	}
	else{
		writediv("villebox", "<span style='color:green'>*</span>");
		valid=1;
	}
	
	return valid;
}

function removeAccents(input,texte){
    rep = file("include/ajax/removeAccents.php?texte=" + texte );
    alert(rep);
    //input.value=file("include/ajax/removeAccents.php?texte=" + texte );
}
 
function verifPseudonyme(pseudonyme){
	var valid = 0;
	
	if( trim(pseudonyme) != "" ){
		if(validMail(pseudonyme) != true){
			if(verifEspace(pseudonyme) != false ){
				textes = file("include/ajax/pseudo.php?pseudo=" + pseudonyme );
				if( textes == -1 ){
					writediv("pseudonymebox", '<span style="color:red">*</span>');
					valid = 0;
					writediv("contenuPopupPseudo",file("include/ajax/propositionPseudo.php?pseudo="+pseudonyme));
					document.getElementById('pseudo').value = '';
					centerPopupPseudo();
					//load popup
					loadPopupPseudo();
					
					$("#popupContactClosePseudo").click(function(){
						disablePopupPseudo();
					});
					
					$("#popupValidationPseudo").click(function(){
						if( document.getElementById('autrePseudo').value != '' ){
							test = file("include/ajax/pseudo.php?pseudo=" + document.getElementById('autrePseudo').value );
							if( test == -1 ){
								alert(langue12);
							}
							else{
								document.getElementById('pseudo').value = document.getElementById('autrePseudo').value;
								disablePopupPseudo();
							}
						}
						else{
							var champs = document.getElementById('form_pseudo').getElementsByTagName("input");
							for(var i=0, n=champs.length; i<n; i++) {
								var nom = champs[i].getAttribute("id");
								if( nom ){
									if( document.getElementById(nom).checked ){
										document.getElementById('pseudo').value = document.getElementById(nom).value;//document.getElementById('choixPseudo').value;
										disablePopupPseudo();
									}
								}
							}
							//pseudo = document.getElementById('choixPseudo').value;
						}
					});
					
					$("#popupAnnulationPseudo").click(function(){
						disablePopupPseudo();
					});
					
					$("#backgroundPopup").click(function(){
						disablePopupPseudo();
					});
					
					$(document).keypress(function(e){
						if(e.keyCode==27 && popupStatus==1){
							disablePopupPseudo();
						}
					});
				}
				else{
					writediv("pseudonymebox", "<span style='color:green'>*</span>");
					valid = 1;
				}
			}
			else
			{
				writediv("pseudonymebox", '<span style="color:red">*</span>');
				valid = 0;
			}
		}
		else{
			writediv("pseudonymebox", '<span style="color:red">*</span>');
			valid = 0;
		}
	}
	else{
		writediv("pseudonymebox", '<span style="color:red">*</span>');
		valid = 0;
	}
	return valid;
}

function verifPasse(passwordazerty) {
	var valid = 0;		  
	
	if (passwordazerty == "")
	{
		writediv("passwordbox", "<span style='color:red'>*</span>");
		valid = 0;
	}
	else
	{  
	  if (passwordazerty.length < 1)
	  {
		writediv("passwordbox", "<span style='color:red'>*</span>");
		valid = 0;
	  }
	  else
	  {
		//RatePassword(password);
		writediv("passwordbox", "<span style='color:green'>*</span>");
		valid = 1;
	  }
	}
	return valid;
}

function RatePassword(pwd) {
	var strength  = GetPasswordStrength(pwd);
	var strengthPercent = ConvertToPercent(strength);
	document.getElementById('strengthdisplay').innerHTML = GetPasswordStrengthText(strengthPercent);
	var bardisplayGood = document.getElementById('bardisplayGood');
	bardisplayGood.style.width = strengthPercent + "%";
	var bardisplayBad = document.getElementById('bardisplayBad');
	bardisplayBad.style.width = 100 - strengthPercent + "%";
}
	
function GetPasswordStrength(pwd) {
    // zero-length passwords cannot be rated
    if (pwd.length == 0) {
          return -1;
    }
    // passwords that are too short are zero-strong
    if (pwd.length < 6) {
          return 0;
    }
    var charsSpecial = "";
    var charsLowercase = "";
    var charsUppercase = "";
    var charsNumeric = "";
    var rating = 0;
    var bonus = 0;
    var i;
    
    // characters that follow each other in the alphabet are bad
    var charcode = pwd.charCodeAt(0); 
    for (i=1; i<pwd.length; i++) {
          var diff = pwd.charCodeAt(i) - charcode;
          charcode = pwd.charCodeAt(i);
          if (diff == 1 || diff == -1) {
                pwd = pwd.substring(0, i) + pwd.substring(i-1, i) + pwd.substring(i+1, pwd.length);
          }
    }
    
    // put password characters into the right buckets
    for (i=0; i<pwd.length; i++) {
          if (pwd.charCodeAt(i) >= 'a'.charCodeAt(0) && pwd.charCodeAt(i) <='z'.charCodeAt(0)) {
                charsLowercase += pwd.substring(i, i+1);
          } else if (pwd.charCodeAt(i) >= 'A'.charCodeAt(0) && pwd.charCodeAt(i) <='Z'.charCodeAt(0)) {
                charsUppercase += pwd.substring(i, i+1);
          } else if (pwd.charCodeAt(i) >= '0'.charCodeAt(0) && pwd.charCodeAt(i) <='9'.charCodeAt(0)) {
                charsNumeric += pwd.substring(i, i+1);
          } else {
                charsSpecial += pwd.substring(i, i+1);
          }
    }
                
    rating = GetDistribution(charsLowercase);
    rating += GetDistribution(charsUppercase);
    rating += GetDistribution(charsNumeric);
    rating += GetDistribution(charsSpecial);
    
    if (charsLowercase.length > 0) bonus++;
    if (charsUppercase.length > 0) bonus++;
    if (charsNumeric.length > 0) bonus++;
    if (charsSpecial.length > 0) bonus++;
    
    rating = rating * (1 + ((bonus-1) / 4));
    return rating;
}

function ConvertToPercent(strength) {
	return 6*strength;
}
	
function GetDistribution(str) {
	var distribution = 0;
	var uniques = "";
	var i;
	for (i=0; i < str.length; i++) {
		if (uniques.indexOf(str.substring(i, i+1)) == -1) {
			uniques += str.substring(i, i+1);
		}
	}
	return uniques.length + ((str.length - uniques.length) / 5);
}

function GetPasswordStrengthText(strength) {
	if (strength == 0) {
		return langue52;
	} else if (strength > 0 && strength < 20) {
		return langue53;
	} else if (strength >= 20 && strength < 40) {
		return langue54;
	} else if (strength >= 40 && strength < 60) {
		return langue55;
	} else if (strength >= 60 && strength < 80) {
		return langue56;
	} else if (strength >= 80) {
		return langue57;
	} else {
		return langue58;
	}

}


function verifConfirmPasse(passwordazerty,passwordazerty2){
	var valid = 0;
	
	if( passwordazerty != '' && passwordazerty2 != '' ){
		if( passwordazerty == passwordazerty2){
			valid = 1;
			writediv("confirmPassebox","<span style='color:green'>*</span>");
		}
		else{
			valid = 0;
			writediv("confirmPassebox","<span style='color:red'>*</span>");
		}
	}
	else{
		writediv("confirmPassebox","<span style='color:red'>*</span>");
	}
	return valid;
}

function verifCGU(cgu){
	var valid = 0;
	
	if( cgu.checked ){
		writediv("cgubox", "<font color=green>"+langue11+"</font>");
		valid=1;
		
	}
	else{
		writediv("cgubox", "<font color=red>"+langue13+"</font>");
		valid=0;
	}
	
	return valid;
}

function verifAgeMin(ageMin){
	var valid = 0;
	
	if( ageMin != '-1'){
		valid = 1;
		writediv("ageMinbox","<span style='color:green'>*</span>");	
	}
	else{
		valid = 0;
		writediv("ageMinbox","<span style='color:red'>*</span>");
	}
	
	return valid;
}

function verifAgeMax(ageMax){
	var valid = 0;
	
	if( ageMax != '-1'){
		valid = 1;
		writediv("ageMaxbox","<span style='color:green'>*</span>");	
	}
	else{
		valid = 0;
		writediv("ageMaxbox","<span style='color:red'>*</span>");
	}
	
	return valid;
}

function verifJeSuis(suis){
	var valid = 0;
	
	if( suis != '-1' ){
		valid = 1;
		writediv("jesuisbox","<span style='color:green'>*</span>");		
	}
	else{
		valid = 0;
		writediv("jesuisbox","<span style='color:red'>*</span>");
	}
	
	return valid;
}

function verifRecherche(recherche){
	var valid = 0;
	
	if( recherche != '-1' ){
		valid = 1;
		writediv("recherchebox","<span style='color:green'>*</span>");		
	}
	else{
		valid = 0;
		writediv("recherchebox","<span style='color:red'>*</span>");
	}
	
	return valid;
}

function verifNaissance(jour,mois,annee){
	var valid = 0;
	
	if( jour != '-1' && mois !='-1' && annee !='-1'){
		valid = 1;
		writediv("naissancebox","<span style='color:green'>*</span>");		
	}
	else{
		valid = 0;
		writediv("naissancebox","<span style='color:red'>*</span>");
	}
	
	return valid;
}


function verifMailValidation (form){
	if (verifMail(form.email.value) == 0)
		form.go.disabled = true;
	
}

function verifMail(mail)
{
	var valid = 0;
   
	if(mail != "")
	{
		if(validMail(mail) != true)
		{
			writediv("mailbox", "<span style='color:red'><b>"+mail+" :</b>"+langue14+"</span>");
			writediv("mailEtoileboxValidation", "<span style='color:red'>*</span>");
			
		}
		else if(texte = file("include/ajax/mail.php?mail=" + escape(mail) ))
		{   
			
			if(texte == '1')
			{   
				document.getElementById('email').value = '';
				writediv("mailbox", "<span style='color:red'>"+langue15+"</span>");
				writediv("mailEtoilebox", "<span style='color:red'>*</span>");
				writediv("mailEtoileboxValidation", "<span style='color:red'>*</span>"); 
				
				valid=0;
			}
			else
			{
				writediv("mailbox", "");
				writediv("mailEtoilebox", "<span style='color:green'>*</span>");
				writediv("mailEtoileboxValidation", "<span style='color:green'>*</span>");
				
				valid = 1;
				
			}		
		}	
	}
	else
	{
		writediv("mailbox", "<span style='color:red'>"+langue16+"</span>");
	}
	
	return valid;
}

function validMail(mail)
{
	var EmailValid = 0;
	var EmailAt = 0;
	var EmailPeriod = 0;
	var EmailControlEspace = 0;
	var EmailControlSlash = 0;
	var EmailControlDiese = 0;
	var EmailControlAntiSlash = 0;
	var valid = 0;
	
	for (i = 0;  i < mail.length;  i++)
	{
		var ch = mail.charAt(i);
		if ( ch == "@"){ EmailAt += parseInt(1); }
		if ( ch == "."){ EmailPeriod += parseInt(1); }
	}
	
	if( EmailAt == 1 &&  EmailPeriod >= 1 ){
		for (i = 0;  i < mail.length;  i++)
		{
			ch = mail.charAt(i);
			if ( ch == " "){ EmailControlEspace += parseInt(1); }
			if ( ch == "/"){ EmailControlSlash += parseInt(1);}
			if ( ch == "#"){ EmailControlDiese += parseInt(1);}
			if ( ch == "\\"){ EmailControlAntiSlash += parseInt(1); }
		}
		
		if( EmailControlEspace + EmailControlSlash + EmailControlDiese + EmailControlAntiSlash == 0 ){
			valid = 0;
		}
		else{
			valid = 1;
		}
	}
	else{
		valid = 1;
	}
	
	if(valid == 0 ){
		EmailValid = true;
	}
	else{
		EmailValid = false;
	}
	
	return EmailValid;
}

function verifEspace(texte)
{
	for( i=0;i<texte.length;i++ )
	{
		if( texte.charAt(i) == " " )
			return false;
		else
			valid = true;
	}
	return valid;
}

function verifAge(ageMin,ageMax)
{
	if( ageMax >= ageMin )
	{
		return 1;	
	}
	else
	{
		return 0;
	}
}

function verifForm(){
	var valid = 0;
	
	/*
	var regexp = new RegExp("^[_a-z0-9]{1,16}$","g"); 
	if(regexp.test(document.getElementById('pseudo').value) == false)
		alert("Le pseudo ne doit pas contenir les caract&egrave;res sp&eacute;ciaux :  @,?,! etc.");*/
	
	
	/*if( pays == '61' ||  pays == '285' ){
		cp = verifCodePostal(document.getElementById('regionResi').value);
	}*/
	var suis = verifJeSuis(document.getElementById('sexe').value);
	var recherche = verifRecherche(document.getElementById('recherche').value);
	var ageMin = verifAgeMin(document.getElementById('ageMin').value);
	var ageMax = verifAgeMax(document.getElementById('ageMax').value);
	var naissance = verifNaissance(document.getElementById('jour').value,document.getElementById('mois').value,document.getElementById('annee').value);
	
	var pseudonyme = verifPseudonyme(document.getElementById('pseudo').value);
	var passe = verifPasse(document.getElementById('passssse').value);
	var confirmPass = verifConfirmPasse(document.getElementById('passssse').value,document.getElementById('confirmPass').value);
	var pays = verifPays(document.getElementById('paysResi').value);
	var departement = verifDepartement(document.getElementById('regionResi').value);
	var ville = verifVille(document.getElementById('villeResi').value);
	var cgu = verifCGU(document.getElementById('majeur'));
	var age = verifAge(ageMin,ageMax);
	
	var email =  verifMail(document.getElementById('email').value) ; 
	
	
	
	valid = pays + passe + confirmPass + cgu + email + pseudonyme + departement + ville + suis + recherche + naissance + ageMin + ageMax + age;
	if (valid == 14) 
	{
		return true;
	}
	else
	{
		return false;
	}
}

function verifForm2(msg){
	if( verifJeSuis(document.getElementById('sexe').value) == 0 ){ alert(langue17); return false; }
	if( verifRecherche(document.getElementById('recherche').value) == 0 ){ alert(langue18);return false; }
	if( verifAgeMin(document.getElementById('ageMin').value) == 0 ){ alert(langue19);return false; }
	if( verifAgeMax(document.getElementById('ageMax').value) == 0 ){ alert(langue20);return false; }
	if( verifAge(document.getElementById('ageMin').value,document.getElementById('ageMax').value) == 0){ alert(langue61); return false; }
	if( verifNaissance(document.getElementById('jour').value,document.getElementById('mois').value,document.getElementById('annee').value) == 0 ){ alert(langue21);return false; }
	if( verifMail(document.getElementById('email').value) == 0 ){ alert(langue22);return false; }
	if( verifPseudonyme(document.getElementById('pseudo').value) == 0 ){ //alert(langue23);
		alert(msg);
		return false; 
	}
	if( verifPasse(document.getElementById('passssse').value) == 0 ){ alert(langue24);return false; }
	if( verifConfirmPasse(document.getElementById('passssse').value,document.getElementById('confirmPass').value) == 0 ){ alert(langue25);return false; }
	if( verifPays(document.getElementById('paysResi').value) == 0 ){ alert(langue26);return false; }
	if( verifDepartement(document.getElementById('regionResi').value) == 0 ){ alert(langue27);return false; }
	if( verifVille(document.getElementById('villeResi').value) == 0 ){ alert(langue28);return false; }
	if( verifCGU(document.getElementById('majeur')) == 0 ){ alert(langue29);return false; }
	
	return true;
}

function envoie_passe_perdu(courriel){
	if( courriel != '' ){
		rep = file('include/ajax/envoiePassePerdu.php?courriel='+courriel);
		writediv("passe2",rep);
	}
	else{
		return false;
	}
}

function effaceChampDestinataire(element){
	if( element.value == "Pseudo du destinataire"){
		element.value = '';
	}
}

function liste_regionResi_accueilConnecte(pays){
    if( pays == '-2' )
	{	
		document.getElementById('regionResi').disabled=true;
	}
	else
	{
		rep = file('include/pages/MOD_ACCUEIL_CONNECTE/ajax/liste_region_accueil_connecter.php?pays='+pays);
		writediv("liste_region", rep);
	}
}

function deselectionneMail(form){
	if(form) {
   		var total = parseInt(0);
		var totalCoche = parseInt(0);
		var champs = form.getElementsByTagName("input");
		for(var i=0, n=champs.length; i<n; i++) {
   			var nom = champs[i].getAttribute("id");
			if( nom ){
				if( nom.indexOf("email") == 0 && nom != "email_1"){
					if( !document.getElementById(nom).checked ){
						total = parseInt(total) + parseInt(1);
					}
					totalCoche = parseInt(totalCoche)+ parseInt(1);
				}
			}
   		}
		if( total == totalCoche){
			document.getElementById('email_1').checked = true;
		}
   	}
}

function deselectionneLigne(form){
	if(form) {
   		var total = parseInt(0);
		var totalCoche = parseInt(0);
		var champs = form.getElementsByTagName("input");
		for(var i=0, n=champs.length; i<n; i++) {
   			var nom = champs[i].getAttribute("id");
			if( nom ){
				if( nom.indexOf("ligne") == 0 && nom != "ligne_1"){
					if( !document.getElementById(nom).checked ){
						total = parseInt(total) + parseInt(1);
					}
					totalCoche = parseInt(totalCoche)+ parseInt(1);
				}
			}
   		}
		if( total == totalCoche){
			document.getElementById('ligne_1').checked = true;
		}
   	}
}

function selectionneMail(form){
	if(form) {
   		var champs = form.getElementsByTagName("input" );
		for(var i=0, n=champs.length; i<n; i++) {
   			var nom = champs[i].getAttribute("id");
			if( nom ){
				if( nom.indexOf("email") == 0 && nom != "email_1" ){
					if( document.getElementById(nom).checked ){
						document.getElementById(nom).checked = false;
					}
					else{
						document.getElementById(nom).checked = true;
					}
				}
			}
   		}
   	}
}

function selectionneLigne(form){
	if(form) {
   		var champs = form.getElementsByTagName("input" );
		for(var i=0, n=champs.length; i<n; i++) {
   			var nom = champs[i].getAttribute("id");
			if( nom){
				if( nom.indexOf("ligne") == 0 && nom != "ligne_1"){
					if( document.getElementById(nom).checked ){
						document.getElementById(nom).checked = false;
					}
					else{
						document.getElementById(nom).checked = true;
					}
				}
			}
   		}
   	}
}

function verifObjet(objet){
	if(objet == '' ){
		return confirm(langue31);
		alert('1');
	}
		alert('2');
	
}



//Retourne la cha”ne val sans ses espaces
function trim(val) {
	var retour = ""
	for(i=0;i < val.length;i++)
		if(val.charAt(i) != " ") {
			retour += val.charAt(i)
		}
	return retour
}


function  verifEcrireMessage(form){
	dest = form.destinataire.value;
	objet = form.objet.value;
	message = form.message.value;
	if( dest == '' ||  dest == langue59 ){
		alert(langue32);
		return false;
	}
	else if( trim(message) == "" ){
		alert(langue33);
		return false;
	}
	
	if( objet == '' ){
		return confirm(langue34);
	}
	
	return true;
	
}

function verifMontant(montant){
	if( montant!= '' && montant > 0 ){
		return true;
	}
	else{
		alert(langue35);
		return false;
	}
}

function verifFormContact(form){
	if( form.objet.value != '-1' ){
		if( form.message.value != '-1' ){
			return true;
		}
		else{
			alert(langue36);
			return false;
		}
	}
	else{
		alert(langue37);
		return false;
	}
		
}

function verifCaptcha(hncaptcha,hncaptcha_public_key,captcha,textefield) {
	
	var valid = 0; 
	texte = 0;

	 //alert("include/ajax/valid_captcha.php?hncaptcha=" + escape(hncaptcha) + "&hncaptcha_public_key=" + escape(hncaptcha_public_key) + "&hncaptcha_private_key=" + escape(captcha) + "&type=" + escape(box));
	 if( !textefield.disabled ){
		 if (captcha.length != 5)
		  {
			writediv("captchabox", " <span style='color:red'>"+langue38+"</span>");
			
		  }
		  else if(texte = file("include/ajax/valid_captcha.php?hncaptcha=" + escape(hncaptcha) + "&hncaptcha_public_key=" + escape(hncaptcha_public_key) + "&hncaptcha_private_key=" + escape(captcha)))
			{
				//alert("include/ajax/valid_captcha.php?hncaptcha_private_key=" + escape(captcha) + "&type=" + escape(box));
				if(texte == 1)
				{
				writediv("captchabox", "<span style='color:green'> "+langue11+"</span>");
				textefield.disabled = true;
				valid = 1;
				}
				else if(texte == 2)
				{
				essai = file("include/ajax/valid_captcha.php?essai=ask");
				reste = 5 - essai;
				writediv("captchabox", "<span style='color:red'>"+langue39 + reste + langue40+"</span>");
				
				var valid = 0;
				}
				else if(texte == 3)
				{
				writediv("captchabox", "<span style='color:red'>"+langue41+"</span>");
				var valid = 0;
				}
				else
				{
				writediv("captchabox", texte);
				var valid = 0;
				}
		  }
	 }
	 else{
		 valid = 1;
	 }
	
	 return valid;
}

function verifFormContactAccueil(form){
	if( form.nom.value != '' ){
		if( form.mail.value != '' ){
			if( verifMail2(form.mail.value) == 1 ){
				if( form.objet.value != '-1' ){
					if( form.message.value != '' ){
						if( verifCaptcha(form.hncaptcha.value,form.hncaptcha_public_key.value,form.hncaptcha_private_key.value,form.hncaptcha_private_key) == 1 ){
							return true;
						}
						else{
							alert(langue42);
							return false;
						}
					}
					else{
						alert(langue43);
						return false;
					}
				}
				else{
					alert(langue44);
					return false;
				}
			}
			else{
				alert(langue45);
				return false;
			}
		}
		else{
			alert(langue46);
			return false;
		}
	}
	else{
		alert(langue47);
		return false;
	}
		
}

function verifFormContactSite(form){
	if( form.mail.value != '' ){
		if( verifMail2(form.mail.value) == 1 ){
			if( form.objet.value != '-1' ){
				if( form.message.value != '' ){
					if( verifCaptcha(form.hncaptcha.value,form.hncaptcha_public_key.value,form.hncaptcha_private_key.value,form.hncaptcha_private_key) == 1 ){
						return true;
					}
					else{
						alert(langue42);
						return false;
					}
				}
				else{
					alert(langue43);
					return false;
				}
			}
			else{
				alert(langue44);
				return false;
			}
		}
		else{
			alert(langue45);
			return false;
		}
	}
	else{
		alert(langue46);
		return false;
	}
		
}

function verifMail2(mail)
{
	valid = 0;

	if(mail != "")
	{
		if(validMail(mail) != true)
		{
			valid= 0;
		}
		else{
			valid = 1;
		}
		/*else if(texte = file("include/ajax/mail.php?mail=" + escape(mail) ))
		{
			if(texte >= 1)
			{
				valid=0;
			}
			else
			{
				valid = 1;
			}
		}*/
			
	}
	
	return valid;
}

function afficheCache(e){  
    /*if( document.getElementById(e).style.display != 'none' ){
    	//new Effect.BlindUp(document.getElementById(e));
		//document.getElementById(e).style.display = 'none';
		document.getElementById(f).style.backgroundImage='url(/images/plus_fiche_finale.png)';
    }
    else{
		//new Effect.BlindDown(document.getElementById(e));
		//document.getElementById(e).style.display = 'block';
		document.getElementById(f).style.backgroundImage='url(/images/moins_fiche_finale.png)';
    }*/
	$("#"+e).slideToggle("slow");
}
