
function trim(str){
	str = str.replace(/\s+/g," ");
	return str.replace(/^\s*|\s*$/,"");
}

function validate_mail(courriel){
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	return reg.test(courriel);
}

function validate_form(nom_form){
	
	var nom_form	= nom_form.name;
	var form		= document.getElementById(nom_form);
	var nom			= trim(form.nom.value);
	var prenom		= trim(form.prenom.value);
	var courriel	= trim(form.courriel.value);
	var tel			= trim(form.tel.value);

	if(nom=="" || prenom=="" || courriel=="" || tel=="" ){
		alert('Complétez tous les champs munis d\'une astérisque.');
		return false;
	}else if(!validate_mail(courriel)){
		alert('Veuillez corriger l\'adresse e-mail.');
		return false;
	}
}


		function resize_textarea(textArea,compteur){
										
			var text 		= textArea.value;
			var compteur	= compteur
			
			if(compteur!=''){
				var nbr_carac 	= text.length;
				var max_carac	= 250;

				if(nbr_carac>max_carac){
					text = text.substr(0,250);
					textArea.value	= text;
					var nbr_carac	= text.length;
				}
				
				document.getElementById(compteur).innerHTML = 250 - nbr_carac +" restants.";
			}

			if (navigator.appName.indexOf("Microsoft Internet Explorer") == 0){
				textArea.style.overflow = 'visible';
				textArea.style.height	= '70px';
				return;
			}else{
				while(textArea.rows > 3 && textArea.scrollHeight < textArea.offsetHeight){
					textArea.rows--;
				}
				
				while(textArea.scrollHeight > textArea.offsetHeight){
					textArea.rows++;
				}
			}
		}

