function status (msg ) {document.part1.erreur.value = msg;}

function remote_info( Obj ){document.getElementById('RemoteScripting').src = "load.php?champ=cp&cp="+Obj.value;}

function enregistre_inscription(  )
{
	document.part1.action = "inscription.php";
	document.part1.target="RemoteScripting";
	document.part1.submit();
}

function check()
{
	if ( ( document.part1.email.value != "" ) && ( document.part1.pseudo.value != "" ) )
	{
		document.getElementById('RemoteScripting').src = "load.php?champ=controle&email="+document.part1.email.value+"&pseudo="+document.part1.pseudo.value;
	}
	else
	{
		if ( document.part1.email.value == "" ) 
		{
			document.getElementById('legende').innerHTML = "Veuillez renseigner le champ <B><font color='red'>Email</font></B> avant de 'Passer à la suite', Merci.";
			alert("Veuillez renseigner le champ Email avant de 'Passer à la suite', Merci.");
		}
		else
		{
			document.getElementById('legende').innerHTML = "Veuillez renseigner le champ <B><font color='red'>Pseudo</font></B> avant de 'Passer à la suite', Merci.";
			alert("Veuillez renseigner le champ Pseudo avant de 'Passer à la suite', Merci.");
		}
		return false;
	}
}

function enregistre()
{
	if ( nameOK( document.part1 ) ) 
	{ 
		enregistre_inscription();
	}	
}

function TraiteRemote( champ, valeur )
{
	if ( champ=='cp' ) populate_list ( "document.part1.ville" , valeur );
	if ( champ=='controle' )
	{
		var erreur = false;	var s = new String(valeur); var a = s.split(";");
		s = new String(a[0]);
		aa = s.split("|");
		if ( aa[1] != "" ) 
		{ 
			document.getElementById('legende').innerHTML = "<font color='red'>"+aa[1]+"</font>"; 
			alert(aa[1]);
			document.part1.record.value="Passez à la suite...";
			return;
		}

		s = new String(a[1]);
		aa = s.split("|");
		if ( aa[1] != "" ) 
		{ 
			document.getElementById('legende').innerHTML = "<font color='red'>"+aa[1]+"</font>"; 
			alert(aa[1]);
			document.part1.record.value="Passez à la suite...";
			return; 
		}

		if ( nameOK( document.part1 ) ) 
		{ 
			enregistre(); 
		}
	}

	if ( champ=='inscription' )
	{
		if ( valeur=="-1" )
		{
			document.getElementById('legende').innerHTML = "Erreur lors de l'enregistrement de votre Inscription.";
		}
		else
		{
			this.location = "inscription_terminee.php";
		}
	}

}
function populate_list(ctrl_name, liste)
{
	ctrl= eval(ctrl_name);
	if (ctrl.type != "select-one") { alert ("'"+ctrl_name + "' is not a valid <SELECT...> control\nfunction : populate_list()\nFélix");	return; }
	//initialisation 
	for (i=ctrl.length; i>= 0;i--) { ctrl.options[i]=null;}
	var i;
	var s = new String(liste);
	var a = s.split(";");
	if (a == "") len = 0;
	else len = a.length;
	
	for(i=0; i < len - 1 ; i++)
	{
		s = new String(a[i]);
		aa = s.split("|");
		if (aa.length > 1)
		{
			if (aa[1] == "") ctrl.options[i]= new Option (aa[0],aa[0]);
			else ctrl.options[i]= new Option (aa[1],aa[0]);
		}
		else
		{
			ctrl.options[i]= new Option (aa[0],aa[0]);
		}
	}
}

function init_pays()
{
	for (i=0 ; i< document.part1.pays.length ; i++) 
	{
		if (document.part1.pays.options[i].value == "France" )
			document.part1.pays.selectedIndex=i;
	}
}

function update_pays()
{

	if ( document.part1.pays.options[document.part1.pays.selectedIndex].value != "France" )
	{
		// Désactiver CP et Ville
		document.part1.cp.value= "";
		document.part1.cp.disabled = true;
		document.part1.ville.disabled = true;
	}
	else
	{
		document.part1.cp.disabled = false;
		document.part1.ville.disabled = false;
	}
}

