<!--

//**************************************************************************************
// Author:  Mai Trinh
// Purpose: CheckInput function is called in eRealProperty form to validate user input.
//          We only want to accept 10-digits. No space, dash, hipen, or characters 
//          are allowed.
//**************************************************************************************

function CheckInput(form) {

     var lng;
     var Value;
     var msg;
     var j;
     lng = form.ParcelNbr.value.length;
     Value = form.ParcelNbr.value;
     msg = "";
     
     if (lng < 10) {
		msg = "Enter a 10-digit parcel number.  ";
     }
     else {
		for (j = 0; j < lng; j++) {
			if ((Value.substring(j,j+1) != "0") &&
				(Value.substring(j,j+1) != "1") &&
				(Value.substring(j,j+1) != "2") &&
				(Value.substring(j,j+1) != "3") &&
				(Value.substring(j,j+1) != "4") &&
				(Value.substring(j,j+1) != "5") &&
				(Value.substring(j,j+1) != "6") &&
				(Value.substring(j,j+1) != "7") &&
				(Value.substring(j,j+1) != "8") &&
				(Value.substring(j,j+1) != "9")) {
		msg = "Input value has non-numeric value.  A parcel number is a 10-digit number."
				} // end if			
		} // end for
     } //end else
     
    if (msg != "") {
		alert(msg);		
    }
    else {
		form.submit(); 
    }
} // end function



//**************************************************************************************
// Author:  Mai Trinh
// Purpose: CheckChangeRequestfunction is called in RequestForm.asp.
//          We do not want any scripting text or html tag in the text box.
//**************************************************************************************

function CheckChangeRequest(form) {
     var msg;
     var req;
     var name;
     var email;
     
     req = form.Change.value;
     name = form.Requestor.value;
     email = form.RequestorEmail.value;
     msg = "";
     if (name == "") {
          msg = "Enter your name. "
     }
     if (email == "") {
          msg = msg + "\nEnter your email address. " 
     } else {
          if (!validateEmail(form.RequestorEmail)) {
               msg = msg + "\nInvalid email address. "           
          }
     }

     if (req == "") {
          msg = msg + "\nEnter your message. "
     }
     if (msg == "") {
	form.Send.value = form.ParcelNbr.value;

	form.submit(); 
     } else {
        alert(msg);    
     }

} // end function



//**************************************************************************************
// From    : The original code was from a forum of www.ASP101.com site.
// Revised : Mai modified to fix the need.
// Purpose : Check for invalid email address.
//**************************************************************************************


function isEmail(str) {
// are regular expressions supported?
var supported = 0;
if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
}
if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
return (!r1.test(str) && r2.test(str));
}
function validateEmail(obj)
{
    if (!isEmail(obj.value)) {
        obj.focus();
        return false;
    }
    else {
        return true;
    }
}



//**************************************************************************************
// Author:  Mai Trinh
// Purpose: Increase the access count when user click the Back button.
// How:     Call this in the onload.         
//**************************************************************************************

function IncreaseCount()
{	
	var ct;
	if (document.getElementById) {
	    ct = document.getElementById("form1").AccessCount.value;
		if (ct == "") {
			ct = "0";
		}
		
		document.getElementById("form1").AccessCount.value = eval(ct) + 1;
	}
		
	if (document.layers) {
		ct = document.form1.AccessCount.value;
		if(ct=="")
			ct=0;
		else
			ct=parseInt(ct);
	    document.form1.AccessCount.value=ct+1+"";
	
	}
}



-->