var submitted = 0;
var one = false;
var two = false;
var three = false;
var four = false;
var five = false;
var six = false;
var seven = false;
var eight = false;
function submitFrom (form,element) {		
	if (!submitted) { 
		form.elements[element].disabled = true;
		submitted = 1;
		with (form.yourname) {
			tot = /^[\sa-zA-Z\.]+$/;			
			len = tot.test(value);
			if (!len) {
				style.backgroundColor = "yellow";
				one = false;
			} else {
				style.backgroundColor = "white";
				one = true;
			}
		}
		with (form.youremail) {
			emFa = /^.+@.+\..{2,6}$/;
			ilCh= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
			format = emFa.test(value);
			content = value.match(ilCh);
			if (!format || content) {
				style.backgroundColor = "yellow";
				three = false;
			} else {
				style.backgroundColor = "white";
				three = true;
			}
		}
		with (form.yourphone) {
			tot = /^[\d\s\(\)\-\+]{7,18}$/;
			len = tot.test(value);
			if (!len) {
				style.backgroundColor = "yellow";
				two = false;
			} else {
				style.backgroundColor = "white";
				two = true;
			}
		}
		if (form.subject.value == "item0" || form.subject.value == "item00") {
			form.subject.style.backgroundColor = "yellow";			
			four = false;
		} else {
			form.subject.style.backgroundColor = "white";
			four = true;
		}
		with (form.ownersname) {
			tot = /^[\sa-zA-Z\.]+$/;			
			len = tot.test(value);
			if (len || value == "" || value == null) {
				style.backgroundColor = "white";
				five = true;
			} else {
				style.backgroundColor = "yellow";
				five = false;
			}
		}
		with (form.buyersname) {
			tot = /^[\sa-zA-Z\.]+$/;			
			len = tot.test(value);
			if (len || value == "" || value == null) {
				style.backgroundColor = "white";
				six = true;
			} else {
				style.backgroundColor = "yellow";
				six = false;
			}
		}
		with (form.mortgageamount) {
			tot = /^[\d\$\.,]+$/;			
			len = tot.test(value);
			if (len || value == "" || value == null) {
				style.backgroundColor = "white";
				seven = true;
			} else {				
				style.backgroundColor = "yellow";
				seven = false;
			}
		}
		with (form.saleprice) {
			tot = /^[\d\$\.,]+$/;			
			len = tot.test(value);
			if (len || value == "" || value == null) {
				style.backgroundColor = "white";
				eight = true;
			} else {				
				style.backgroundColor = "yellow";
				eight = false;
			}
		}
		if (one == true && two == true && three == true && four == true && five == true && six == true && seven == true && eight == true) {
			form.submit ();			
		} else {
			form.elements[element].disabled = false;
			submitted = 0;
			alert("Please correct the highlighted fields.");
		}			
	}
}
function resetFrom (form,element) {
	submitted = 0;
	with (form) {	
		elements[element].disabled = false;
		yourname.style.backgroundColor = "white";
		yourphone.style.backgroundColor = "white";
		youremail.style.backgroundColor = "white";
		subject.style.backgroundColor = "white";
		ownersname.style.backgroundColor = "white";
		buyersname.style.backgroundColor = "white";
		mortgageamount.style.backgroundColor = "white";
		saleprice.style.backgroundColor = "white";
		extra.style.backgroundColor = "white";
		reset();
	}
}