function adapte_sexe( Obj )
{
	if ( Obj.value <= 3 )
	{
		affiche_f( false );
		affiche_h( true );
	}
	else if ( ( Obj.value > 3 ) && ( Obj.value < 7 ) )
	{
		affiche_f( true );
		affiche_h( false );
	}
	else
	{
		affiche_f( true );
		affiche_h( true );
	}
}

function affiche_h( val )
{
	if ( val == true )
	{
		document.getElementById('ageh').style.display = "inline";	
		document.getElementById('cheveuxh').style.display = "inline";	
		document.getElementById('tailleh').style.display = "inline";	
		document.getElementById('poidh').style.display = "inline";	
		document.getElementById('signeh').style.display = "inline";	
		document.getElementById('fumeurh').style.display = "inline";	
	}
	else
	{
		document.getElementById('ageh').style.display = "none";	
		document.getElementById('cheveuxh').style.display = "none";	
		document.getElementById('tailleh').style.display = "none";	
		document.getElementById('poidh').style.display = "none";	
		document.getElementById('signeh').style.display = "none";	
		document.getElementById('fumeurh').style.display = "none";	
	}
}

function affiche_f( val )
{
	if ( val == true )
	{
		document.getElementById('agef').style.display = "inline";	
		document.getElementById('cheveuxf').style.display = "inline";	
		document.getElementById('taillef').style.display = "inline";	
		document.getElementById('poidf').style.display = "inline";	
		document.getElementById('signef').style.display = "inline";	
		document.getElementById('fumeurf').style.display = "inline";	
	}
	else
	{
		document.getElementById('agef').style.display = "none";	
		document.getElementById('cheveuxf').style.display = "none";	
		document.getElementById('taillef').style.display = "none";	
		document.getElementById('poidf').style.display = "none";	
		document.getElementById('signef').style.display = "none";	
		document.getElementById('fumeurf').style.display = "none";	
	}
}

