function fn_search_errors(){
        if(document.search.type.value==""){
           alert("Please select at least one type of property.");
           document.search.type.focus();
           return false;
        }
	    var minpri=parseInt(document.search.minprice.value);
		var maxpri=parseInt(document.search.maxprice.value);
        if(minpri>=maxpri){
			alert("Please select a valid price range.");
			document.search.minprice.focus();
			return false;
		}
		var frm=parseInt(document.search.yearfrom.value);
		var to=parseInt(document.search.yearto.value);
		if(frm>=to){
			alert("Please select a valid year built range.");
			document.search.yearfrom.focus();
			return false;
		}
        var minsq=parseInt(document.search.minsqft.value);
		var maxsq=parseInt(document.search.maxsqft.value);
		if(minsq>=maxsq){
			alert("Please select a valid living area range.");
			document.search.minsqft.focus();
			return false;
        }
        var minlot=parseInt(document.search.minlotsize.value);
		var maxlot=parseInt(document.search.maxlotsize.value);
		if(minlot>=maxlot){
			alert("Please select a valid lot size range.");
			document.search.minlotsize.focus();
			return false;
        }
        return true;
}
function fn_register_errors(){
   if(document.register.txtfirstname.value==""){
		   alert('Please enter your first name.');
		   document.register.txtfirstname.focus();
		   return false;
   }
   if(!isNaN(document.register.txtfirstname.value)) {
			alert('Please enter a valid first name.');
			document.register.txtfirstname.focus();
			document.register.txtfirstname.value="";
			return false;
   }
/*   if(document.register.txtlastname.value==""){
		   alert('Please enter your last name.');
		   document.register.txtlastname.focus();
		   return false;
   }
    if(!isNaN(document.register.txtlastname.value)) {
			alert('Please enter a valid last name.');
			document.register.txtlastname.focus();
			document.register.txtlastname.value="";
			return false;
   }*/
    if(document.register.txtemail.value==""){
			alert('Please enter a valid email.');
			document.register.txtemail.focus();
			document.register.txtemail.value="";
			return false;
		}
		else{
			var str=document.register.txtemail.value;
			var at="@"
			var dot="."
			var comma=","
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			var cdot=str.indexOf(comma)

			if(cdot!=-1){
			   alert("Please enter a valid email.")
 	           document.register.txtemail.focus();
			   document.register.txtemail.value="";
			   return false
			}
			if (str.indexOf(at)==-1){
			   alert("Please enter a valid email.")
		   	   document.register.txtemail.focus();
     	       document.register.txtemail.value="";
			   return false
			}
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
			   alert("Please enter a valid email.")
 	           document.register.txtemail.focus();
			   document.register.txtemail.value="";
			   return false
			}
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
				alert("Please enter a valid email.")
			    document.register.txtemail.focus();
			    document.register.txtemail.value="";
				return false
			}
			if (str.indexOf(at,(lat+1))!=-1){   // To check whether there is one @ character in an email id
				alert("Please enter a valid email.")
               	document.register.txtemail.focus();
			    document.register.txtemail.value="";
				return false
			 }
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ // To check whether @. and .@
				alert("Please enter a valid email.")
				document.register.txtemail.focus();
		    	document.register.txtemail.value="";
				return false
			 }
			 if (str.indexOf(dot,(lat+2))==-1){
				alert("Please enter a valid email.")
				document.register.txtemail.focus();
			    document.register.txtemail.value="";
				return false
			 }
			 if (str.indexOf(" ")!=-1){
				alert("Please enter a valid email.")
				document.register.txtemail.focus();
			    document.register.txtemail.value="";
				return false
			 }
	}
