String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
}

function doMatch(str,rex) {
  var re = new RegExp(rex);
  var m = re.exec(str);
  return m;
}

function process_form(){
	nom 	= document.contact_form.nom_field.value.trim();
	prenom 	= document.contact_form.prenom_field.value.trim();
	adresse = document.contact_form.adresse_field.value.trim();
	ville	= document.contact_form.ville_field.value.trim();
	pays	= document.contact_form.pays_field.value.trim();
	//postal	= document.contact_form.postale_field.value.trim();
	tel	= document.contact_form.telephone_field.value.trim();
	email	= document.contact_form.courrier_field.value.trim();
	//porduit	= document.contact_form.produit_field.value.trim();
	comment	= document.contact_form.question_field.value.trim();
	
	if (nom == ''){
		window.alert('Please enter your first name.');
		return;
	}
	if (prenom == ''){
		window.alert('Please enter your last name.');
		return;
	}
	/*
	if (adresse == ''){
		window.alert('Please enter your address.');
		return;
	}
	if (ville == ''){
		window.alert('Please enter your city name.');
		return;
	}
	if (pays == ''){
		window.alert('Please enter your country name.');
		return;
	}
	if (tel != ''){
		if (doMatch(tel,'^[0-9\s \( \) \+ -]{8,30}[0-9]{1}$') == null){
			window.alert('Please enter your valid phone number.');
			return;			
		}
	}
	*/
	if (doMatch(email,'^[A-Za-z0-9_\.-]+@[A-Za-z0-9_\.-]+\.[A-Za-z]{2,4}$') == null){
		window.alert('Please enter your valid e-mail address.');
		return;
	}
	/*
	if (produit == ''){
		window.alert('Veuillez entrer un code du produit.');
		return;
	}
	*/
	if (comment == ''){
		window.alert('Please enter your comment.');
		return;
	}
	document.contact_form.submit();
	
}
