function validate()

// use this on the form tag ..... onSubmit="return validate()"

{	
	var strErrHeader="";
	var strErrMsg="";
	var isChecked = -1;
	var StopSpam = "";

	if (document.frmNatBio.name.value=="") {
		strErrMsg = strErrMsg + 'Your name.\n';
		}	
	if (document.frmNatBio.firstname.value=="") {
		strErrMsg = strErrMsg + 'Your name.\n';
		}
	if (document.frmNatBio.lastname.value=="") {
		strErrMsg = strErrMsg + 'Your name.\n';
		}
	if (document.frmNatBio.workphoneReq){
		if (document.frmNatBio.workphoneReq.value=="") {
		strErrMsg = strErrMsg + 'Work phone.\n';
			}
		}
	if (document.frmNatBio.email.value=="") {
		strErrMsg = strErrMsg + 'E-mail.\n';
		}
	if (document.frmNatBio.email.value!="") {
		if (!isEmail(document.frmNatBio.email.value)) {
			strErrMsg = strErrMsg + 'Error: Invalid Email Address.\n';
			}
		}
	if (document.frmNatBio.address1.value!="") {
		if (!isEmail(document.frmNatBio.email.value)) {
			strErrMsg = strErrMsg + 'Error: Invalid Address.\n';
			}
		}
	if (document.frmNatBio.homephone.value!="") {
		if (!isEmail(document.frmNatBio.email.value)) {
			strErrMsg = strErrMsg + 'Error: Invalid Phone.\n';
			}
		}	if (document.frmNatBio.address1.value=="") {
		strErrMsg = strErrMsg + 'Your address.\n';
		}	
	if (document.frmNatBio.city.value=="") {
		strErrMsg = strErrMsg + 'Your city.\n';
		}
	if (document.frmNatBio.state.value=="") {
		strErrMsg = strErrMsg + 'Your state.\n';
		}
	if (document.frmNatBio.zip.value=="") {
		strErrMsg = strErrMsg + 'Your zip.\n';
		}		
	if (document.frmNatBio.physicianname){
		if (document.frmNatBio.physicianname.value=="") {
		strErrMsg = strErrMsg + 'Referring physician name.\n';
		}
	}
	if (strErrMsg != '') {
		strErrHeader = strErrHeader + 'Please ensure the following ';
		strErrHeader = strErrHeader + 'fields are properly filled out:\n';
		strErrHeader = strErrHeader + '------------------------\n';
		strErrMsg = strErrHeader + strErrMsg
		strErrMsg = strErrMsg + '------------------------\n';
		alert(strErrMsg);
		return false;
	}
}

function isEmail(s) {
	
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@")) {
    	i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != ".")) {
    	i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}


