function isNotEmpty(field) {
	var str = field.value;
   var msg = "all required fields";
   if(str == null || str.length == 0) {
      return false;
   } else {
   	return true;
   }
}

function isEmailAddr(address) {
	var str = address.value;
   str = str.toLowerCase();
   if (str.indexOf("@") > 1) {
		var addr = str.substring(0, str.indexOf("@"));
      var domain = str.substring(str.indexOf("@") + 1, str.length);
      if (domain.indexOf(".") == -1) {
      	alert("Please verify the domain portion of the email address. Adresse email incorrecte.");
         return false;
      }
      // check address portion
      for (var i = 0; i < addr.length; i++) {
      	oneChar = addr.charAt(i).charCodeAt(0);
         // no dot or hyphen in first position nor dot in last
         if ((i == 0 && (oneChar == 45 || oneChar == 46)) ||
         	(i == addr.length -1 && oneChar == 46)) {
            	alert("Please verify the user address portion of the email address.Adresse email incorrecte.");
               return false;
         }
         // acceptable characters
         if (oneChar == 45 || oneChar == 46 || oneChar == 95 ||
         	(oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)){
            	continue;
         } else {
         	alert("There are invalid characters in the user address\r\nportion of the email address. Please Verify.\r\nAdresse email incorrecte.");
            return false;
         }
      }
      for (i = 0; i < domain.length; i++) {
      	oneChar = domain.charAt(i).charCodeAt(0);
         if ((i == 0 && (oneChar == 45 || oneChar == 46)) ||
         	((i == domain.length - 1 || i == domain.length - 2) &&
            oneChar == 46)) {
            	alert("Please verify the domain portion of the email address\r\ndoes not begin with non-alphabetical characters. \r\nAdresse email incorrecte.");
            	return false;
         }
         if (oneChar == 45 || oneChar == 46 || oneChar == 95 ||
         	(oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
            	continue;
         } else {
         	alert("There are invalid characters in the domain portion\r\nof the email address. Please verify.\r\nAdresse email incorrecte.");
            return false;
         }
      }
      return true;
   }
   alert("The email address may not be formatted correctly. Please verify.\r\nAdresse email incorrecte.");
   return false;
}

function isLen300(note) {
	var str = note.value;
   if (str.length > 300) {
   	alert("You have entered too long of a note.\r\nPlease shorten it.\r\nVotre question est trop longue.");
      return false;
   } else {
   	return true;
   }
}

function isGoodLen(field, len) {
	var str = field.value;
   if (str.length > len) {
   	alert("This field cannot be be longer than "+len+" characters.\r\nPlease shorten it.\r\nTrop du caracteres.");
      return false;
   } else {
   	return true;
   }
}

function isRadioChecked(radio) {
	var valid = false;
   for (var i = 0; i < radio.length; i++) {
   	if (radio[i].checked) {
      	return true;
      }
   }
   return false;
}

function noItemsChecked(form) {
   if (isRadioChecked(form.paytype) ||
      isRadioChecked(form.photo)) {
   		return false;
   }
	alert("Please indicate your type of payment or how you are sending your photo.");
	return true;
}

function validateMsg(form) {
	var str="";
	if (isNotEmpty(form.nom)) {
 	  	if (isNotEmpty(form.email)) {
      			//if (isNotEmpty(form.adresse)) {
				// str = noItemsChecked(form);
                	//	if (str == false) {
 					return true;
                		//}
        		//}
	     	}
  	}
   alert("Please fill in your name and email address.\r\nVeuillez inscrire votre nom et adresse email.");
   return false;
}