//global variables
var sFieldToFocus;
sFieldToFocus = "namefirst";

//utility functions
function setFieldToFocus(sFieldName) {
	if(sFieldToFocus == "") {
		return sFieldName;
	} else {
		return sFieldToFocus;
	}
}

function appendLineToString(sCurrentString, sNewString) {
	if(sCurrentString == "") {
		return sNewString;
	} else {
		return sCurrentString + "\n" + sNewString;
	}
}

function isValidEmail(sEmail) {
	var pattern = /^[\w\.\-]+[\+]?[\w\.\-]*@([0-9a-zA-Z\-]+\.)+[a-zA-Z]+$/;
	return pattern.test(sEmail);
}


//form validation function
function handleFormSubmit() {
	var sAlertMessage;
	sAlertMessage = "";
	
	if(!isValidEmail(document.SubscribeForm.email.value)){
		sAlertMessage = appendLineToString(sAlertMessage, "Votre courriel semble etre invalide.");
	}

	if(sAlertMessage != "") {
		alert(sAlertMessage);
		return false;
	} else {
		return true;
	}
}
//-->
