	function genValid(theForm) 
	{
		// Validations
		var moreinfo = "You should provide as much information as possible\n" +
			           "to receive the most acccurate response.";
         
		// loan amount
		if ( check_valid_money(theForm.add_fd0) == false)
		{
			alert( "Please enter a valid monetary amount for loan amount.\n" + moreinfo );
			theForm.add_fd0.focus();
			return false;
		}
		
		// loan amount minimum value
		if (theForm.add_fd0.value < 250000)
		{
			alert ( "Loan Amount minimum is $250,000.\n" + moreinfo );
			theForm.add_fd0.focus();
			return false;
		}

		// property value
		if ( check_valid_money(theForm.add_fd1) == false)
		{
			alert( "Please enter a valid monetary amount for property value.\n" + moreinfo );
			theForm.add_fd1.focus();
			return false;
		}

		// LTV [Loan To Value]
		if (check_LTV(theForm.add_fd0.value,theForm.add_fd1.value) == false)
		{
			theForm.add_fd1.focus();
			return false;
		}
		
		// Purchase Price
			if ( check_valid_money(theForm.add_fd6) == false)
			{
				alert( "Please enter a valid monetary amount for the purchase price.\n" + moreinfo );
				theForm.add_fd6.focus();
				return false;
		}
		// Brokers Name
		if (check_valid_name(theForm.add_fd8) == false )
		{
			alert( "Please enter the Brokers Name.\n" + moreinfo );
			theForm.add_fd8.focus();		
			return false;
		}
		// Brokers Street
		//	if (check_valid_name(theForm.add_fd9) == false )
		//	{
		//		alert( "Please enter the Brokers Street.\n" + moreinfo );
		//		theForm.add_fd9.focus();		
		//		return false;
		//}
		
		// Brokers City
			if (check_valid_name(theForm.add_fd10) == false )
			{
				alert( "Please enter the Brokers City.\n" + moreinfo );
				theForm.add_fd10.focus();		
						return false;
		}
		// Broker state/region
		if ( theForm.add_fd11.type == "select-one")
		{
			if ( theForm.add_fd11.selectedIndex==0 )
			{
				alert( "Please select Brokers state.\n" + moreinfo );
				theForm.add_fd11.focus();		
				return false;
			}		
		}
		// Brokers Zip Code
			if (check_valid_zipcode(theForm.add_fd12) == false )
			{
				alert( "Please enter the Brokers Zip Code.\n" + moreinfo );
				theForm.add_fd12.focus();		
				return false;
		}
		// borrowers first name
		if (check_valid_name(theForm.add_fd13) == false )
		{
			alert( "Please enter borrower's first name.\n" + moreinfo );
			theForm.add_fd13.focus();		
			return false;
		}

		// borrowers last name
		if (check_valid_name(theForm.add_fd14) == false )
		{
			alert( "Please enter borrower's last name.\n" + moreinfo );
			theForm.add_fd14.focus();		
			return false;
		}
		// Brokers Email Address
		if ( isEmail(theForm.add_fd16.value) == false )
		{
			alert( "Please enter a valid Email Address.\n" + moreinfo );			       
			theForm.add_fd16.focus();		
			return false;
		}		
		// Borrowers Street
		//	if (check_valid_name(theForm.add_fd17) == false )
		//	{
		//		alert( "Please enter the Borrowers Street.\n" + moreinfo );
		//		theForm.add_fd17.focus();		
		//		return false;
		//}
		
		// Borrowers City
			if (check_valid_name(theForm.add_fd18) == false )
			{
				alert( "Please enter the Borrowers City.\n" + moreinfo );
				theForm.add_fd18.focus();		
		}
		// Borrower property state/region
		if ( theForm.add_fd19.type == "select-one")
		{
			if ( theForm.add_fd19.selectedIndex==0 )
			{
				alert( "Please select Borrowers state.\n" + moreinfo );
				theForm.add_fd19.focus();		
				return false;
			}		
		}	
		// Borrowers Zip Code
			if (check_valid_zipcode(theForm.add_fd20) == false )
			{
				alert( "Please enter the Borrowers Zip Code.\n" + moreinfo );
				theForm.add_fd20.focus();		
				return false;
		}

		// need at least one of the brokers telephone numbers
		if (((theForm.add_fd21.value=="") || (theForm.add_fd22.value=="") || (theForm.add_fd23.value==""))
		  &&((theForm.add_fd24.value=="") || (theForm.add_fd25.value=="") || (theForm.add_fd26.value=="")))
		{
			alert( "Please enter either the broker's complete work or cell phone number.\n" + moreinfo );
			theForm.add_fd21.focus();		
			return false;		
		}

		// phone fields numeric values and length
		var t1 = theForm.add_fd21.value + theForm.add_fd22.value + theForm.add_fd23.value;
		var t2 = theForm.add_fd24.value + theForm.add_fd25.value + theForm.add_fd26.value;
		if (!(t1==""))
		{
			if ((check_numeric(theForm.add_fd21.value) == false) || ((theForm.add_fd21.value.length == 3) == false))
			{
				alert ("Please enter a valid telephone area code.\n" );
				theForm.add_fd21.focus();
				return false;
			}	

			if ((check_numeric(theForm.add_fd22.value) == false) || ((theForm.add_fd22.value.length == 3) == false))
			{
				alert ("Please enter a valid telephone number prefix.\n" );
				theForm.add_fd22.focus();
				return false;
			}
			if ((check_numeric(theForm.add_fd23.value) == false)	|| ((theForm.add_fd23.value.length == 4) == false))
			{
				alert ("Please enter a valid telephone number suffix.\n" );
				theForm.add_fd23.focus();
				return false;
			}
		}
		if (!(t2==""))
		{
			if ((check_numeric(theForm.add_fd24.value) == false)	|| ((theForm.add_fd24.value.length == 3) == false))
			{
				alert ("Please enter a valid telephone area code.\n" );
				theForm.add_fd24.focus();
				return false;
			}
			if ((check_numeric(theForm.add_fd25.value) == false)	|| ((theForm.add_fd25.value.length == 3) == false))
			{
				alert ("Please enter a valid telephone number prefix.\n" );
				theForm.add_fd25.focus();
				return false;
			}
			if ((check_numeric(theForm.add_fd26.value) == false)	|| ((theForm.add_fd26.value.length == 4) == false))
			{
				alert ("Please enter a valid telephone number suffix.\n" );
				theForm.add_fd26.focus();
				return false;
			}
		}
		
		// Personal Income
		if ( check_valid_money(theForm.add_fd28) == false)
		{
			alert( "Please enter a valid monetary amount for Personal Income.\n" + moreinfo );
			theForm.add_fd28.focus();
			return false;
		}
		// Corporate Net Income
		if ( check_valid_money(theForm.add_fd29) == false)
		{
			alert( "Please enter a valid monetary amount for Corporate Net Income.\n" + moreinfo );
			theForm.add_fd29.focus();
			return false;
		}
		// Annual Gross Income
		if ( check_valid_money(theForm.add_fd31) == false)
		{
			alert( "Please enter a valid monetary amount for Annual Gross Income.\n" + moreinfo );
			theForm.add_fd31.focus();
			return false;
		}
		// Annual Gross Expense
		if ( check_valid_money(theForm.add_fd32) == false)
		{
			alert( "Please enter a valid monetary amount for Annual Gross Expense.\n" + moreinfo );
			theForm.add_fd32.focus();
			return false;
		}
		// Annual Net Income
		if ( check_valid_money(theForm.add_fd33) == false)
		{
			alert( "Please enter a valid monetary amount for Annual Net Income.\n" + moreinfo );
			theForm.add_fd33.focus();
			return false;
		}


		// ALL SYSTEMS GO!
		return true;
	}
	
	function check_valid_name(theNameField)
	{
		var reSpaces = new RegExp ('\\W','gi');
		var reAlpha = new RegExp ('[^a-zA-Z]','gi');
		if ( theNameField.value != null ) {
			var temp;
			temp = theNameField.value;
			temp = temp.replace(reSpaces,'');
			temp = temp.replace(reAlpha,'');
			if (temp == '')
			{
				theNameField.value = temp;
				return false;
			}
			theNameField.value = temp;
		} else {
			return false;
		} 
		return true; 
	}
	
	function check_LTV(loanamt,propval)
	{
		var msg;
		msg = "Are you sure that your loan amount and purchase price\nor property values are correct? It appears that\nyou are looking to borrow 100% or more of the\nproperty value. If the values are correct click OK\notherwise please click CANCEL and change them.";
		if (parseFloat(loanamt) >= parseFloat(propval))
		{
			return confirm(msg);
		}
		return true;
	}
	
	function check_valid_zipcode(el) {
		var temp;
		temp = el.value;
		if ( temp.length == 5 ) {
			var re = /^[\d]{5}$/;
			return re.test(temp);
		} else if ( (temp.indexOf('-') > -1) == (temp.length == 10) ) {
			var re = /^[\d]{5}[\-]{1}[\d]{4}$/;
			return re.test(temp);
		} else if ( (temp.indexOf('-') == -1) == (temp.length == 9) ) {
			var re = /^[\d]{9}$/;
			return re.test(temp);
		} else {
			return false;
		}
	}
	
	function check_valid_money(e) 
	{
		var temp;
		var position;
		var reComma = new RegExp (',','gi');
		var reDollar = new RegExp ('\\$','gi');
		var reDecimal = new RegExp ('\\.','gi');
		var reAlpha = new RegExp ('[a-zA-Z]','gi');
		var reWord = new RegExp ('\\W','gi');
		temp = '';
		temp = e.value;
		position = temp.lastIndexOf('.');
		if (position != -1)
		{
			temp = temp.slice(0,position);
		}
		temp = temp.replace(reDecimal,'');
		temp = temp.replace(reComma,'');
		temp = temp.replace(reDollar,'');
		temp = temp.replace(reAlpha,'');
		temp = temp.replace(reWord,'');
		if (check_numeric(temp) == false)
		{
			e.value = temp;
			return false;
		}
		if (temp == 0)
		{
			e.value = "";
			return false;
		}
		e.value = temp;
		return true;
	} 
	function check_numeric(val)
	{
		var reNumeric = /(^-?\d\d*$)/;
		return reNumeric.test(val);
	}
	function isEmail(string) 
    	{
		if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
			return true;
		else
			return false;
	}