function lespays ( val )
{
document.write("<select name=\"pays\" size=\"1\" style=\"width: 100%;\" class=\"form_bloc\" onFocus='document.getElementById(\"legende\").innerHTML=\"Donnez votre Pays ( Information publique)\";'><option value='' selected>\</option><option value='Afghanistan'>Afghanistan</option><option value='Albania'>Albania</option><option value='Algeria'>Algeria</option><option value='American Samoa'>American Samoa</option><option value='Angola'>Angola</option><option value='Anguilla'>Anguilla</option><option value='Antartica'>Antartica</option><option value='Antigua'>Antigua</option><option value='Argentina'>Argentina</option><option value='Armenia'>Armenia</option><option value='Aruba'>Aruba</option><option value='Ascension Island'>Ascension Island</option><option value='Australia'>Australia</option><option value='Austria'>Austria</option><option value='Bahamas'>Bahamas</option><option value='Bahrain'>Bahrain</option><option value='Bangladesh'>Bangladesh</option><option value='Barbados'>Barbados</option><option value='Barkinoa Faso'>Barkinoa Faso</option><option value='Belarus'>Belarus</option><option value='Belgium'>Belgium</option><option value='Belize'>Belize</option><option value='Benin'>Benin</option><option value='Bermuda'>Bermuda</option><option value='Bhutan'>Bhutan</option><option value='Bolivia'>Bolivia</option><option value='Bosnia-Herzegovina'>Bosnia-Herzegovina</option><option value='Botswana'>Botswana</option><option value='Brazil'>Brazil</option><option value='British Virgin Islands'>British Virgin Islands</option><option value='Brunei'>Brunei</option><option value='Bulgaria'>Bulgaria</option><option value='Burundi'>Burundi</option><option value='Camaroon'>Camaroon</option><option value='Cambodia'>Cambodia</option><option value='Canada'>Canada</option><option value='Canada'>Canada</option><option value='Cape Verde Islands'>Cape Verde Islands</option><option value='Cayman Islands'>Cayman Islands</option><option value='Central African Rep.'>Central African Rep.</option><option value='Chad Republic'>Chad Republic</option><option value='Chile'>Chile</option><option value='China'>China</option><option value='Colombia'>Colombia</option><option value='Comoros'>Comoros</option><option value='Congo'>Congo</option><option value='Cook Islands'>Cook Islands</option><option value='Costa Rica'>Costa Rica</option><option value='Croatia'>Croatia</option><option value='Cyprus'>Cyprus</option><option value='Czech Republic'>Czech Republic</option><option value='Denmark'>Denmark</option><option value='Diego Garcia'>Diego Garcia</option><option value='Djibouti'>Djibouti</option><option value='Dominica'>Dominica</option><option value='Dominican Republic'>Dominican Republic</option><option value='Ecuador'>Ecuador</option><option value='Egypt'>Egypt</option><option value='El Salvador'>El Salvador</option><option value='Eqitorial Guinea'>Eqitorial Guinea</option><option value='Eritrea'>Eritrea</option><option value='Estonia'>Estonia</option><option value='Ethiopia'>Ethiopia</option><option value='Faeroe Islands'>Faeroe Islands</option><option value='Falkland Islands'>Falkland Islands</option><option value='Fiji Islands'>Fiji Islands</option><option value='Finland'>Finland</option><option  value='France'>France</option><option value='French Antilles'>French Antilles</option><option value='French Guiana'>French Guiana</option><option value='French Polynesia'>French Polynesia</option><option value='Gabon'>Gabon</option><option value='Gambia'>Gambia</option><option value='Georgia'>Georgia</option><option value='Germany'>Germany</option><option value='Ghana'>Ghana</option><option value='Gibralter'>Gibralter</option><option value='Greece'>Greece</option><option value='Greenland'>Greenland</option><option value='Grenada'>Grenada</option><option value='Guadeloupe'>Guadeloupe</option><option value='Guam'>Guam</option><option value='Guantanemo Bay'>Guantanemo Bay</option><option value='Guatemala'>Guatemala</option><option value='Guinea'>Guinea</option><option value='Guinea Bissau'>Guinea Bissau</option><option value='Guyana'>Guyana</option><option value='Haiti'>Haiti</option><option value='Honduras'>Honduras</option><option value='Hong Kong'>Hong Kong</option><option value='Hungary'>Hungary</option><option value='Iceland'>Iceland</option><option value='India'>India</option><option value='Indonesia'>Indonesia</option><option value='Iran'>Iran</option><option value='Iraq'>Iraq</option><option value='Ireland'>Ireland</option><option value='Isreal'>Isreal</option><option value='Italy'>Italy</option><option value='Ivory Coast'>Ivory Coast</option><option value='Jamaica'>Jamaica</option><option value='Japan'>Japan</option><option value='Jordan'>Jordan</option><option value='Kazakhstan'>Kazakhstan</option><option value='Kenya'>Kenya</option><option value='Kiribati'>Kiribati</option><option value='Korea (North)'>Korea (North)</option><option value='Korea (South)'>Korea (South)</option><option value='Kuwait'>Kuwait</option><option value='Kyrgyzstan'>Kyrgyzstan</option><option value='Laos'>Laos</option><option value='Latvia'>Latvia</option><option value='Lebanon'>Lebanon</option><option value='Lesotho'>Lesotho</option><option value='Liberia'>Liberia</option><option value='Libya'>Libya</option><option value='Lithuania'>Lithuania</option><option value='Luxembourg'>Luxembourg</option><option value='Macao'>Macao</option><option value='Macedonia'>Macedonia</option><option value='Madagascar'>Madagascar</option><option value='Malawi'>Malawi</option><option value='Malaysia'>Malaysia</option><option value='Maldives'>Maldives</option><option value='Mali Republic'>Mali Republic</option><option value='Malta'>Malta</option><option value='Marshall Islands'>Marshall Islands</option><option value='Mauritania'>Mauritania</option><option value='Mauritius'>Mauritius</option><option value='Mexico'>Mexico</option><option value='Micronesia'>Micronesia</option><option value='Moldiva (CIS)'>Moldiva (CIS)</option><option value='Mongolia'>Mongolia</option><option value='Montserrat'>Montserrat</option><option value='Morocco'>Morocco</option><option value='Mozambique'>Mozambique</option><option value='Namibia'>Namibia</option><option value='Nauru'>Nauru</option><option value='Nepal'>Nepal</option><option value='Netherland Antilles'>Netherland Antilles</option><option value='Netherlands'>Netherlands</option><option value='Nevis'>Nevis</option><option value='New Calidonia'>New Calidonia</option><option value='New Zealand'>New Zealand</option><option value='Nicaragua'>Nicaragua</option><option value='Niger'>Niger</option><option value='Nigeria'>Nigeria</option><option value='Niue Island'>Niue Island</option><option value='Norfork Island'>Norfork Island</option><option value='Norway'>Norway</option><option value='Oman'>Oman</option><option value='Pakistan'>Pakistan</option><option value='Palau'>Palau</option><option value='Panama'>Panama</option><option value='Papua New Guinia'>Papua New Guinia</option><option value='Paraguay'>Paraguay</option><option value='Peru'>Peru</option><option value='Philipines'>Philipines</option><option value='Poland'>Poland</option><option value='Portugal'>Portugal</option><option value='Puerto Rico'>Puerto Rico</option><option value='Qatar'>Qatar</option><option value='Reunion Island'>Reunion Island</option><option value='Romania'>Romania</option><option value='Russia'>Russia</option><option value='Rwanda'>Rwanda</option><option value='Saipan'>Saipan</option><option value='Sao Tome'>Sao Tome</option><option value='Saudi Arabia'>Saudi Arabia</option><option value='Senegal Republic'>Senegal Republic</option><option value='Seychelles Island'>Seychelles Island</option><option value='Sierrra Leone'>Sierrra Leone</option><option value='Singapore'>Singapore</option><option value='Slovenia'>Slovenia</option><option value='Soloman Island'>Soloman Island</option><option value='Somalia'>Somalia</option><option value='South Africa'>South Africa</option><option value='Spain'>Spain</option><option value='Sri Lanka'>Sri Lanka</option><option value='St Helen'>St Helen</option><option value='St Kitts'>St Kitts</option><option value='St Lucia'>St Lucia</option><option value='St Pierre'>St Pierre</option><option value='St Vincent'>St Vincent</option><option value='Sudan'>Sudan</option><option value='Suriname'>Suriname</option><option value='Swaziland'>Swaziland</option><option value='Sweden'>Sweden</option><option value='Switzerland'>Switzerland</option><option value='Syria'>Syria</option><option value='Taiwan'>Taiwan</option><option value='Tanzania'>Tanzania</option><option value='Thailand'>Thailand</option><option value='Togo'>Togo</option><option value='Tonga'>Tonga</option><option value='Trinidad &amp'>Trinidad &amp</option><option value='Tunisia'>Tunisia</option><option value='Turkey'>Turkey</option><option value='Turks/Caicos'>Turks/Caicos</option><option value='Tuvalu'>Tuvalu</option><option value='Uganda'>Uganda</option><option value='Ukraine'>Ukraine</option><option value='United Arab Emirates'>United Arab Emirates</option><option value='United Kingdom'>United Kingdom</option><option value='Uruguay'>Uruguay</option><option value='USA'>USA</option><option value='Vanuatu'>Vanuatu</option><option value='Venezuela'>Venezuela</option><option value='Viet Nam'>Viet Nam</option><option value='Wallis / Futuna'>Wallis / Futuna</option><option value='West Samoa'>West Samoa</option><option value='Yemen Republic'>Yemen Republic</option><option value='Yugoslavia'>Yugoslavia</option><option value='Zaire'>Zaire</option><option value='Zambia'>Zambia</option><option value='zerbaijan'>zerbaijan</option><option value='Zimbabwe'>Zimbabwe</option></select>");
	
	if ( val == "")
		return;
		
	update( val, "p");

}

