function validate_required(field,alerttxt)
{
	if (field.value.length === 0)
	{
		alert(alerttxt);
		return false;
	}
	else {return true;}
}

function validate_email(field,alerttxt)
{
	var apos = field.value.indexOf("@");
	var dotpos = field.value.lastIndexOf(".");
	if (apos < 1 || dotpos - apos < 2)
	{
		alert(alerttxt);
		return false;
	}
	else {return true;}
}

function validate_form()
{
	var theform = document.getElementById('survey_1661');
	if (validate_required(theform.cons_first_name,"First name is required.") === false)
	{
		theform.cons_first_name.style.backgroundColor = '#ffff00';
		theform.cons_first_name.focus();
		return false;
	}
	if (validate_required(theform.cons_last_name,"Last name is required.") === false)
	{
		theform.cons_last_name.style.backgroundColor = '#ffff00';
		theform.cons_last_name.focus();
		return false;
	}
	if (validate_required(theform.cons_email,"Email is required.") === false)
	{
		theform.cons_email.style.backgroundColor = '#ffff00';
		theform.cons_last_name.focus();
		return false;
	}
	if (validate_email(theform.cons_email,"Email is invalid.") === false)
	{
		theform.cons_email.style.backgroundColor = '#ffff00';
		theform.cons_last_name.focus();
		return false;
	}
	//success!
	//swapbox('http://www.civilwar.org/assets/member-center/registration-thank-you.html');
}