function validate()
{
	return doValidate(new Array("last_name","first_name" ,"company" ,"email","confirm_email", "zip" ,"country"));
}

function doValidate(inputFields)
{
	var counter;
	var name;

	var msg = "Please complete the following fields:\n";
	var badFields = "";


		var sel = document.getElementById("00N0000000730MM");
		if (sel!=null)
		{
			if (sel.selectedIndex == 0) 
			{
				badFields = badFields + "  - Region\n"			
			}
		}

		for (counter = 0; counter < inputFields.length; counter++) {
			name = inputFields[counter];
			if (document.form.elements[name] != null)
			{
				if (document.form.elements[name].value.length == 0) 
				{
					badFields = badFields + "  - " + name + "\n"			
				}
			}
		}

	var nameMatch = /^[a-zA-Z ,.]*$/
	var companyMatch = /^[a-zA-Z0-9\-,. ]*$/
	var emailMatch = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/
	if(document.getElementById("first_name")!=null)
	{
		if(!nameMatch.test(document.getElementById("first_name").value))
			badFields = badFields + "  - Invalid First Name\n"; 
	}

	if(document.getElementById("last_name")!=null)
	{
		if(!nameMatch.test(document.getElementById("last_name").value))
			badFields = badFields + "  - Invalid Last Name\n"; 
	}

	if(document.getElementById("company")!=null)
	{
		if(!companyMatch.test(document.getElementById("company").value))
			badFields = badFields + "  - Invalid Company Name\n"; 
	}

	var eml = document.getElementById("email")
	if(eml!=null)
	{
		if(!emailMatch.test(eml.value))
			badFields = badFields + "  - Invalid E-Mail Address\n"; 
	}


	var ce = document.getElementById("confirm_email");
	if (ce!=null)
	{
		if (ce.value != eml.value) 
		{
			badFields = badFields + "  - Email Addresses Do Not Match\n"
		}
	}

	if (badFields.length != 0) 
	{
		alert(msg + badFields);
		return false;
	}

	var ref = document.getElementById("00N000000072yyJ");
	if (ref!=null) ref.value=document.referrer;

	return true;	
}

function validateAndSubmit() 
{
	if (validate()) 
	{
		document.form.submit();
	}
	return false;
}	

function validateAndSubmit2(inputfields) 
{
	if (doValidate(inputfields)) 
	{
		document.form.submit();
	}
	return false;
}	
