/****************************************/
function verifFormRecherche()
{
	if (document.formRecherche.recherche.value=="")
	{
		alert("Specify a key word.");
		document.formRecherche.recherche.focus();
		return false;
	}
}
/****************************************/


/****************************************/
function verifFormRecherche2()
{
	if (document.formRecherche2.recherche.value=="")
	{
		alert("Specify a key word.");
		document.formRecherche2.recherche.focus();
		return false;
	}
}
/****************************************/



/****************************************/
function verifFormulaire()
{
Valider=true;
Valider=verifMail(newsletter.email,"Your e-mail address is not correct",Valider);	
return Valider;	
}
/****************************************/


/****************************************/
function verifMail(champ,message,Valider)
{
PasEncoreErreur=Valider;

	if (PasEncoreErreur) 
		{
		mail = champ.value;
		listemail=new Array;
		
		if(mail=="" || mail=="null" || mail.indexOf('@')==-1 || mail.indexOf(' ')>=0 )
			{
			alert(message);
			champ.select ();
			champ.focus ();
			PasEncoreErreur = false;
			}
		else
			{
			listemail=mail.split('@');

			if( (listemail[1].indexOf('.') <2) || (listemail[1].length<=listemail[1].indexOf('.')+2 ) || (listemail[0].length<1))
				{
				alert(message);
				champ.select ();
				champ.focus ();
				PasEncoreErreur = false;
				}
			} 		
		}
		if ( (!(/^[0-9A-Za-z.@\-_]+$/.test(champ.value))) && (PasEncoreErreur) )
			{alert('Your e-mail address is not correct, it includes special characters');
			PasEncoreErreur = false;}
return PasEncoreErreur;
}
/****************************************/


/****************************************/
function verifChampText(champ, message)
{
	retour=true;
	if (champ.value=="")
	{
		alert(message);
		champ.focus();
		retour=false;
	}
	return retour;
}
/****************************************/


/****************************************/
function verifFormInscription()
{
Valider=true;
Valider=verifMail(formInscription.email,"Your e-mail address is not correct",Valider);	
if (Valider==true)
	Valider=verifChampText(document.formInscription.password, "Your password is not correct");
if (Valider==true)
	Valider=verifChampText(document.formInscription.password2, "The confirmation of your password is not correct");
if ((Valider==true) && (document.formInscription.password.value != document.formInscription.password2.value))
	{
	alert("Your password and the confirmation are not the same");
	Valider=false;
	}
if ((Valider==true))
	{ 
	titreCoche=false;
	for (i=0;i<document.formInscription.titre.length ;i++ )
	{
		if ((document.formInscription.titre[i].checked==true)&&(titreCoche==false))
			titreCoche=true;
	}

	if (titreCoche==false)
		{	
			alert("Your civility is not indicated ");
			Valider=false;
		}
	}
if (Valider==true)
	Valider=verifChampText(document.formInscription.nom, "Your name is not correct");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.prenom, "Your first name is not correct");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.societe, "Your company is not correct");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.adresse, "Your address is not correct");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.codepostal, "Your postal code is not correct");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.ville, "Your city is not correct");	
//pays
if (Valider==true)
	Valider=verifChampText(document.formInscription.telephone, "Your phone number is not correct");	
if ((Valider==true))
	{ 
	titreCoche=false;
	for (i=0;i<document.formInscription.profession.length ;i++ )
	{
		if ((document.formInscription.profession[i].checked==true)&&(titreCoche==false))
		{
			titreCoche=true;
			valCaseCochee=document.formInscription.profession[i].value;
		}
	}

	if ( (titreCoche==false) || (valCaseCochee==0 && document.formInscription.profautre=="") )
		{	
			alert("Your profession is not indicated");
			Valider=false;
		}
	}

return Valider;	
}

/****************************************/

