function validatePage()
{ // function will validate form pages win/loss and club app for required fields. 
// loads error messages into string and send the alert

	var strAlert = "";
	
	if (document.getElementById('firstname').value == "")
	{
		strAlert = "- First name is required.\n"
	}
	if (document.getElementById('lastname').value == "")
	{
		strAlert = strAlert + "- Last name is required.\n"
	}
	if (document.getElementById('address').value == "")
	{
		strAlert = strAlert + "- Address is required.\n"
	}
	if (document.getElementById('city').value == "")
	{
		strAlert = strAlert + "- City is required.\n"
	}
	if (document.getElementById('state').value == "")
	{
		strAlert = strAlert + "- State is required.\n"
	}
	if (document.getElementById('zip').value == "")
	{
		strAlert = strAlert + "- Zipcode is required.\n"
	}
	if (document.getElementById('MemNum') != null) //this is the Win/Loss Page
	{
		if (document.getElementById('MemNum').value == "")
		{
			strAlert = strAlert + "- Member # is required.\n"
		}
	}
	//if this is the Contact us form this textbox does not exist
	if (document.getElementById('dob') != undefined) 
	{
		if (document.getElementById('dob').value == "")
		{
			strAlert = strAlert + "- Date of Birth is required.\n"
		}
	}
	if (strAlert == "")
		return true;
	else
	{
		alert(strAlert);
		return false;
	}
}

function ValidatePhone(unformattedPhone,control)
	{
		var formattedPhone="";
		var index = 0;
		var MaxCheck;
		var nothing = "";
		
		if(unformattedPhone.length > 0)
		{
			MaxCheck = unformattedPhone.length;
			while (index != MaxCheck)
			{
				if (isNaN(parseInt(unformattedPhone.charAt(index))))
				{ }
				else
				{ formattedPhone = formattedPhone + unformattedPhone.charAt(index); }
				index = index + 1;
			}
			if (formattedPhone.length == 10)
			{
				formattedPhone = formattedPhone.substring(0,3) + "-" + formattedPhone.substring(3,6) + "-" + formattedPhone.substring(6,10);
			}
			else
			{
				formattedPhone=unformattedPhone;
			}
			return formattedPhone;
		}
		else
		{
			return nothing;
		}
  }