// JavaScript Document

// Removes the instructional text from the email address box for newsletter signups
function removeInstructionalText(e) {
	if ( e.value.toLowerCase() == "e-mail address" ) { e.value = "" }
}

function removeInstructionalTextFR(e) {
	if ( e.value.toLowerCase() == "courriel" ) { e.value = "" }
}

function checkEmail(strVar) {
    var emailReg = /^(\w){1}[^\*\$\^\&\!\#\%\(\)\+\`\~\,\/\?\:\;\\\"\|\[\]\{\}\@]+\@(\w){1}(\w|-|\.)+\.[a-z]{2,4}$/i;
    var emOK = true;
    if(strVar.length > 1){
		if(!emailReg.test(strVar)){
			emOK = false;
		}
	} 
    return emOK;
}

function validateEmail() {
	if ((document.ngsignup.emailID.value != "") && (document.ngsignup.emailID.value != document.ngsignup.emailID.defaultValue)) {
		if (!checkEmail(document.ngsignup.emailID.value)) {
			alert("Invalid email address");
			return false;
		} // end if
	} else { //email is blank
		alert("Invalid email address");
		return false;
	}
	return true;
} // end function

function validateEmailFR() {
	if ((document.ngsignup.emailID.value != "") && (document.ngsignup.emailID.value != document.ngsignup.emailID.defaultValue)) {
		if (!checkEmail(document.ngsignup.emailID.value)) {
			alert("Adresse de courriel erronée");
			return false;
		} // end if
	} else { //email is blank
		alert("Adresse de courriel erronée");
		return false;
	}
	return true;
} // end function