function urldecode(ch) 
{
   ch = ch.replace(/[+]/g," ")
   return unescape(ch)
}

// --------------------------------------------------------
// Contrôle de l'&eacute;tape 1 ( pseudo, ville, dpt, pays )
// --------------------------------------------------------
function nameOK(f)
{
	// Sexe
	if( document.part1.sexepseudo.selectedIndex == 0)
    {
		document.getElementById('legende').innerHTML = "Veuillez renseigner le champ <B><font color='red'>SEXE</font></B> avant de 'Passer à la suite', Merci.";
		alert("Veuillez renseigner le champ SEXE avant de 'Passer à la suite', Merci.");
        return false;
    }

	if( document.part1.mobilite.selectedIndex == 0)
    {
		document.getElementById('legende').innerHTML = "Veuillez péciser votre <B><font color='red'>Mobilité</font></B> avant de 'Passer à la suite', Merci.";
		alert("Veuillez péciser votre Mobilité avant de 'Passer à la suite', Merci.");
        return false;
    } 

	// Pays
	if ( document.part1.pays.selectedIndex == 0 ) 
    {
		document.getElementById('legende').innerHTML = "Veuillez péciser votre <B><font color='red'>Pays</font></B> avant de 'Passer à la suite', Merci.";
		alert("Veuillez péciser votre Pays avant de 'Passer à la suite', Merci.");
        return false;
    } 

	if( ( document.part1.pays.value.indexOf('France', 0) != -1)  && (document.part1.cp.value.length == 0) )
    {
		document.getElementById('legende').innerHTML = "Veuillez péciser votre <B><font color='red'>Code Postal</font></B> avant de 'Passer à la suite', Merci.";
		alert("Veuillez péciser votre Code Postal avant de 'Passer à la suite', Merci.");
        return false;
    } 

	var pseudo1,index1,index2,index3,index4,index5,index6,index7,index8,index9,index10,index11,index12;
	
	pseudo1 = document.part1.pseudo.value;
	index1 = pseudo1.indexOf(" ");
	index2 = pseudo1.indexOf("/");
	index3 = pseudo1.indexOf(":");
	index4 = pseudo1.indexOf("?");
	index5 = pseudo1.indexOf('\"');
	index6 = pseudo1.indexOf("<");
	index7 = pseudo1.indexOf(">");
	index8 = pseudo1.indexOf("|");
	index9 = pseudo1.indexOf("\\");
	index10 = pseudo1.indexOf("");
	index11 = pseudo1.indexOf("@");
	index12 = pseudo1.indexOf("\'");
	
	if ( (index12!= -1) || (index11!= -1) || (index9!= -1) || (index5!= -1) ||(index1!= -1) ||(index2!= -1) ||(index3!= -1) ||(index4!= -1) || (index6!= -1) ||(index7!= -1) ||(index8!= -1)  )
	{
		alert ("Attention! Les caractères suivants et les espaces sont interdits dans le pseudo \n \" \\ / : * ? < > | @ \'");
		return false;
	}	
	
	if ( !controle_sexe() )
		return false;
	
	// Taille de l'annonce
	if ( document.part1.message.value.length < 25 ) 
	{
		alert ("Veuillez renseigner le champs annonce (25 caractères minimum)");
		return false;
	}	
	
   return VerifMail_inscription();
}