/*	if(document.register.txtvemail.value==""){
			alert('Please confirm your email.');
			document.register.txtvemail.focus();
			document.register.txtvemail.value="";
			return false;
		}
		else{
			var str=document.register.txtvemail.value;
			var at="@"
			var dot="."
			var comma=","
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			var cdot=str.indexOf(comma)

			if(cdot!=-1){
			   alert("Please enter a valid email.")
 	           document.register.txtvemail.focus();
			   document.register.txtvemail.value="";
			   return false
			}
			if (str.indexOf(at)==-1){
			   alert("Please enter a valid email.")
		   	   document.register.txtvemail.focus();
     	       document.register.txtvemail.value="";
			   return false
			}
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
			   alert("Please enter a valid email.")
 	           document.register.txtvemail.focus();
			   document.register.txtvemail.value="";
			   return false
			}
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
				alert("Please enter a valid email.")
			    document.register.txtvemail.focus();
			    document.register.txtvemail.value="";
				return false
			}
			if (str.indexOf(at,(lat+1))!=-1){   // To check whether there is one @ character in an email id
				alert("Please enter a valid email.")
               	document.register.txtvemail.focus();
			    document.register.txtvemail.value="";
				return false
			 }
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ // To check whether @. and .@
				alert("Please enter a valid email.")
				document.register.txtvemail.focus();
		    	document.register.txtvemail.value="";
				return false
			 }
			 if (str.indexOf(dot,(lat+2))==-1){
				alert("Please enter a valid email.")
				document.register.txtvemail.focus();
			    document.register.txtvemail.value="";
				return false
			 }
			 if (str.indexOf(" ")!=-1){
				alert("Please enter a valid email.")
				document.register.txtvemail.focus();
			    document.register.txtvemail.value="";
				return false
			 }
	}
	var email=document.register.txtemail.value;
    var email1=document.register.txtvemail.value;
	if(email!=email1){
           alert('Your email and verify email fields must match.');
		   document.register.txtemail.focus();
		   document.register.txtemail.value="";
		   document.register.txtvemail.value="";
		   return false;
   }*/
    	if(document.register.txtpassword.value==""){
		   alert('Please enter a password.');
	       document.register.txtpassword.value="";
	       document.register.txtvpassword.value="";
		   document.register.txtpassword.focus();
		   return false;
   }
   var pass=document.register.txtpassword.value;
   if(pass.length<6){
           alert('Your password should be at least 6 characters.');
		   document.register.txtpassword.focus();
	       document.register.txtpassword.value="";
	       document.register.txtvpassword.value="";
		   return false;
   }
   	if(document.register.txtvpassword.value==""){
		   alert('Please verify your password.');
	       document.register.txtvpassword.value="";
		   document.register.txtvpassword.focus();
		   return false;
   }
   var pass1=document.register.txtvpassword.value;
   if(pass1.length<6){
           alert('Please verify your password.');
	       document.register.txtvpassword.value="";
	       document.register.txtvpassword.value="";
		   return false;
   }
   if(pass!=pass1){
           alert('Your password and verify password fields must match.');
		   document.register.txtpassword.focus();
		   document.register.txtpassword.value="";
		   document.register.txtvpassword.value="";
		   return false;
   }
/*   	if(document.register.txtphone.value==""){
		   alert('Please enter a valid phone number.');
		   document.register.txtphone.focus();
		   return false;
   }*/
   if(isNaN(document.register.txtphone.value.replace(/[\(\)\.\-\ ]/g, ''))) {
			alert('Please enter a valid phone number.');
			document.register.txtphone.focus();
			document.register.txtphone.value="";
			return false;
   }
/*   	if(document.register.timeframe.value==""){
		   alert('Please select an estimated time frame.');
		   document.register.timeframe.focus();
		   return false;
   }
   if(document.register.needs.value==""){
		   alert('Please select the reason you are using this site.');
		   document.register.txtphone.focus();
		   return false;
   }
   if(!document.register.termsofuse.checked){
		   alert('You must read and agree to the Terms of Use to continue.');
		   return false;
   }*/

}

function fn_email_errors(){
	// First Name - Not Blank
	// Last Name - Not Blank
	// Email - Not Blank, Valid Email
	// Comments - Not Blank

	if(document.send.txtsenderfirstname.value==""){
		alert('Please enter your first name.');
		document.send.txtsenderfirstname.focus();
		return false;
	}
	if(document.send.txtsenderlastname.value==""){
		alert('Please enter your last name.');
		document.send.txtsenderlastname.focus();
		return false;
	}
	if(document.send.txtsenderemail.value==""){
		alert('Please enter a valid email.');
		document.send.txtsenderemail.focus();
		document.send.txtsenderemail.value="";
		return false;
	} else {
		var str=document.send.txtsenderemail.value;
		var at="@"
		var dot="."
		var comma=","
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var cdot=str.indexOf(comma)

		if(cdot!=-1){
		   alert("Please enter a valid email.")
		   document.send.txtsenderemail.focus();
		   document.send.txtsenderemail.value="";
		   return false
		}
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid email.")
		   document.send.txtsenderemail.focus();
		   document.send.txtsenderemail.value="";
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
		   alert("Please enter a valid email.")
		   document.send.txtsenderemail.focus();
		   document.send.txtsenderemail.value="";
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
			alert("Please enter a valid email.")
			document.send.txtsenderemail.focus();
			document.send.txtsenderemail.value="";
			return false
		}
		if (str.indexOf(at,(lat+1))!=-1){   // To check whether there is one @ character in an email id
			alert("Please enter a valid email.")
			document.send.txtsenderemail.focus();
			document.send.txtsenderemail.value="";
			return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ // To check whether @. and .@
			alert("Please enter a valid email.")
			document.send.txtsenderemail.focus();
			document.send.txtsenderemail.value="";
			return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Please enter a valid email.")
			document.send.txtsenderemail.focus();
			document.send.txtsenderemail.value="";
			return false
		 }
		 if (str.indexOf(" ")!=-1){
			alert("Please enter a valid email.")
			document.send.txtsenderemail.focus();
			document.send.txtsenderemail.value="";
			return false
		 }

	}
	
	if(document.send.txtfirstname.value==""){
		alert('Please enter your friend\'s first name.');
		document.send.txtfirstname.focus();
		return false;
	}
	if(document.send.txtlastname.value==""){
		alert('Please enter your friend\'s last name.');
		document.send.txtlastname.focus();
		return false;
	}
	if(document.send.txtemail.value==""){
		alert('Please enter a valid email.');
		document.send.txtemail.focus();
		document.send.txtemail.value="";
		return false;
	} else {
		var str=document.send.txtemail.value;
		var at="@"
		var dot="."
		var comma=","
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var cdot=str.indexOf(comma)

		if(cdot!=-1){
		   alert("Please enter a valid email.")
		   document.send.txtemail.focus();
		   document.send.txtemail.value="";
		   return false
		}
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid email.")
		   document.send.txtemail.focus();
		   document.send.txtemail.value="";
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
		   alert("Please enter a valid email.")
		   document.send.txtemail.focus();
		   document.send.txtemail.value="";
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		}
		if (str.indexOf(at,(lat+1))!=-1){   // To check whether there is one @ character in an email id
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ // To check whether @. and .@
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		 }
		 if (str.indexOf(" ")!=-1){
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		 }

	}

	if(document.send.txtcomments.value==""){
		alert('Please enter a message to send.');
		document.send.txtcomments.focus();
		return false;
	}


}


