// Provided by MyFreeTemplates.com
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function addToFavorite() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel("Lettres types gratuites","http://www.LettrePratique.Fr/",""); }
else { window.external.AddFavorite("http://www.LettrePratique.Fr/","Lettres types gratuites"); } 
}

function nbNum(field) {
	var valid = "0123456789";
	var numCount = 0;
	
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (valid.indexOf(temp) != "-1") numCount++;
	}
	
	return numCount;
}

/* check if field contain only char from pattern */
function matchPattern(field, pattern) {
	var valid = pattern;
	var numCount = 0;
	
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (valid.indexOf(temp) != "-1") numCount++;
	}
	
	return (field.length == numCount);
}

/* check if field contain only numeric chars */
function isNumeric(field) {
	return matchPattern(field, "0123456789");
}

/* check if field contain only numeric or "," char */
function isDecimal(field) {
	return matchPattern(field, "0123456789,");
}

isEmail = function(emailStr) {

	var checkTLD = 1;
	var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|fr)$/;
	var emailPat = /^(.+)@(.+)$/;
	var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars = "\[^\\s" + specialChars + "\]";
	var quotedUser = "(\"[^\"]*\")";
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom = validChars + '+';
	var word = "(" + atom + "|" + quotedUser + ")";
	var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray = emailStr.match(emailPat);
	if (matchArray == null) { return false; }
	var user = matchArray[1];
	var domain = matchArray[2];
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i) > 127) { return false; }
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i) > 127) { return false; }
	}
	if (user.match(userPat) == null) { return false; }
	var IPArray=domain.match(ipDomainPat);
	if (IPArray != null) {
		for (var i=1; i<=4; i++) {
			if (IPArray[i] > 255) { return false; }
		}
		return true;
	}
	var atomPat = new RegExp("^" + atom + "$");
	var domArr = domain.split(".");
	var len = domArr.length;
	for (i=0; i<len; i++) {
		if (domArr[i].search(atomPat) == -1) { return false; }
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { return false; }
	if (len < 2) { return false; }
	return true;
}

function verifForm() {

document.getElementById('message_zone').innerHTML = "&nbsp;";
document.getElementById('nom').style.backgroundColor="#FFFFFF";
document.getElementById('prenom').style.backgroundColor="#FFFFFF";
document.getElementById('code_postal').style.backgroundColor="#FFFFFF";
document.getElementById('numero_de_telephone').style.backgroundColor="#FFFFFF";
document.getElementById('email').style.backgroundColor="#FFFFFF";
document.getElementById('ir').style.backgroundColor="#FFFFFF";

var nom = document.getElementById('nom').value;
var prenom = document.getElementById('prenom').value;
var code_postal = document.getElementById('code_postal').value;
var numero_de_telephone = document.getElementById('numero_de_telephone').value;
var email = document.getElementById('email').value;
var ir = document.getElementById('ir').value;


if((nom.length < 3))
{
	document.getElementById('message_zone').innerHTML = '<span style="color:red;font-weight:bold">Veuillez indiquer votre nom.</span>';
	document.getElementById('nom').style.backgroundColor="#F8B23A";
	return false;
}

if((prenom.length < 3))
{
	document.getElementById('message_zone').innerHTML = '<span style="color:red;font-weight:bold">Veuillez indiquer votre prénom.</span>';
	document.getElementById('prenom').style.backgroundColor="#F8B23A";
	return false;
}

if((code_postal.length >=5) && (nbNum(code_postal) == 5))
{
}
else
{	
	document.getElementById('message_zone').innerHTML = '<span style="color:red;font-weight:bold">Le code postal doit comporter 5 chiffres.</span>';
	document.getElementById('code_postal').style.backgroundColor="#F8B23A";
	return false;
}

if ((numero_de_telephone.length >=10) && (nbNum(numero_de_telephone) == 10) && (numero_de_telephone.length <=14))
{
}
else
{	
	document.getElementById('message_zone').innerHTML = '<span style="color:red;font-weight:bold">Le numéro de téléphone n\est pas valide.</span>';
	document.getElementById('numero_de_telephone').style.backgroundColor="#F8B23A";
	return false;
}

if((ir.length < 3))
{
	document.getElementById('message_zone').innerHTML = '<span style="color:red;font-weight:bold">L\'impôt sur le revenu n\'est pas renseigné.</span>';
	document.getElementById('ir').style.backgroundColor="#F8B23A";
	return false;
}

if(!isEmail(email))
{
	document.getElementById('message_zone').innerHTML = '<span style="color:red;font-weight:bold">L\'email n\'est pas valide.</span>';
	document.getElementById('email').style.backgroundColor="#F8B23A";
	return false;
}

//alert('Merci! Vous serez contacté(e) prochainement.');
return true;

}

//-->
