// JavaScript Document

window.onload = function()
{
	//alert("loaded");
}

function formValidate(form)
{
	var securityValidate = MPFSCheckStatus();
	var name = form.Full_Name.value;
	var phone = form.Daytime_Phone.value;
	var address = form.Address.value;
	var city = form.City.value;
	var remodeling = form.Remodeling_on.value;
	var email = form.Email.value;
	var emailValidate = validateEmail(email);
	if (!securityValidate ||
		(name == "" || name == "Type your first and last name here") ||
		phone == "" ||
		(address == "" || address == "Type your address here") ||
		(city == "" || city == "Type your city here") ||
		(remodeling == "" || remodeling == "please select from the list") ||
		!emailValidate)
	{
		var errorString = "There were errors in your form :\n\n";
		if (!securityValidate)
		{
			errorString += "- Incorrect security code entered\n";
		}
		if (name == "" || name == "Type your first and last name here")
		{
			errorString += "- No name provided\n";
		}
		if (phone == "")
		{
			errorString += "- No phone number provided\n";
		}
		if (address == "" || address == "Type your address here")
		{
			errorString += "- No address provided\n";
		}
		if (city == "" || city == "Type your city here")
		{
			errorString += "- No city provided\n";
		}
		if (remodeling == "" || remodeling == "please select from the list")
		{
			errorString += "- No remodeling type provided\n";
		}
		if (!emailValidate)
		{
			errorString += "- Invalid email entered\n";
		}
		window.alert(errorString);
	}
	else
	{
		//take form action
	}
	
}

function validateEmail(s)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var valid = reg.test(s) == false ? false : true;
	return valid;
}

function validateForm()
{
	if (document.contactForm.Full_Name.value == "" || document.contactForm.Full_Name.value == "Type your first and last name here")
	{
		alert("Please type in your full name");
		document.contactForm.Full_Name.focus();
		return false;
	}
	else if (document.contactForm.Email.value == "" || document.contactForm.Email.value == "Type your email address here")
	{
		alert("Please type in your email address");
		document.contactForm.Email.focus();
		return false;
	}
	//else if (document.contactForm.Daytime_Phone.value.length < 10)
	else if (document.contactForm.Daytime_Phone.value == "")
	{
		alert("Please type in a full daytime phone number including area code (ie : 847-555-5555)");
		document.contactForm.Daytime_Phone.focus();
		return false;
	}
	else if (document.contactForm.Address.value == "" || document.contactForm.Address.value == "Type your address here")
	{
		alert("Please type in the address where the desired work is to be done");
		document.contactForm.Address.focus();
		return false;
	}
	else if (document.contactForm.City.value == "" || document.contactForm.City.value == "Type your city here")
	{
		alert("Please type in the city where the desired work is to be done");
		document.contactForm.City.focus();
		return false;
	}
	else if (document.contactForm.Remodeling_on.value == "please select from the list")
	{
		alert("Please choose the type of remodeling from the list");
		document.contactForm.Remodeling_on.focus();
		return false;
	}
	else
	{
		//alert("List selection = " + document.contactForm.Remodeling_on.value);
		return true;
		//document.window.navigate("http://iamjj.com/testsites/samanco/thank_you.html");
	}
}

function nameMouseClick()
{
	document.contactForm.Full_Name.select();
}

function emailMouseClick()
{
	document.contactForm.Email.select();
}

function dayPhoneMouseClick()
{
	document.contactForm.Daytime_Phone.select();
}

function nightPhoneMouseClick()
{
	document.contactForm.Evening_Phone.select();
}

function cityMouseClick()
{
	document.contactForm.City.select();
}

function addressMouseClick()
{
	document.contactForm.Address.select();
}