function fn_requestshowing_errors(){
	// First Name - Not Blank
	// Last Name - Not Blank
	// Email - Not Blank, Valid Email
	// Comments - Not Blank
	
	if(document.send.txtfirstname.value==""){
		alert('Please enter your first name.');
		document.send.txtfirstname.focus();
		return false;
	}
	if(document.send.txtlastname.value==""){
		alert('Please enter your last name.');
		document.send.txtlastname.focus();
		return false;
	}
	if(document.send.txtemail.value==""){
		alert('Please enter a valid email.');
		document.send.txtemail.focus();
		document.send.txtemail.value="";
		return false;
	} else {
		var str=document.send.txtemail.value;
		var at="@"
		var dot="."
		var comma=","
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var cdot=str.indexOf(comma)

		if(cdot!=-1){
		   alert("Please enter a valid email.")
		   document.send.txtemail.focus();
		   document.send.txtemail.value="";
		   return false
		}
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid email.")
		   document.send.txtemail.focus();
		   document.send.txtemail.value="";
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
		   alert("Please enter a valid email.")
		   document.send.txtemail.focus();
		   document.send.txtemail.value="";
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		}
		if (str.indexOf(at,(lat+1))!=-1){   // To check whether there is one @ character in an email id
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ // To check whether @. and .@
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		 }
		 if (str.indexOf(" ")!=-1){
			alert("Please enter a valid email.")
			document.send.txtemail.focus();
			document.send.txtemail.value="";
			return false
		 }

	}

   	if(document.send.txtphone.value==""){
		   alert('Please enter a valid phone number.');
		   document.send.txtphone.focus();
		   return false;
   }
   if(isNaN(document.send.txtphone.value.replace(/[\(\)\.\-\ ]/g, ''))) {
			alert('Please enter a valid phone number.');
			document.send.txtphone.focus();
			document.send.txtphone.value="";
			return false;
   }


	if(document.send.txtcomments.value==""){
		alert('Please enter a message to send.');
		document.send.txtcomments.focus();
		return false;
	}
}


function fn_mortgagecalc_errors(){
	// All fields are not blank and are numeric
	
   if(document.send.txtpurchase.value==""){
		   alert('Please enter a valid purchase price.');
		   document.send.txtpurchase.focus();
		   return false;
   }
   if(isNaN(document.send.txtpurchase.value.replace(/[\(\)\.\-\ ]/g, ''))) {
			alert('Please enter a valid purchase price.');
			document.send.txtpurchase.focus();
			document.send.txtpurchase.value="";
			return false;
   }

   if(document.send.txtdown.value==""){
		   alert('Please enter a valid down payment.');
		   document.send.txtdown.focus();
		   return false;
   }

   if(isNaN(document.send.txtdown.value.replace(/[\(\)\.\-\ ]/g, ''))) {
			alert('Please enter a valid downpayment.');
			document.send.txtdown.focus();
			document.send.txtdown.value="";
			return false;
   }

   if(parseFloat(document.send.txtdown.value)>parseFloat(document.send.txtpurchase.value)){
		   alert('Down payment must be equal to or less than purchase price.');
		   document.send.txtdown.focus();
		   return false;
   }

}



