/* ******************************************************************************************** */
/* 
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!! Don't use this file again! It should be replaced by more common file 'validateForm.js'.
*     The functions from this file are in the file 'validateForm.js' too.
*/
/* ******************************************************************************************** */
/*
* The 'validateEmail' function validate the standard email format in the input text field in the form.
* Params:
*   formName ... the name of the current form
*   errorMessage ... the locale specified part of the error message
* The name of the input field in form must be 'email'
* This script is used for example in '/porfile/EditPHPMainPageForm.jhtml'.
*
* Oriflame SW, Tomas, 22.11.2001
*/

function validateEmail(formName, errorMessage) {
  var field = formName.email; // email field
  var str = field.value; // email string
  if (field.value == "") { // if email isn't filed
    return true;
  }

  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid
    //alert("Thank your for your feedback."); // this is optional
    return true;
  }
	if (navigator.appName == 'Netscape' && document.layers && !document.getElementById){ // NN4
    var xxx = confirm("\"" + str + "\" " + errorMessage);
  }
  else {
    alert("\"" + str + "\" " + errorMessage);
    field.focus();
    field.select();
    return false;
  }
}

