function IsNumeric(strString)
  //  check for valid numeric strings	
  {
  var strValidChars = "0123456789";
  var strChar;
  var blnResult = true;

  if (strString.length == 0) return false;

  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == true; i++)
     {
     strChar = strString.charAt(i);
     if (strValidChars.indexOf(strChar) == -1)
        {
        blnResult = false;
        }
     }
  return blnResult;
  }

function testBox2(form) {
Ctrl = form.os1;
if (validateEmail(form.os1.value,1,0)==(true)) {
	return (true);
} else
	validatePrompt (Ctrl, "Please enter a valid email address to \n which the password will be sent.")
	return (false);
}

function testBox1(form) {
Ctrl = form.os0;
if (IsNumeric(form.os0.value) != (true) || (form.os0.value.length < 5) || (form.os0.value.length > 8)) {
validatePrompt (Ctrl, "Please enter the System ID \n located at the top of the \n Registration Form when you \n first open Fashion Master. \n\n The System ID must \n be a number containing \n between 5 and 8 digits.")
	return (false);
} else
	return (true);
}

function runSubmit (form)  {
if (!testBox1(form)) return false;
if (!testBox2(form)) return false;
return;
}


function validatePrompt (Ctrl, PromptStr) {
alert (PromptStr)
Ctrl.focus();
return;
}

function validateEmail(addr,man,db) {
if (addr == '' && man) {
  if (db) alert('email address is mandatory');
  return false;
}
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
  if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
     if (db) alert('email address contains invalid characters');
     return false;
  }
}
for (i=0; i<addr.length; i++) {
  if (addr.charCodeAt(i)>127) {
     if (db) alert("email address contains non ascii characters.");
     return false;
  }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
  if (db) alert('email address must contain an @');
  return false;
}
if (atPos == 0) {
  if (db) alert('email address must not start with @');
  return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
  if (db) alert('email address must contain only one @');
  return false;
}
if (addr.indexOf('.', atPos) == -1) {
  if (db) alert('email address must contain a period in the domain name');
  return false;
}
if (addr.indexOf('@.',0) != -1) {
  if (db) alert('period must not immediately follow @ in email address');
  return false;
}
if (addr.indexOf('.@',0) != -1){
  if (db) alert('period must not immediately precede @ in email address');
  return false;
}
if (addr.indexOf('..',0) != -1) {
  if (db) alert('two periods must not be adjacent in email address');
  return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
  if (db) alert('invalid primary domain in email address');
  return false;
}
return true;
}

