
// checks and unchecks all boxes in form for "All Categories"

function toggleChecks( f, toggle ) {
for ( var i = 2; i < arguments.length; i++ ) {
cbGroup = f.elements[arguments[i]];
if ( typeof cbGroup == 'undefined' ) continue;
if ( cbGroup.length > 1 ) {
for ( var j = 0; ( cb = cbGroup[j] ); j++ ) {
cb.checked = toggle;
	}
}
else {
cbGroup.checked = toggle;
	}
}
}


//checks if values for required fields are not submitted 	
function validateForm(theForm) {
	var firstName = theForm.fname.value;
	var Firm = theForm.firm.value;
	var Phone = theForm.phone.value;
	var Email = theForm.email.value;
	
	var Project = theForm.email.project;
	var Date = theForm.email.date;
	var Location = theForm.email.location;
	
	var Travel = theForm.email.travel;
	var Hotel = theForm.email.hotel;
	var Nights = theForm.email.nights;
	var Reimbursement = theForm.email.reimbursement;
	
	if (firstName =="") {
		alert("Please provide your first name");
		theForm.fname.focus();
		return false;
		} 
	if (lastName =="") {
		alert("Please provide your last name");
		theForm.lname.focus();
		return false;
		} 
	if (Firm =="") {
		alert("Please provide the name of your firm");
		theForm.firm.focus();
		return false;
		} 
	if (Phone =="") {
		alert("Please provide a daytime phone number");
		theForm.phone.focus();
		return false;
		} 				
	if (Email =="") {
		alert("Please provide an email address");
		theForm.email.focus();
		return false;
		}
		
		
	if (Project =="") {
		alert("Please provide the project for which this meeting is associated");
		theForm.project.focus();
		return false;
		}
	if (Date =="") {
		alert("Please provide the date(s) of your meeting");
		theForm.date.focus();
		return false;
		}
	if (Location =="") {
		alert("Please provide the location of your meeting");
		theForm.location.focus();
		return false;
		}
		
	if (Travel =="") {
		alert("Please provide estimated expense for round-trip air or rail travel");
		theForm.travel.focus();
		return false;
		}
	if (Hotel =="") {
		alert("Please provide the estimated expense for the hotel where you will be staying");
		theForm.hotel.focus();
		return false;
		}
	if (Nights =="") {
		alert("Please provide the number of nights you will be staying");
		theForm.nights.focus();
		return false;
		}
	if (Reimbursement =="") {
		alert("Please provide the percentage of reimursement you are requesting (keeping in mind that the maximum reimursement is 80% of actual and reasonable transportation and hotel expenses)");
		theForm.reimbursement.focus();
		return false;
		}
		

//checks if value is syntactically NOT a valid email address 
function notValidEmail( str ){
    mailRE = new RegExp( );
    mailRE.compile( '^[\._a-z0-9-]+@[\.a-z0-9-]+[\.]{1}[a-z]{2,4}$', 'gi' );
    return !(mailRE.test( str.value ));
} 


//checks if Email is valid
    if( notValidEmail( theForm.email ) ){
        alert( 'Please enter a valid email address' );
		theForm.email.focus();
        return false;
    	}
		
//checks if Phone and Zip are numeric inputs		
		
function IsNumeric(sText)	{
   	var ValidChars = "0123456789-";
   	var IsNumber=true;
   	var Char;
		
		for (i = 0; i < sText.length && IsNumber == true; i++) { 
      	Char = sText.charAt(i); 
      	if (ValidChars.indexOf(Char) == -1) {
         	IsNumber = false;
         	}
      	}
   		return IsNumber;
		}

//checks if Phone is valid   
 	if (!IsNumeric(theForm.phone.value)) 
   		{ 
      	alert('Please enter your phone number in the following format: 000-000-0000') 
      	theForm.phone.focus(); 
      	return false; 
      	} 

		
		
	
// if all of the above criteria is satisfied, return True

return true;
}