/****************************************/
function verifFormMembre(nomForm)
{
	//alert(nomForm.name);

Valider=true;
Valider=verifMail(nomForm.email,"Your e-mail address is not correct",Valider);	

if (nomForm.name=="formInscription")
{
	if (Valider==true )
		Valider=verifChampText(nomForm.password, "Your password is not correct");
	if (Valider==true)
		Valider=verifChampText(nomForm.password2, "The confirmation of your password is not correct");
}

if (nomForm.name!="formQuestions")
{
	if ((Valider==true) && (nomForm.password.value != nomForm.password2.value))
		{
		alert("Your password and the confirmation are not the same");
		Valider=false;
		}
}

if ((Valider==true))
	{ 
	titreCoche=false;
	for (i=0;i<nomForm.titre.length ;i++ )
	{
		if ((nomForm.titre[i].checked==true)&&(titreCoche==false))
			titreCoche=true;
	}

	if (titreCoche==false)
		{	
			alert("Your civility is not indicated ");
			Valider=false;
		}
	}
	
if (Valider==true)
	Valider=verifChampText(nomForm.nom, "Your name is not correct");	
if (Valider==true)
	Valider=verifChampText(nomForm.prenom, "Your first name is not correct");	
if (Valider==true)
	Valider=verifChampText(nomForm.societe, "Your company is not correct");	
if (Valider==true)
	Valider=verifChampText(nomForm.adresse, "Your address is not correct");	
if (Valider==true)
	Valider=verifChampText(nomForm.codepostal, "Your postal code is not correct");	
if (Valider==true)
	Valider=verifChampText(nomForm.ville, "Your city is not correct");	
//pays
if (Valider==true)
	Valider=verifChampText(nomForm.telephone, "Your phone number is not correct");	

if ((Valider==true))
{ 
	if (nomForm.profession[nomForm.profession.selectedIndex].value=="")
		{	
			alert("Your profession is not indicated");
			Valider=false;
		}
}

if (nomForm.name=="formQuestions")
{
	demandeCoche=false;
	for (i=0;i<nomForm.demande.length ;i++ )
	{
		if ((nomForm.demande[i].checked==true)&&(demandeCoche==false))
		{
			demandeCoche=true;
			valCaseCochee=nomForm.demande[i].value;
		}
	}

	if (demandeCoche==false)
		{	
			alert("The type of request is not indicated ");
			Valider=false;
		}
	else
		{
		switch(valCaseCochee)
			{
			case "doc":
				//if (nomForm.doc.selectedIndex==-1)
				//documents.forms[0].elements['var[]']; 
				if (nomForm.elements['doc[]'].selectedIndex==-1)

				{ Valider=false; alert("No documentation is selected ");}
				break;
			case "dis":
				if (nomForm.dis[nomForm.dis.selectedIndex].value=="")
				{ Valider=false; alert("No region is indicated");}
				break;
			case "pri":
				if (nomForm.pri1[nomForm.pri1.selectedIndex].value=="")
				{ Valider=false; alert("No product is indicated");}
				if (nomForm.pri1s.value=="")
				{ Valider=false; alert("The area of the product is not indicated");}
				break;
			}
		}
	
}
return Valider;	
}

/****************************************/
function afficheSouhaitContact(val)
{
	document.getElementById("chambre").style.display='none';
	document.getElementById("restaurant").style.display='none';
	document.getElementById("cours").style.display='none';
	if (val=="restaurant"||val=="chambre"||val=="cours")
	{
		document.getElementById(val).style.display='';
	}
}

/**** QUESTIONS ****/
tabnomsId=new Array("doc", "tec", "pri", "con", "dis","aut");
function afficheId(nomId)
{	
	//alert(tabnomsId.length);
	for (i=0; i<tabnomsId.length; i++ )
	{ 
		if (document.getElementById("details"+tabnomsId[i]))
			document.getElementById("details"+tabnomsId[i]).style.display='none';	
		//alert(tabnomsId[i]);
	}
	if (document.getElementById(nomId))
		document.getElementById(nomId).style.display='';
}

function detailscon()
{
	if (formQuestions.detailscon_select.options[formQuestions.detailscon_select.selectedIndex].value=="")
	{
		document.getElementById("detailscon_autre").style.display='';
	}
	else
		document.getElementById("detailscon_autre").style.display='none';

}


/****************************************/
function verifSondageQuestion(nomForm, numQuestion, numElement, Valider)
{
	if (eval('nomForm.q'+numQuestion+'['+numElement+'].checked==true') && eval('nomForm.q'+numQuestion+'commentaire.value==""') && Valider==true)
	{
		alert("Thank you for specifying your answer to the question n°"+numQuestion);
		eval('nomForm.q'+numQuestion+'commentaire.select()');
		eval('nomForm.q'+numQuestion+'commentaire.focus()');
		Valider=false;
	}
	return Valider;
}

/****************************************/

function verifSondage(nomForm)
{

Valider=true;

// Questions
for (y=1;y<12;y++)
{

	if (Valider==true && y!=5 && y!=3 && y<9)
	{ 

		questionOK=false;
		longueurRep=eval('nomForm.q'+y+'.length');

		for (i=0;i<longueurRep;i++)
		{
			if (eval('nomForm.q'+y+'['+i+'].checked')==true && questionOK==false)
				questionOK=true;
		}


		// Question non cochée
		if (questionOK==false)
		{	
			alert("Thank you for answering the question n°"+y);
			Valider=false;
		}
		// Question cochée, tout ok ?
		else
		{
			switch(y)
			{
				case 1:
				Valider=verifSondageQuestion(nomForm, 1, 4, Valider);
					break;
				case 3:
				Valider=verifSondageQuestion(nomForm, 3, 6, Valider);
					break;
				case 4:
				Valider=verifSondageQuestion(nomForm, 4, 1, Valider);
					break;
				case 6:
				Valider=verifSondageQuestion(nomForm, 6, 3, Valider);
					break;
				case 7:
				Valider=verifSondageQuestion(nomForm, 7, 3, Valider);
					break;
				case 8:
				Valider=verifSondageQuestion(nomForm, 8, 3, Valider);
					break;				
			}
		}
	}
	
}

if (nomForm.q5.value=='' && Valider==true)
{
	alert("Thank you for specifying your answer to the question n°5");
	nomForm.q5.select ();
	nomForm.q5.focus ();
	Valider=false;
}

if (nomForm.q9.selectedIndex==0 && Valider==true)
{
	alert("Thank you for answering the question n°9");
	Valider=false;
}

if (nomForm.q10.value=='' && Valider==true)
{
	alert("Thank you for specifying your answer to the question n°10");
	nomForm.q10.select ();
	nomForm.q10.focus ();
	Valider=false;
}

Valider=verifMail(nomForm.email,"Your e-mail address is not correct",Valider);	

return Valider;	
}

/****************************************/