
/* Simple Validation Script 
 * Requires Prototype and Script.aculo.us Libraries
 * By: Andrˇ Houde <info@scah.ca>
 * http://briancrescimanno.com
 * Fonctions globales au site Internet
 * http://www.scah.ca
 */

//  Validation du courriel
//  -----------------------------------------

function isEmail(opt)
	{
	if (opt == "" || opt.length < 6)					//' Verifier si le champ n'est pas vide
		return false

	temp = /\s+/g;										//' Vˇrifier les caracteres illegaux
	if (temp.test(opt))
		return false;
	

	temp = /^(\w|[^_]\.|[\-])+((\@){1}([^_]))(([a-z]|[\d]|[\-]|\.)+|([^_]\.[^_])*)+\.[a-z]{2,6}$/i;
	if (!temp.test(opt))
		return false;
			
	temp =/\.(a[c-gil-oq-uwz]|b[a-bd-jm-or-tvwyz]|c[acdf-ik-orsuvx-z]|d[ejkmoz]|e[ceghr-u]|f[i-kmorx]|g[abd-ilmnp-uwy]|h[kmnrtu]|i[delm-oq-t]|j[emop]|k[eg-imnprwyz]|l[a-cikr-vy]|m[acdghk-z]|n[ace-giloprtuz]|om|p[ae-hk-nrtwy]|qa|r[eouw]|s[a-eg-ort-vyz]|t[cdf-hjkm-prtvwz]|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[admrw]|com|edu|net|org|mil|gov|biz|pro|aero|coop|info|name|museum)$/i;
	
	if (!temp.test(opt))								//' Valider a partie du champ correspondant au nom de domaine
		return false;
	
	temp = /\.\./										//' Valider les caracteres suivants:  ././ 
	if (temp.test(opt))
		return false;
	
														//'  Valider le caractere @@ 
	temp = /\@\@/
	if(temp.test(opt))
		return false;

	return true;
}



//  Validation si le champ est numˇrique 
//  -----------------------------------------

function isNumeric(sText)
{
   var ValidChars = "0123456789-";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}



// FONCTION DE VALIDATION DU FORMULAIRE CONTACT

function valider_contact()
{
	if (document.forms[0].prenom.value == "")
	{
		document.forms[0].prenom.focus();
		alert("Le pr\351nom est obligatoire.");
		return false;
	}

	if (document.forms[0].nom.value == "")
	{
		document.forms[0].nom.focus();
		alert("Le nom de famille est obligatoire.");
		return false;
	}

	if (document.forms[0].courriel.value == "")
	{
		document.forms[0].courriel.focus();
		alert("Le courriel est obligatoire.");
		return false;
	}else{
		if (!isEmail(document.forms[0].courriel.value))
		{
			document.forms[0].courriel.focus();
			alert("Le format du courriel est invalide.");
			return false;
		}
	}
	
	if (document.forms[0].telephone.value == "")
	{
		document.forms[0].telephone.focus();
		alert("Le tˇlˇphone est obligatoire.");
		return false;
	}else{
		if (!isNumeric(document.forms[0].telephone.value))
		{
			document.forms[0].telephone.focus();
			alert("Le format du T\351l\351phone est invalide.");
			return false;
		}
	}
	
	if (document.forms[0].ville.value == "")
	{
		document.forms[0].ville.focus();
		alert("Le nom de la ville est obligatoire.");
		return false;
	}

	if (document.forms[0].message.value == "")
	{
		document.forms[0].message.focus();
		alert("SVP nous indiquer le sujet de votre demande.");
		return false;
	}


}


function liste_profil()
{
	document.location.href = "profil.asp";
}





