// browser detection
var ns4 = (document.layers) ? true:false // Netscape 4.x
var ie4 = (document.all) ? true:false // IE 4.x
var ie5 = (document.getElementById) ? true:false // Browers that really matter

function checkForm(form) {
	var incomplete = 0;
	var alertMsg = "The following fields are required:\n";
	
	
	if(form.txtFriendName.value == "") {
		incomplete++;
		alertMsg = alertMsg +"Friend's Name\n";
	}
	if(form.txtFriendEmail.value == "") {
		incomplete++;
		alertMsg = alertMsg +"Friend's E-mail\n";
	}	
	if(form.txtSenderName.value == "") {
		incomplete++;
		alertMsg = alertMsg +"Your Name\n";
	}
	if(form.txtSenderEmail.value == "") {
		incomplete++;
		alertMsg = alertMsg +"Your E-mail\n";
	}
	if (incomplete > 0){
		alert(alertMsg);
		return false;
	}
	//Given an email, make sure it's in proper email format.
 var boolValidateEmail = bwwValidateEmailAddress(form.txtFriendEmail.value);
   
 //If the email isn't formatted properly, throw out this error:
 if (boolValidateEmail == false)
 {
  form.txtFriendEmail.focus();
  alert("The Friend's E-mail Address you entered is not in the proper format\n");
 }


 var boolValidateEmail = bwwValidateEmailAddress(form.txtSenderEmail.value);
   
 //If the email isn't formatted properly, throw out this error:
 if (boolValidateEmail == false)
 {
  form.txtSenderEmail.focus();
  alert("The Email Address you entered is not in the proper format\n");
 }


function bwwValidateEmailAddress(emailAddress)
{
 var regexProperEmail=/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/
      
 if (emailAddress.search(regexProperEmail)==-1)
 {  
  return false;
 }
 return true;
}
}