/*
function fn_login_errors(){
   if(document.login.email.value==""){
           alert("please enter your Email Id");
           document.login.email.focus();
           return false;
   }
   else{
			var str=document.login.email.value;
			var at="@"
			var dot="."
			var comma=","
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			var cdot=str.indexOf(comma)

			if(cdot!=-1){
			   alert("Invalid E-mail ID")
 	           document.login.email.focus();
			   document.login.email.value="";
			   return false
			}
			if (str.indexOf(at)==-1){
			   alert("Invalid E-mail ID")
		   	   document.login.email.focus();
     	       document.login.email.value="";
			   return false
			}
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
			   alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
 	           document.login.email.focus();
			   document.login.email.value="";
			   return false
			}
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
			    document.login.email.focus();
			    document.login.email.value="";
				return false
			}
			if (str.indexOf(at,(lat+1))!=-1){   // To check whether there is one @ character in an email id
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
               	document.login.email.focus();
			    document.login.email.value="";
				return false
			 }
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ // To check whether @. and .@
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
				document.login.email.focus();
		    	document.login.email.value="";
				return false
			 }
			 if (str.indexOf(dot,(lat+2))==-1){
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
				document.login.email.focus();
			    document.login.email.value="";
				return false
			 }
			 if (str.indexOf(" ")!=-1){
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
                document.login.email.focus();
			    document.login.email.value="";
				return false
			 }
	}
   if(document.login.psd.value==""){
           alert("please enter your password");
           document.login.psd.focus();
           return false;
   }
}
function fn_forgot_errors(){
 if(document.forgot.emil.value==""){
           alert("please enter your Email Id");
           document.forgot.emil.focus();
           return false;
   }
    else{
			var str=document.forgot.emil.value;
			var at="@"
			var dot="."
			var comma=","
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			var cdot=str.indexOf(comma)

			if(cdot!=-1){
			   alert("Invalid E-mail ID")
 	           document.forgot.emil.focus();
			   document.forgot.emil.value="";
			   return false
			}
			if (str.indexOf(at)==-1){
			   alert("Invalid E-mail ID")
		   	   document.forgot.emil.focus();
     	       document.forgot.emil.value="";
			   return false
			}
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
			   alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
 	           document.forgot.emil.focus();
			   document.forgot.emil.value="";
			   return false
			}
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
			    document.forgot.emil.focus();
			    document.forgot.emil.value="";
				return false
			}
			if (str.indexOf(at,(lat+1))!=-1){   // To check whether there is one @ character in an email id
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
               	document.forgot.emil.focus();
			    document.forgot.emil.value="";
				return false
			 }
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ // To check whether @. and .@
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
				document.forgot.emil.focus();
		    	document.forgot.emil.value="";
				return false
			 }
			 if (str.indexOf(dot,(lat+2))==-1){
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
				document.forgot.emil.focus();
			    document.forgot.emil.value="";
				return false
			 }
			 if (str.indexOf(" ")!=-1){
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
                document.forgot.emil.focus();
			    document.forgot.emil.value="";
				return false
			 }
	}
}
function fn_verify_errors(){
 if(document.verify.email1.value==""){
           alert("please enter your Email Id");
           document.verify.email1.focus();
           return false;
   }
    else{
			var str= document.verify.email1.value;
			var at="@"
			var dot="."
			var comma=","
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			var cdot=str.indexOf(comma)

			if(cdot!=-1){
			   alert("Invalid E-mail ID")
 	            document.verify.email1.focus();
			    document.verify.email1.value="";
			   return false
			}
			if (str.indexOf(at)==-1){
			   alert("Invalid E-mail ID")
		   	   document.verify.email1.focus();
     	 document.verify.email1.value="";
			   return false
			}
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
			   alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
 	            document.verify.email1.focus();
			    document.verify.email1.value="";
			   return false
			}
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
			     document.verify.email1.focus();
			     document.verify.email1.value="";
				return false
			}
			if (str.indexOf(at,(lat+1))!=-1){   // To check whether there is one @ character in an email id
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
               	 document.verify.email1.focus();
			     document.verify.email1.value="";
				return false
			 }
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ // To check whether @. and .@
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
				 document.verify.email1.focus();
		    	 document.verify.email1.value="";
				return false
			 }
			 if (str.indexOf(dot,(lat+2))==-1){
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
				 document.verify.email1.focus();
			     document.verify.email1.value="";
				return false
			 }
			 if (str.indexOf(" ")!=-1){
				alert("Invalid E-mail ID.\n\n Eg: abc@def.ghi")
                document.verify.email1.focus();
			     document.verify.email1.value="";
				return false
			 }
	}
	if(document.verify.verifycode.value==""){
           alert("please enter the verification code");
           document.verify.verifycode.focus();
           return false;
   }
	
} */
