NumChars = "0123456789";
BadMail=";/:<>*|'&$!§#(){}` \"\\";
		
function Verif(size)
{
        if (trimAll(size).length < 1)
        { return 1;}
        return 0;
}

function trimAll(sString)
{
  while (sString.substring(0,1) == ' ')
  {
    sString = sString.substring(1, sString.length);
  }

  while (sString.substring(sString.length-1, sString.length) == ' ')
  {
    sString = sString.substring(0,sString.length-1);
  }
  return sString;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function VerifMail(name)
{
	var plot1 = 0;
	var plot2 = 0;
	var j;
	name=trimAll(name);
	for (var i = 0; i < name.length; i++)
	{
		var charactere1 = name.substring(i, i+1);
		for (j = 0; j < BadMail.length; j++)
		{
			var charactere2 = BadMail.substring(j, j+1);
			if (charactere2 == charactere1)
			{
				return (1);
			}
		}
		if (charactere1 == '@')
		{
			if (plot1)
			{
				return (1);
			}
			else
			{
				plot1 = 1;
				plot2 = 0;
			}
		}
		if (charactere1 == '.')
		{
			plot2 = 1;
		}
	}
	if ((!plot1) || (!plot2))
	{
		return (1);
	}
	return (0);
}

function vwStandard(elmt)
{
	st = $(elmt).getElementsByTagName('form')[0];
	st.style.display=(st.style.display=="")?"block":"";  
}

function VerifFormEnvoisParEmail(form)
{
  var msg=msgVerif="Le formulaire n'a pas été remplis correctement.\nVeuillez vérifier les champs suivants:\n\n";

  if (Verif(form.nomEmail.value)==1)
  {
    msg+="  -  Votre nom\n";
  }

  if (Verif(form.provenanceEmail.value)==1)
  {
    msg+="  -  Votre e-mail\n";
  }
  else if (VerifMail(form.provenanceEmail.value)==1)
  {
    msg+="  -  Votre e-mail est invalide\n";
  }

  if (form.destinatairesEmail.value=="")
  {
    msg+="  -  E-mails des destinataires \n";
  }

  if (Verif(form.objetEmail.value)==1)
  {
    msg+="  -  Objet \n";
  }

  if (form.messageEmail.value=="")
  {
    msg+="  -  Message \n";
  }

 	if(msg!=msgVerif)
  {
    alert(msg);
    return false;
  }

	return true;
}

function VerifFormContact(form)
{
  var msg=msgVerif="Le formulaire n'a pas été remplis correctement.\nVeuillez vérifier les champs suivants:\n\n";

	if (Verif(form.nomContact.value)==1)
	{
	    msg+="  -  Votre nom\n";
	}
	
	if (getCheckedValue(form.elements['idOrigineContact'])=="")
	{
		msg+="  -  Votre êtes\n";
	}

	if (getCheckedValue(form.elements['idTypeContact'])=="")
	{
		msg+="  -  Votre question concerne\n";
	}
	
	if (Verif(form.emailContact.value)==1)
	{
	    msg+="  -  Votre email\n";
	}
	else if (VerifMail(form.emailContact.value)==1)
  {
    msg+="  -  Veuillez indiquer un email valide\n";
  }

	
  if(msg!=msgVerif)
  {
    alert(msg);
    return false;
  }
}

function validsearch0(thisitem)
{
	if (thisitem.searchTexte.value.length<3)
	{
		alert('Veuillez renseigner au moins 3 caractères dans la recherche libre');
		return false;
	}
	else return true;
}

function putRssHead(titre,url)
{	
	if(titre != '' && url != '' && document.getElementsByTagName)
	{
		head = document.getElementsByTagName('head');
		toto = document.getE
		dalink=document.createElement("link");
		dalink.setAttribute('type','application/rss+xml');
		dalink.setAttribute('href',url);
		dalink.setAttribute('title',titre);
		dalink.setAttribute('rel','alternate');
		head[0].appendChild(dalink);					
	}
}
