	// tab to next box in IE
	function TabNext(obj,event,len,next_field) {
	   var field_length=0;
	   if (event == "down") {
	      field_length=obj.value.length;
	   } else if (event == "up") {
	      if (obj.value.length != field_length) {
		 	field_length=obj.value.length;
		 	if (field_length == len) {
		    		next_field.focus();
		 	}
	       }
	   }
	}


function setCookie(){
    var the_date = new Date("December 31, 2025");
    var the_cookie_date = the_date.toGMTString();
    var the_cookie = "name=" + escape("username:" + document.login.username.value) + ";expires=" + the_cookie_date;
    document.cookie = the_cookie;
    return true;
}

function readCookie(){
	if(document.cookie == ''){
		return;
	}
	var the_cookie = document.cookie;
	var the_cookie = unescape(the_cookie);
	var broken_cookie = the_cookie.split(":");
	var the_name = broken_cookie[1];

	if(the_name == null) {
		document.login.username.value = '';
	}else{
		var index1 = the_name.indexOf(";");
		if(index1 > -1) {
			the_name = the_name.substring(0,index1);
		}
		document.login.username.value = the_name;
	}
	return;
}


	function checkNewCustomerFields() {
		if (document.app.Company.value == "") {
			alert("A value is required for Company");
			document.app.Company.focus();
			return false;
		}

		if (document.app.Street.value == "") {
			alert("A value is required for Address");
			document.app.Street.focus();
			return false;
		}
		if (document.app.City.value == "") {
			alert("A value is required for City");
			document.app.City.focus();
			return false;
		}

		if (document.app.State.value == "") {
			alert("A value is required for State");
			document.app.State.focus();
			return false;
		}

		if (document.app.Zip.value == "") {
			alert("A value is required for Zip");
			document.app.Zip.focus();
			return false;
		}
		if (document.app.Contact_Name_1.value == "") {
			alert("A value is required for Contact #1 Name");
			document.app.Contact_Name_1.focus();
			return false;
		}
		if (document.app._Phone11.value == "" || document.app._Phone12.value == "" || document.app._Phone13.value == "") {
			alert("A value is required for Phone Number");
			document.app._Phone11.focus();
			return false;
		}

		app.submit();
	}


	function checkCurrentCustomerFields() {
		if (document.app.Customer_No.value == "") {
			alert("A value is required for Customer No");
			document.app.Customer_No.focus();
			return false;
		}

		if (document.app.Contact.value == "") {
			alert("A value is required for Contact");
			document.app.Contact.focus();
			return false;
		}

		if (document.app._Phone1.value == "" || document.app._Phone2.value == "" || document.app._Phone3.value == "") {
			alert("A value is required for Phone Number");
			document.app._Phone1.focus();
			return false;
		}

		if (document.app.Email_Address.value == "") {
			alert("A value is required for Email Address");
			document.app.Email_Address.focus();
			return false;
		}

		if (document.app.Password.value == "") {
			alert("A value is required for Password");
			document.app.Password.focus();
			return false;
		}

		if (document.app.Password2.value == "") {
			alert("A value is required for Password2");
			document.app.Password2.focus();
			return false;
		}

		if (document.app.Password.value != document.app.Password2.value) {
			alert("Both passwords must match");
			document.app.Password.value = '';
			document.app.Password2.value = '';
			document.app.Password.focus();
			return false;
		}

		if(window.confirm("Do you want to submit this application to Title Review?")) {
			return(true);
		}
		return(false);
	}


	function checkCustomerAppFields() {
		if (document.app.Name.value == "") {
			alert("A value is required for Name");
			document.app.Name.focus();
			return false;
		}

		if (document.app.Email_Address.value == "") {
			alert("A value is required for Email Address");
			document.app.Email_Address.focus();
			return false;
		}

		if (document.app._SSN1.value == "" || document.app._SSN2.value == "" || document.app._SSN3.value == "") {
			alert("A value is required for SSN");
			document.app._SSN1.focus();
			return false;
		}

		if (document.app._Phone1.value == "" || document.app._Phone2.value == "" || document.app._Phone3.value == "") {
			alert("A value is required for Phone Number");
			document.app._Phone1.focus();
			return false;
		}

		if(window.confirm("Do you want to submit this application to Title Review?")) {
			return(true);
		}
		return(false);
	}
