// JavaScript Document


///Auto Formats Phone Number

function validate_form()
{
	if (document.hub.terms.checked == true)
	{
	var canSubmit = true;
	var toAlert = "The Following Fields are missing:\n";
	
			if (document.hub.name.value == '')
			{
					toAlert += "Corporation / partnership / sole proprietorship name\n";
					canSubmit = false;									
			}
		
		

	
		if (document.hub.address.value == '')
		{
			toAlert += "Address\n";
			canSubmit = false;
			
		}
		
		if (document.hub.city.value == '')
		{
			toAlert += "City\n";
			canSubmit = false;
		}
		if (document.hub.country.value == '')
		{
			toAlert += "Country\n";
			canSubmit = false;
		}
		
		if (document.hub.telephone.value == '')
		{
			toAlert += "Telephone Number\n";
			canSubmit = false;
		}
		if (document.hub.authContact.value == '')
		{
			toAlert += "Authorized Contact\n";
			canSubmit = false;
		}
		if (document.hub.contactTitle.value == '')
		{
			toAlert += "Contact Title\n";
			canSubmit = false;
		}		
		if (document.hub.email.value == '')
		{
				toAlert += "Email\n";
				canSubmit = false;
		} else {
			// Confirms Email is correctly entered
				var apos=document.getElementsByName('email')[0].value.indexOf("@");
				var dotpos=document.getElementsByName('email')[0].value.lastIndexOf(".");
				if (apos<1||dotpos-apos<2) {
					toAlert += "Email is present but not valid\n";
					canSubmit = false;
				}
		}
		
		if ((document.hub.dollarRange1.checked == false) && (document.hub.dollarRange2.checked == false) && (document.hub.dollarRange3.checked == false))
		{	
			toAlert += "Dollar range of investment\n";
			canSubmit = false;
		}

			
			
			///////
		var letter = '';	

		
		


				
		
		
		////////
	
		if (canSubmit == false)
		{
			alert (toAlert);
			return false;
		} else {
			if (confirm('Please make sure that all the information you have entered is correct as you will not have a chance to change it after this point. \n\n If you would like to review the information you have entered, click "Cancel".'))
			{
				return true;
			} else {
				return false;
			}
			
		}
		
	} else {
		alert('Please read over the Terms and Conditions on the right before submiting');
		return false;
	}
		
		
}