function VerifMail_inscription(){
	var length = document.part1.email.value.length;
	var mail = document.part1.email.value;
	var test = false;
	var nbArob = 0;
	for(var i=0;i<length;i++){
		if (mail.charAt(i)=='@'){
			nbArob += 1;
			test=true;
		}
	}
	if ((test==false) || (nbArob>1)){
		alert("L'adresse Email n'est pas valide!");
		return false;
		}
	var tab = new Array();
	tab = mail.split("@");
	var placeArob = tab[1].lastIndexOf(".");
	var reste = (tab[1].length - (placeArob + 1));
	if ((placeArob == -1) || (reste>3) || (tab[0]<1)){
		alert("L'adresse Email n'est pas valide!");
		return false;
	}
	
	return true;	
}

// --------------------------------------------------------
// Contrôle de l'&eacute;tape 2 ( sexe, etc.... )
// --------------------------------------------------------
function controle_sexe()
{
	sexe = document.part1.sexepseudo.value;
	var f = document.part1;
	if ( sexe <= 3 )
	{
		if ( !verif_sexe('h') )
		  	return false;
	}
	else if ( ( sexe >= 4 ) && ( sexe <= 6 )  )
	{
		if ( !verif_sexe('f') )
		  	return false;
	}
	else if ( sexe >= 7 )
	{
		if ( verif_sexe('h') )
		{
			if ( verif_sexe('f') )
			 {
			 }
			 else
			 {
			 	return false;
			 }
		} 
		else
		{
			return false;
		}
	}
	
   	var compteur=0;
   	for (var i=0;i<f['cible'].length;i++)
	{
			var e = f['cible'][i];
			if (e.checked)
			{
				if ( f['cible'][i].value == 11) { document.part1.recherchec.value = 1;}
				if ( f['cible'][i].value == 12) { document.part1.recherchecfb.value = 1;}
				if ( f['cible'][i].value == 13) { document.part1.recherchechb.value = 1;}
				if ( f['cible'][i].value == 14) { document.part1.recherchec2b.value = 1;}
				if ( f['cible'][i].value == 15) { document.part1.recherchef.value = 1;}
				if ( f['cible'][i].value == 16) { document.part1.recherchefb.value = 1;}
				if ( f['cible'][i].value == 17) { document.part1.recherchefg.value = 1;}
				if ( f['cible'][i].value == 18) { document.part1.rechercheh.value = 1;}
				if ( f['cible'][i].value == 19) { document.part1.recherchehb.value = 1;}
				if ( f['cible'][i].value == 20) { document.part1.recherchehg.value = 1;}
				compteur++;
			}
			else
			{
				if ( f['cible'][i].value == 11) { document.part1.recherchec.value = 0;}
				if ( f['cible'][i].value == 12) { document.part1.recherchecfb.value = 0;}
				if ( f['cible'][i].value == 13) { document.part1.recherchechb.value = 0;}
				if ( f['cible'][i].value == 14) { document.part1.recherchec2b.value = 0;}
				if ( f['cible'][i].value == 15) { document.part1.recherchef.value = 0;}
				if ( f['cible'][i].value == 16) { document.part1.recherchefb.value = 0;}
				if ( f['cible'][i].value == 17) { document.part1.recherchefg.value = 0;}
				if ( f['cible'][i].value == 18) { document.part1.rechercheh.value = 0;}
				if ( f['cible'][i].value == 19) { document.part1.recherchehb.value = 0;}
				if ( f['cible'][i].value == 20) { document.part1.recherchehg.value = 0;}
			}
	}

	if (compteur == 0)
	{
		document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>vos type de recherche</font></B> avant de 'Passer à la suite', Merci.";
		alert ("Veuillez péciser vos type de recherche avant de 'Passer à la suite', Merci.");
    	return(false);
	} 

   	return true;
}

