function strTrim(tmpStr)
{
	tmpStr = tmpStr.replace(/^\s+/,"");//remove leading
	tmpStr = tmpStr.replace(/\s+$/,"");//remove trailing
	return tmpStr;
}
//-------------------------------------------------------------------------
function trimFields()
{
	for(var i=0; i < obj.elements.length; i++)
	{
		if(obj.elements[i].type == "text" || obj.elements[i].type == "textarea" || obj.elements[i].type == "password")
		{
			obj.elements[i].value = strTrim(obj.elements[i].value);
		}
	}
}
//-------------------------------------------------------------------------
function chkZip(tmpStr)
{
	var zip_pat = /^[0-9]{5,5}$/gi;
	return(zip_pat.test(tmpStr));
}
//-------------------------------------------------------------------------
function chkEmail(tmpStr)
{
	var email_pat = /^[a-z][a-z0-9_\.\-]*[a-z0-9]@[a-z0-9]+[a-z0-9\.\-_]*\.[a-z]+$/gi;
	return(email_pat.test(tmpStr));
}
//-------------------------------------------------------------------------
function validateForm()
{
	trimFields();
	if(obj.firstname.value == "")
	{
		alert("Please enter your First Name.");
		obj.firstname.focus();
		return;
	}
	if(obj.lastname.value == "")
	{
		alert("Please enter your Last Name.");
		obj.lastname.focus();
		return;
	}
	if(obj.city.value == "")
	{
		alert("Please enter the City.");
		obj.city.focus();
		return;
	}
	if(obj.state.selectedIndex == 0)
	{
		alert("Please select the State.");
		obj.state.focus();
		return;
	}
	if(obj.zip.value == "")
	{
		alert("Please enter the Zip Code.");
		obj.zip.focus();
		return;
	}
	if(!chkZip(obj.zip.value))
	{
		alert("Please enter a valid Zip Code.");
		obj.zip.focus();
		obj.zip.select();
		return;
	}
	if(obj.email.value == "")
	{
		alert("Please enter your Email Address.");
		obj.email.focus();
		return;
	}
	if(!chkEmail(obj.email.value))
	{
		alert("Please enter a valid Email Address.");
		obj.email.focus();
		obj.email.select();
		return;
	}
	if(obj.phone.value == "")
	{
		alert("Please enter the Phone Number.");
		obj.phone.focus();
		return;
	}
	//Everything fine?
	obj.action = 'sendmail.php?opt=advisor';
	obj.submit();
}
