// JavaScript Document

function validateForm(form)
{ 	
	
	var fullname = form.fullname.value; 
	var age = form.age.value;
	var childname = form.childname.value;
	var partydate = form.partydate.value;
	var email = form.email.value;
	var phone = form.phone.value;
	
	//alert(phone);
	
	
	
	if(partydate == "")
	{ 
		
		alert("Please choose the Party Date."); 
		form.partydate.focus(); 
		return false; 
		
	}
	
	if(childname == "")
	{ 
		
		alert("Please enter the Birthday Child's name."); 
		form.childname.focus(); 
		return false; 
		
	}
	
	if(age == "")
 	{ 
		
		alert("Please enter your the Birthday Child's age.");
		form.age.focus(); 
		return false; 
		
	}
	
	if(fullname == "")
	{ 
		
		alert("Please enter your name."); 
		form.fullname.focus(); 
		return false; 
		
	}
	
	if(email == "")
	{ 
		alert("Please enter your email.");
		form.email.focus(); 
		return false; 
			
	}
	if(email != "")
	{
		var okEmail = form.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		if (okEmail)
		{
			ok = true;
		} 
		else 
		{
		   alert("Please enter a valid email address.");
		   form.email.focus();
		   form.email.select();
		   ok = false;
		   return false;
		}  
	}
	if(phone == "") 
	{ 
		alert("Please enter a Contact Phone Number.");
		form.phone.focus();
		form.phone.select();
		return false;
	}
	if(phone != "")
	{
		//alert("Please enter your phone.");
		//phonechar = phone.charAt(0); 
		//alert(phonechar);
		if(phone.length < 7)
		{ 
			alert("Please enter your phone number in the following format. 555-1111"); 
			form.phone.focus(); 
			return false; 
		}
					
		for(var i = 0; i != phone.length; i++)
		{
			var phonechar = phone.substring(i, i + 1); 
			//alert(phonechar); 
			//
			if(phonechar < "0" || phonechar > "9" )
			{ 
				if (phonechar != "(" && phonechar != " " && phonechar != ")" && phonechar != "-")
				{
					//alert(phonechar); 
					alert("Please enter your phone number in the following format. 555-1111"); 
					form.phone.focus(); 
					return false; 
				}
			}
			//)
		}
			
	}
	
}
