// JavaScript Document

function validate_required(field,alerttxt)
{
	with (field)
	{
		if (value==null||value=="")
  		{
			alert(alerttxt);return false
		}
		else
		{
			return true
		}
	}
}

function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_required(applicantsname,"Principal Applicant's Name must be filled out.")==false)
  		{
			applicantsname.focus();return false
		}
		if (validate_required(address,"Address must be filled out.")==false)
  		{
			address.focus();return false
		}
		if (validate_required(city,"City must be filled out.")==false)
		{
			city.focus();return false
		}
		if (validate_required(state,"State/Province must be filled out.")==false)
		{
			state.focus();return false
		}
		if (validate_required(zip,"Zip Code must be filled out.")==false)
		{
			zip.focus();return false
		}
		if (validate_required(phone,"Phone must be filled out.")==false)
		{
			homephone.focus();return false
		}
	}
	return checkEmail(thisform);
	return checkCheckBoxes(thisform);
}

function checkCheckBoxes(theForm)
{
	if (theForm.creditreport.checked == false)
	{
		alert ('You cannot submit the application unless you allow Girl Boutique to do a credit check');
		applicationform.creditreport.focus();
		return false;
	}
	else if (theForm.finalize.checked == false)
	{
		alert ('You cannot submit the application unless you agree to the application statement');
		applicationform.finalize.focus();
		return false;
	}
	else 
	{
		return true;
	}
}

function checkEmail(myForm)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value))
	{
		return (true)
	}
	alert("Invalid E-mail Address! Please re-enter.")
	myForm.email.focus();
	return (false)
}
