function validEmail(email) {

	invalidChars = " /:,;"

	if (email == "") {
		return false
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}
	if (periodPos+3 > email.length)	{
		return false
	}
	return true
}

function passwordsMatch(){
	if(document.subsForm.password.value != document.subsForm.password_conf.value){
		alert("Passwords do not match.");
	return false;
	} else {
	return true; }
	
}
function submitIt(subsForm) {
	if (!validEmail(document.subsForm.email.value))
		{
			alert("Invalid email address")
			//document.subsForm.email.focus();
			//document.subsForm.email.select();
			return false
		}
	

	if(!document.subsForm.state.selectedIndex || document.subsForm.state.options[document.subsForm.state.selectedIndex] == ""){
		alert("Please select your State/Province.");
	return false
	}
	
	if(!document.subsForm.locationnumber.selectedIndex || document.subsForm.locationnumber.value == ""){
		alert("Please select the Brunswick Bowling and Entertainment Center location you are most likely to visit.");
	return false
	}
	
	if (document.subsForm.howdidyouhear.type == "hidden"){
		if(document.subsForm.howdidyouhear.value == ""){
			alert("Please indicate you heard about the Brunswick Bonus Zone.");
		return false
		}
	}
	else{
		if(!document.subsForm.howdidyouhear.selectedIndex || document.subsForm.howdidyouhear.options[document.subsForm.howdidyouhear.selectedIndex] == ""){
			alert("Please indicate you heard about the Brunswick Bonus Zone.");
		return false
		}
	}	
	
	if(!passwordsMatch()){
		alert("Passwords do not match.");
		return false;
	
	}
	
	

	// check for areas of interest
	/*var checkbox_choices = 0;
	var checkbox_names = new Array("bowling","billiards","arcadegames","lasertag","offersforkids","leagueinformation","corporatefunctions","groupeventsandparties");
		// Loop from zero to the one minus the number of checkbox button selections
	for (i = 0; i < checkbox_names.length; i++) {
		{	
			temp="document.subsForm."+checkbox_names[i]+".checked";
//			alert(eval(temp));
//			return false;
			//loop for each of the checkboxes above
			if (eval(temp))
					{ 
						checkbox_choices = checkbox_choices + 1; 
						break;
					}
				}
				
			}
		
	
	
	//checkbox_choices = 0;
	
	if (checkbox_choices <= 0) {
			alert("Please indicate the type of information you are interested in receiving.");
			return false;	
		}*/
	
				
	if(document.subsForm.birthmonth.value > 12 || document.subsForm.birthmonth.value==""){
		alert("Please enter a valid Birth Month.");
		return false;
	}
	
	if(document.subsForm.birthyear.value < 1900 || document.subsForm.birthyear.value==""){
		alert("Please enter a valid Birth Year. Note: You must be over 13.");
		return false;
	}
	
	//Must be 13 years of age to signup
	var date = new Date();
	if ((date.getFullYear() - document.subsForm.birthyear.value) < 13){
		if ((date.getFullYear() - document.subsForm.birthyear.value) == 12){
			if (date.getMonth()+1 > document.subsForm.birthmonth.value){
				alert("Please enter a valid Birth Year. Note: You must be over 13.");
				return false;
			}
		}
		else{
			alert("Please enter a valid Birth Year. Note: You must be over 13.");
			return false;
		}
	}

	//child1
	if(document.subsForm.child1name.value != ""){
		if (document.subsForm.child1birthdaymonth.value==""){			
			alert("Please enter a valid Child 1 Birth Month.");
			document.subsForm.child1birthdaymonth.focus();
			return false;
		}
		if (document.subsForm.child1birthdayyear.value==""){
			alert("Please enter a valid Child 1 Birth Year.");
			document.subsForm.child1birthdayyear.focus();
			return false;
		}		
	}
	else{
		if (document.subsForm.child1birthdaymonth.value!=""){			
			alert("Please enter a valid Child 1 First Name.");
			document.subsForm.child1name.focus();
			return false;
		}
		if (document.subsForm.child1birthdayyear.value!=""){
			alert("Please enter a valid Child 1 First Name.");
			document.subsForm.child1name.focus();
			return false;
		}	
	}
	
	//child2
	if(document.subsForm.child2name.value != ""){
		if (document.subsForm.child2birthdaymonth.value==""){			
			alert("Please enter a valid Child 2 Birth Month.");
			document.subsForm.child2birthdaymonth.focus();
			return false;
		}
		if (document.subsForm.child2birthdayyear.value==""){
			alert("Please enter a valid Child 2 Birth Year.");
			document.subsForm.child2birthdayyear.focus();
			return false;
		}		
	}
	else{
		if (document.subsForm.child2birthdaymonth.value!=""){			
			alert("Please enter a valid Child 2 First Name.");
			document.subsForm.child2name.focus();
			return false;
		}
		if (document.subsForm.child2birthdayyear.value!=""){
			alert("Please enter a valid Child 2 First Name.");
			document.subsForm.child2name.focus();
			return false;
		}	
	}
	
	//child3
	if(document.subsForm.child3name.value != ""){
		if (document.subsForm.child3birthdaymonth.value==""){			
			alert("Please enter a valid Child 3 Birth Month.");
			document.subsForm.child3birthdaymonth.focus();
			return false;
		}
		if (document.subsForm.child3birthdayyear.value==""){
			alert("Please enter a valid Child 3 Birth Year.");
			document.subsForm.child3birthdayyear.focus();
			return false;
		}		
	}
	else{
		if (document.subsForm.child3birthdaymonth.value!=""){			
			alert("Please enter a valid Child 3 First Name.");
			document.subsForm.child3name.focus();
			return false;
		}
		if (document.subsForm.child3birthdayyear.value!=""){
			alert("Please enter a valid Child 3 First Name.");
			document.subsForm.child3name.focus();
			return false;
		}	
	}
	
	//child4
	if(document.subsForm.child4name.value != ""){
		if (document.subsForm.child4birthdaymonth.value==""){			
			alert("Please enter a valid Child 4 Birth Month.");
			document.subsForm.child4birthdaymonth.focus();
			return false;
		}
		if (document.subsForm.child4birthdayyear.value==""){
			alert("Please enter a valid Child 4 Birth Year.");
			document.subsForm.child4birthdayyear.focus();
			return false;
		}		
	}
	else{
		if (document.subsForm.child4birthdaymonth.value!=""){			
			alert("Please enter a valid Child 4 First Name.");
			document.subsForm.child4name.focus();
			return false;
		}
		if (document.subsForm.child4birthdayyear.value!=""){
			alert("Please enter a valid Child 4 First Name.");
			document.subsForm.child4name.focus();
			return false;
		}	
	}
	
	//child5
	if(document.subsForm.child5name.value != ""){
		if (document.subsForm.child5birthdaymonth.value==""){			
			alert("Please enter a valid Child 5 Birth Month.");
			document.subsForm.child5birthdaymonth.focus();
			return false;
		}
		if (document.subsForm.child5birthdayyear.value==""){
			alert("Please enter a valid Child 5 Birth Year.");
			document.subsForm.child5birthdayyear.focus();
			return false;
		}		
	}
	else{
		if (document.subsForm.child5birthdaymonth.value!=""){			
			alert("Please enter a valid Child 5 First Name.");
			document.subsForm.child5name.focus();
			return false;
		}
		if (document.subsForm.child5birthdayyear.value!=""){
			alert("Please enter a valid Child 5 First Name.");
			document.subsForm.child5name.focus();
			return false;
		}	
	}
	
	var pref = "";
	var reqfields = new Array();
	
		for(i=0; i < reqfields.length;i++)
			{
				tempfield = "document.subsForm."+pref+reqfields[i]+".value";
				tempid = "document.subsForm."+pref+reqfields[i]+".id";
				tempval = eval(tempfield);
				tempid = eval(tempid);
				
				if(tempval=="")
					{
						alert("Please provide a "+tempid+".");
						return false;
					}
		}
	document.subsForm.Submit.disabled = true;
	return true
}

function selectValue(theBox,theValue) {

		/*
		implement simple function to select a value of a given select box
		*/
		var a = theBox; 
		//		alert(a.options.length+" optionslen");
//alert("LOOKING FOR    "+ theValue);
		for(i=0;i< a.options.length;i++){
			
			b=a.options[i];
		//	alert(b.value+" value found");
			if(b.value==theValue){
				
				a.options.selectedIndex=i;
				break;
			}
		}
	}
	

