function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value)){
return (true)
}
alert("Email Address is formatted incorrectly.")
return (false)
}


function Validator(theForm)
{
  var error = "";
  
  if (theForm.name.value == "")
  {
    error += "Full Name is required.\n";
  } 
    
  if (!(validEmail(theForm.email.value)))
  {
    error += "Email address is required.\n";
  }

  if (theForm.zip.value == "")
  {
    error += "Zip is required.\n";
  }
  
   if (theForm.state.options[0].selected == true)
 {
   error += "State is required.\n";
 }
  
  if (theForm.homephone.value == "")
  {
    error += "Home Phone is required.\n";
  }
  
  

  
  if (theForm.timetocall.value == "")
  {
    error += "Best Time to Call is required.\n";
  } 
 
  //if (theForm.aftertaxincome.value == "")
  //{
  //  error += "After Tax Income is required.\n";
  //}
  
   if (theForm.totalccdebt.value == "")
  {
    error += "Total Credit Card Debt is required.\n";
  }
  
  if (theForm.totalexpenses.value == "")
  {
    error += "Total Monthly Expenses is required.\n";
  } 
  
 
  // validate radio buttons
	myOption = -1;
	for (i=theForm.living_status.length-1; i > -1; i--) {
	if (theForm.living_status[i].checked) {
	myOption = i;
	}
	}
	if (myOption == -1) {
	alert("Living Status is required.");
	return false;
	}
	
  if (error != "")
  {
    alert(error);
    return (false);
  } else {
    return (true);
  } 
}

function getElementIndex(obj) 
				{
					var theform = obj.form;
					for (var i=0; i<theform.elements.length; i++) {
						if (obj.name == theform.elements[i].name) {
							return i;
							}
					}
					return -1;
				}

				var isIE = document.all?true:false;
				var isNS = document.layers?true:false;
	
function onlyCurrency(e) {
		var acceptChars = "0123456789,.$";
		var strKey;
		var _ret = true;
		if (isIE)
			{
			strKey = String.fromCharCode(window.event.keyCode)
			}
		else 
			{
			strKey = String.fromCharCode(e.which)
			}
		
		if (acceptChars.indexOf(strKey) < 0)
			_ret = false;
		return (_ret);
	}
	
function onlyPhone(e) {
		var acceptChars = "0123456789.-";
		var strKey;
		var _ret = true;
		if (isIE)
			{
			strKey = String.fromCharCode(window.event.keyCode)
			}
		else 
			{
			strKey = String.fromCharCode(e.which)
			}
		
		if (acceptChars.indexOf(strKey) < 0)
			_ret = false;
		return (_ret);
	}

function validEmail(str){
	//alert('validEmail()');
	var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(filter.test(str)){
		return true;
	}else{
		return false;
	}
}