function validate() {

fname=document.form1.first.value
lname=document.form1.last.value
email = document.form1.email.value
phone = document.form1.phone.value
street = document.form1.street.value
state = document.form1.st.value
zip = document.form1.zip.value
city = document.form1.city.value


var valid = "0123456789-";
var hyphencount = 0;

myOption = -1;
for (i=document.form1.camp.length-1; i > -1; i--) {
if (document.form1.camp[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert("You must select atleast one program option");
document.form1.camp[0].focus();
return false;
}

//document.form1.submit();

if ((fname.length<1)||(fname.substring(0,6)=="******")) {
alert("The First Name field must be filled.")
document.form1.first.focus();
return false;
	}
	
	
if ((lname.length<1)||(lname.substring(0,6)=="******")) {
alert("The Last Name field must be filled.")
document.form1.last.focus();
return false;
	}
	
if ((street.length<1)||(street.substring(0,6)=="******")) {
alert("The Street field must be filled.")
document.form1.street.focus();
return false;
	}
	
if ((city.length<1)||(city.substring(0,6)=="******")) {
alert("The City field must be filled.")
document.form1.city.focus();
return false;
	}

if ((state.length<1)||(state.substring(0,6)=="******")) {
alert("The State field must be filled.")
document.form1.st.focus();
return false;
	}

if (zip.length!=5) {
alert("Please enter your 5 digit zip code.");
document.form1.zip.focus();
return false;
}
for (var i=0; i < zip.length; i++) {
temp = "" + zip.substring(i, i+1);
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
document.form1.zip.focus();
return false;
}
}


var checkTLD=1;

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=email.match(emailPat);

if (matchArray==null) {

alert("Email address seems incorrect (check @ and .'s)");
document.form1.email.focus();
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
document.form1.email.focus();
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
document.form1.email.focus();
return false;
   }
}

if (user.match(userPat)==null) {
alert("The username doesn't seem to be valid.");
document.form1.email.focus();
return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
document.form1.email.focus();
return false;
   }
}
return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
document.form1.email.focus();
return false;
   }
}

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
document.form1.email.focus();
return false;
}

if (len<2) {
alert("This address is missing a hostname!");
document.form1.email.focus();
return false;
}

if (phone.length!=12) {
alert("Please enter your 10 digit phone code. Please enter in 999-999-9999 Format.");
document.form1.phone.focus();
return false;
}
for (var i=0; i < phone.length; i++) {
temp = "" + phone.substring(i, i+1);
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your Phone Number.  Please enter in 999-999-9999 Format.");
document.form1.phone.focus();
return false;
}
}

}
