
//  **  VALIDATE THE FORM  **

function ValidateForm(theForm) {
//alert("got to form validation");
	if (theForm.organization.value=="") {
		alert("What is the name of your organization?");
                theForm.organization.focus();
           }
	else if (theForm.firstname.value=="" || theForm.lastname.value=="") {
		alert("I need your full name");
                theForm.firstname.focus();
           }
	else if (theForm.mailAddress.value=="") {
		alert("What is your address, please?");
                theForm.mailAddress.focus();
           }
	else if (theForm.city.value=="") {
		alert("Please include your city or town.");
                theForm.city.focus();
           }
	else if (theForm.state.value=="") {
		alert("What state are you in?");
                theForm.state.focus();
           }
	else if (theForm.zip.value=="") {
		alert("Please include your postal code number.");
                theForm.zip.focus();
           }
	else if (theForm.telephone.value=="") {
		alert("Please include a phone number.");
                theForm.telephone.focus();
           }
           
// * * check IF EMAIL SUPPLIED  * *
	else if (!validEmail(theForm.email.value)) {
		alert("This is an invalid e-mail address, "
		+"please try again.") ;
                theForm.email.focus();
                theForm.email.select();
             }
           
/*
	else if (theForm.ccNumber.value=="") {
		alert("Please a valid card number.");
                theForm.ccNumber.focus();
           }
   	else if (theForm.ccType.value=="") {
		alert("Please chose card type.");
                theForm.ccType.focus();
           }
   	else if (theForm.ccExpireDate.value=="") {
		alert("Please enter expiration date for this card.");
                theForm.ccExpireDate.focus();
           }
   	else if (theForm.ccNameOnCard.value=="") {
		alert("Please enter name on this card.");
                theForm.ccNameOnCard.focus();
           }
  */
             
//   	else if ( !validateSessionChoices(theForm) ) {
//		alert("If you chose a 2 hr session (in red) you cannot choose from the next session.");
//                theForm.session2_choice[0].focus();
////                theForm.ccNameOnCard.focus();
//           }

        else {
//     alert("submitting form after validation");

//                theForm.submit();
                return true;
             }
//      alert("validation failed");

     return false;
 }
// ** ** ** ** ** ** ** ** ** ** ** **

// ** VALIDATE EMAIL **
function validEmail(email){
	invalidChars="/:,;";
	valid=true;
	
	if(email=="") 	// nothing supplied
		valid = false;
	
	for(i=0; i<invalidChars.length; i++)
		badChar=invalidChars.charAt(i);
    if (email.indexOf(badChar,0)!= -1)
       valid = false;	// found an invalid character
			
	atPos=email.indexOf("@",1);	// look starting at 2nd char
	if(atPos== -1)
		valid = false;		// no @ in email		
	if (email.indexOf("@",atPos+1) != -1)
		valid = false;		// found a second @
		
	periodPos=email.indexOf(".", atPos)
	if(periodPos==-1)
		valid = false;		// found no . (dot) after @ found
		
//  if (last 3 chars are not .com, .edu, .cc,...)  false
	if((periodPos+2) >= email.length)
		valid = false; 		// no space left for com, net, edu, ...
		
	return valid;	// if we make it here, it should be valid!
}
// ** ** ** ** ** ** ** ** ** ** ** **