function verif_sexe(sexe)
{

	if ( sexe=='f')
	{
		// Age Femme
		if ((document.part1.agef.value.length == 0))
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>l'age de Madame</font></B> avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser l'age de Madame avant de 'Passer à la suite', Merci.");
	        return false;
		}

		if ( !isInteger(document.part1.agef.value) )
	    {
			document.getElementById('legende').innerHTML = "<B><font color='red'>ATTENTION : l'age de Madame</font></B> est incorrect.";
			alert ("ATTENTION : l'age de Madame est incorrect.");
	        return false;
		}

		// Taille Femme
		if ((document.part1.taillef.value.length == 0))
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>la taille de Madame</font></B> avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser la taille de Madame avant de 'Passer à la suite', Merci");
	        return false;
		}
		if ( !isInteger(document.part1.taillef.value) )
	    {
			document.getElementById('legende').innerHTML = "<B><font color='red'>ATTENTION : La taille de Madame</font></B> est incorrect.";
			alert ("ATTENTION, la taille de Madame est incorrecte");
	        return false;
		}

		// Poid Femme
		if ((document.part1.poidf.value.length == 0))
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>le poid de Madame</font></B> (en Kg) avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser le poid de Madame avant de 'Passer à la suite', Merci");
	        return false;
		}

		if ( !isInteger(document.part1.poidf.value) )
	    {
			document.getElementById('legende').innerHTML = "<B><font color='red'>ATTENTION : le poid de Madame</font></B> est incorrect.";
			alert ("ATTENTION, le poid de Madame est incorrecte");
	        return false;
		}

		// Cheveux Femme
		if( document.part1.cheveuxf.selectedIndex == 0)
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>la couleur de cheveux de Madame</font></B> (en Kg) avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser la couleur de cheveux de Madame avant de 'Passer à la suite', Merci");
	        return false;
	    }

		// Signe Femme
		if( document.part1.signef.selectedIndex == 0)
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>le signe astrologique de Madame</font></B> (en Kg) avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser le signe astrologique de Madame avant de 'Passer à la suite', Merci");
	        return false;
	    }

		// Fumeur Femme
		if( document.part1.fumeurf.selectedIndex == 0)
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser si <B><font color='red'>Madame Fumme</font></B> (en Kg) avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser si Madame Fumme avant de 'Passer à la suite', Merci");
	        return false;
	    }
	
		return true
	}
	else if ( sexe=='h')
	{
		// Age Homme
		if ((document.part1.ageh.value.length == 0))
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>l'age de Monsieur</font></B> avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser l'age de Monsieur avant de 'Passer à la suite', Merci.");
	        return false;
		}

		if ( !isInteger(document.part1.ageh.value) )
	    {
			document.getElementById('legende').innerHTML = "<B><font color='red'>ATTENTION : l'age de Monsieur</font></B> est incorrect.";
			alert ("ATTENTION, l'age de Monsieur est incorrect.");
	        return false;
		}
		
		// Taille homme
		if ((document.part1.tailleh.value.length == 0))
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>la taille de Monsieur</font></B> avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser la taille de Monsieur avant de 'Passer à la suite', Merci.");
	        return false;
		}

		if ( !isInteger(document.part1.tailleh.value) )
	    {
			document.getElementById('legende').innerHTML = "<B><font color='red'>ATTENTION : La taille de Monsieur</font></B> est incorrect.";
			alert ("ATTENTION, la taille de Monsieur est incorrect.");
	        return false;
		}

		// Poid Homme
		if ((document.part1.poidh.value.length == 0))
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>le poid de Monsieur</font></B> avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser le poid de Monsieur avant de 'Passer à la suite', Merci.");
	        return false;
		}

		if ( !isInteger(document.part1.poidh.value) )
	    {
			document.getElementById('legende').innerHTML = "<B><font color='red'>ATTENTION : Le poid de Monsieur</font></B> est incorrect.";
			alert ("ATTENTION, le poid de Monsieur est incorrect.");
	        return false;
		}

		// Cheveux Homme
		if( document.part1.cheveuxh.selectedIndex == 0)
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>la couleur de cheveux de Monsieur</font></B> avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser la couleur de cheveux de Monsieur avant de 'Passer à la suite', Merci.");
	        return false;
	    }

		// Signe Homme
		if( document.part1.signeh.selectedIndex == 0)
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>le signe astrologique de Monsieur</font></B> avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser le signe astrologique de Monsieur avant de 'Passer à la suite', Merci.");
	        return false;
	    }

		// Fumeur Homme
		if( document.part1.fumeurh.selectedIndex == 0)
	    {
			document.getElementById('legende').innerHTML = "Veuillez péciser <B><font color='red'>Monsieur fume</font></B> avant de 'Passer à la suite', Merci.";
			alert ("Veuillez péciser si Monsieur fume avant de 'Passer à la suite', Merci.");
	        return false;
	    }
	
		return true
	
	}
	
}

