// JavaScript Document
function validate_submit_floorplan()
{
	var digits = /^[0-9]*(\.)?[0-9]+$/;
	
	var errors = "";
	
	if ( ! digits.test(document.floorplanForm.NumBeds.value) ) {
		errors = errors + "Bedrooms must be a number\n";
	}
	if ( ! digits.test(document.floorplanForm.Garage.value) ) {
		errors = errors + "Garage must be a number\n";
	}
	if ( ! digits.test(document.floorplanForm.NumBaths.value) ) {
		errors = errors + "Baths must be a number\n";
	}
	if ( ! digits.test(document.floorplanForm.PriceRange.value) ) {
		errors = errors + "Price must be a number (do not include commas)\n";
	}

	if (errors == "") {
		document.floorplanForm.submit();
	} else {
		errors = "Please correct the following errors:\n\n" + errors;
		alert(errors);
	}
}

function validate_submit_floorplanelevation()
{
	var digits = /^[0-9]*(\.)?[0-9]+$/;
	
	var errors = "";
	
	if ( ! digits.test(document.floorplanForm.SquareFootage.value) ) {
		errors = errors + "Square Footage must be a number (do not include commas)\n";
	}
	
	if (errors == "") {
		document.floorplanForm.submit();
	} else {
		errors = "Please correct the following errors:\n\n" + errors;
		alert(errors);
	}
}

function validate_submit_home()
{	
	var digits = /^[0-9]*(\.)?[0-9]+$/;
	
	var errors = "";
	
	if ( ! digits.test(document.homeForm.NumBeds.value) ) {
		errors = errors + "Bedrooms must be a number\n";
	}
	if ( ! digits.test(document.homeForm.NumBaths.value) ) {
		errors = errors + "Baths must be a number\n";
	}
	if ( ! digits.test(document.homeForm.Price.value) ) {
		errors = errors + "Price must be a number (do not include commas)\n";
	}

	if (errors == "") {
		document.homeForm.submit();
	} else {
		errors = "Please correct the following errors:\n\n" + errors;
		alert(errors);
	}
}

function validate_submit_contactus()
{
	var errors = "";
	
	if ( document.contactusForm.name.value == "" )
	{	
		errors = errors + "Please enter your Name\n";
	}

	if ( document.contactusForm.email.value != document.contactusForm.email2.value )
	{
		errors = errors + "Emails must match\n";
	}
	
	var EmailRegExp="^[a-zA-Z0-9\-\_\.]+\@[a-zA-Z0-9\-\_\.]+\.([a-zA-z]{2,3}|[0-9]{1,3})$";
    var EmailCheck = new RegExp(EmailRegExp);
   // check email string against the reg exp format - this is the REVERSE so check with a ! (negative)
    if(!EmailCheck.test(document.contactusForm.email.value)) {
        errors = errors + "Please insert an email address in the form user@example.com";
    }
	
	if (errors == "") {
		document.contactusForm.submit();
	} else {
		errors = "Please correct the following errors:\n\n" + errors;
		alert(errors);
	}
}

function validate_submit_warranty()
{
	var errors = "";

	var EmailRegExp="^[a-zA-Z0-9\-\_\.]+\@[a-zA-Z0-9\-\_\.]+\.([a-zA-z]{2,3}|[0-9]{1,3})$";
    var EmailCheck = new RegExp(EmailRegExp);
   // check email string against the reg exp format - this is the REVERSE so check with a ! (negative)
    if(!EmailCheck.test(document.warrantyForm.email.value)) {
        errors = errors + "Please insert an email address in the form user@example.com";
    }
	
	if (errors == "") {
		document.warrantyForm.submit();
	} else {
		errors = "Please correct the following errors:\n\n" + errors;
		alert(errors);
	}
}