function ctrl_annonce(Target) 
{
	// cette fonction calcule et affiche le nombre de caracteres saisi pour le champ annonce
	StrLen = Target.value.length
	if (StrLen > 600 )
	{
		Target.value = Target.value.substring(0,600);
		CharsLeft = 600;
	}
	else 
	{
		CharsLeft = StrLen;
	}
	document.part1.caracteres3.value = CharsLeft;
}

function isInteger(inputVal) 
{
   inputStr = inputVal.toString()
   for (var i = 0; i < inputStr.length; i++) {
      var oneChar = inputStr.charAt(i);
      if (i == 0 && oneChar == "-") {
         continue;
      }
      if (oneChar < "0" || oneChar > "9") {
         return false;
      }
   }
   return true;
}


// Startup variables
var imageTag = false;
var theSelection = false;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

// Helpline messages
b_help = "Texte gras: [b]texte[/b] (alt+b)";
i_help = "Texte italique: [i]texte[/i] (alt+i)";
u_help = "Texte souligné: [u]texte[/u] (alt+u)";
q_help = "Citation: [quote]texte cité[/quote] (alt+q)";
c_help = "Afficher du code: [code]code[/code] (alt+c)";
l_help = "Liste: [list]texte[/list] (alt+l)";
o_help = "Liste ordonnée: [list=]texte[/list] (alt+o)";
p_help = "Insérer une image: [img]http://image_url/[/img] (alt+p)";
w_help = "Insérer un lien: [url]http://url/[/url] ou [url=http://url/]Nom[/url] (alt+w)";
a_help = "Fermer toutes les balises BBCode ouvertes";
s_help = "Couleur du texte: [color=red]texte[/color] Astuce: #FF0000 fonctionne aussi";
f_help = "Taille du texte: [size=x-small]texte en petit[/size]";

// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list:u]','[list=]','[/list]','[img]','[/img]','[url]','[/url]');
imageTag = false;

// Shows the help messages in the helpline window
function helpline(help) {
	document.part1.helpbox.value = eval(help + "_help");
}


// Replacement for arrayname.length property
function getarraysize(thearray) {
	for (i = 0; i < thearray.length; i++) {
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
			return i;
		}
	return thearray.length;
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
	thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
	thearraysize = getarraysize(thearray);
	retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}


function checkForm() {

	formErrors = false;    

	if (document.part1.message.value.length < 2) {
		formErrors = "Vous devez entrer un message avant de poster";
	}

	if (formErrors) {
		alert(formErrors);
		return false;
	} else {
		bbstyle(-1);
		//formObj.preview.disabled = true;
		//formObj.submit.disabled = true;
		return true;
	}
}

function emoticon(text) {
	var txtarea = document.part1.message;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function bbfontstyle(bbopen, bbclose) {
	var txtarea = document.part1.message;

	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (!theSelection) {
			txtarea.value += bbopen + bbclose;
			txtarea.focus();
			return;
		}
		document.selection.createRange().text = bbopen + theSelection + bbclose;
		txtarea.focus();
		return;
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbopen, bbclose);
		return;
	}
	else
	{
		txtarea.value += bbopen + bbclose;
		txtarea.focus();
	}
	storeCaret(txtarea);
}


function bbstyle(bbnumber) {
	var txtarea = document.part1.message;

	txtarea.focus();
	donotinsert = false;
	theSelection = false;
	bblast = 0;

	if (bbnumber == -1) { // Close all open tags & default button names
		while (bbcode[0]) {
			butnumber = arraypop(bbcode) - 1;
			txtarea.value += bbtags[butnumber + 1];
			buttext = eval('document.part1.addbbcode' + butnumber + '.value');
			eval('document.part1.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
		}
		imageTag = false; // All tags are closed including image tags :D
		txtarea.focus();
		return;
	}

	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text; // Get text selection
		if (theSelection) {
			// Add tags around selection
			document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
			txtarea.focus();
			theSelection = '';
			return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
		return;
	}
	
	// Find last occurance of an open tag the same as the one just clicked
	for (i = 0; i < bbcode.length; i++) {
		if (bbcode[i] == bbnumber+1) {
			bblast = i;
			donotinsert = true;
		}
	}

	if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
		while (bbcode[bblast]) {
				butnumber = arraypop(bbcode) - 1;
				txtarea.value += bbtags[butnumber + 1];
				buttext = eval('document.part1.addbbcode' + butnumber + '.value');
				eval('document.part1.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
				imageTag = false;
			}
			txtarea.focus();
			return;
	} else { // Open tags
	
		if (imageTag && (bbnumber != 14)) {		// Close image tag before adding another
			txtarea.value += bbtags[15];
			lastValue = arraypop(bbcode) - 1;	// Remove the close image tag from the list
			document.part1.addbbcode14.value = "Img";	// Return button back to normal state
			imageTag = false;
		}
		
		// Open tag
		txtarea.value += bbtags[bbnumber];
		if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
		arraypush(bbcode,bbnumber+1);
		eval('document.part1.addbbcode'+bbnumber+'.value += "*"');
		txtarea.focus();
		return;
	}
	storeCaret(txtarea);
}

// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2) 
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}

// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

