// JavaScript Document

function clearHelpText(thisField)
{
  if (thisField.value == thisField.defaultValue)
	{
	thisField.value = ''; 
	thisField.focus();
	}

}
//===========================
//for hiding mortgageLayer
//Added for accomodating two more fields
//Added on 22/11/2007
//===========================
function hidelayerMortgage()
{
var myElement = document.getElementById("mortgageLayer");
myElement.style.display = "none"; // hides the layer

}
function viewlayerMortgage()
{
var myElement = document.getElementById("mortgageLayer");
myElement.style.display = "block"; // hides the layer
}
function hidelayerSecured()
{
var myElement = document.getElementById("securedLayer");
myElement.style.display = "none"; // hides the layer
var myElement = document.getElementById("mortLayer");
myElement.style.display = "none"; // hides the layer

}
	
function viewmanualLayer()
{
	var myElement = document.getElementById("manualLayer");
	myElement.style.display = "block"; 
	var myElement = document.getElementById("finderLayer");
	myElement.style.display = "none"; 
	var myElement = document.getElementById("findaddress");
	myElement.style.visibility = "hidden"; 
	var myElement = document.getElementById("sixedAdd");
	myElement.style.visibility = "hidden"; 
	document.theForm.fndAdd.value="1";
	
}
function hidemanualLayer()
{
	var myElement = document.getElementById("manualLayer");
	myElement.style.display = "none"; 
	// hides the layer
	var myElement = document.getElementById("finderLayer");
	myElement.style.display = "block"; 
	var myElement = document.getElementById("findaddress");
	myElement.style.visibility = "visible"; 
	document.theForm.fndAdd.value="0";
	
}
	
function viewlayerSecured()
{
var myElement = document.getElementById("securedLayer");
myElement.style.display = "block"; // hides the layer
var myElement = document.getElementById("mortLayer");
myElement.style.display = "block"; // hides the layer
}
function showlayer()
{
	
	var homeowner,mortgage,len,homeownerchosen,mortgagechosen;
	len=document.theForm.homeowner.length;
	
		if (document.theForm.homeowner[0].checked) 
		{
			homeownerchosen = document.theForm.homeowner[0].value
			
			if (document.theForm.mortgage[1].checked)
			{
				//alert("mortgage 0");
			//document.theForm.mortgage[1].checked="False";
			document.theForm.mortgage[1].checked="True";
			
			}
			else
			{
				//alert("mortgage 1");
			//document.theForm.mortgage[0].checked="false";
			document.theForm.mortgage[0].checked="True";
			}
			document.theForm.secured[0].checked="True";
		}
		else
		{
			//alert("hello2");
			document.theForm.mortgage[0].checked="True";
			
			document.theForm.secured[1].checked="True";
			
		}
	
	len=document.theForm.mortgage.length;
	for (i = 0; i <len; i++) 
	{
		if (document.theForm.mortgage[i].checked) 
		{
			mortgagechosen = document.theForm.mortgage[i].value
		}
	}
	
	if(homeownerchosen=="1" && mortgagechosen=="1")
	{
		viewlayerMortgage();
	}
	else
	{
		hidelayerMortgage();
		
	}
}
function showsecuredlayer()
{
	var homeowner,mortgage,len,homeownerchosen,mortgagechosen;
	len=document.theForm.homeowner.length;
	
	for (i = 0; i <len; i++) 
	{
		if (document.theForm.homeowner[i].checked) 
		{
			homeownerchosen = document.theForm.homeowner[i].value
		}
	}
	
	
	if(homeownerchosen=="1" )
	{
		viewlayerSecured();
	}
	else
	{
	hidelayerSecured();
		
	}
}
//=================================
function Validate(theform) 

{
	
//validate Loan purpose
var checkDIS = "()+0123456789- ";

	var checkStr = theform.loan_purpose.value;
	//alert(checkStr);
	
	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "Selecte")
		allValid = false;

	if (checkStr == "0")
		allValid = false;
		
		if (checkStr == "")
		allValid = false;
	
			if (!allValid)
			{
				alert("Please select an loan purpose status");
				theform.loan_purpose.focus();
				return false;
			}

//validate emp status
var checkDIS = "()+0123456789- ";

	var checkStr = theform.emp_status.value;
	//alert(checkStr);
	
	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "Select")
		allValid = false;

	if (checkStr == "0")
		allValid = false;
		
		if (checkStr == "")
		allValid = false;
	
			if (!allValid)
			{
				alert("Please select an employment status");
				theform.emp_status.focus();
				return false;
			}
			var homeowner,mortgage,len,homeownerchosen,mortgagechosen;
	len=document.theForm.homeowner.length;
	for (i = 0; i <len; i++) 
	{
		if (document.theForm.homeowner[i].checked) 
		{
			homeownerchosen = document.theForm.homeowner[i].value
		}
	}
	len=document.theForm.mortgage.length;
	for (i = 0; i <len; i++) 
	{
		if (document.theForm.mortgage[i].checked) 
		{
			mortgagechosen = document.theForm.mortgage[i].value
		}
	}
	
	if(homeownerchosen=="1" && mortgagechosen=="1")
	{
		
	//propertyvalue

var checkDIS = "0123456789";

	var checkStr = theform.propertyvalue.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
		
	if (checkStr == "Amount(£)")
		allValid = false;
	if (checkStr < 1000)
		allValid = false;
		
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter Estimated property value");
				theform.propertyvalue.focus();
				theform.propertyvalue.style.background='#FFA74F';
				return (false);
			}


	
			//mortgagebalance

var checkDIS = "0123456789";

	var checkStr = theform.mortgagebalance.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
		
	if (checkStr == "Amount(£)")
		allValid = false;
	if (checkStr < 1000)
		allValid = false;
		
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter estimated mortgage balance");
				theform.mortgagebalance.focus();
				theform.mortgagebalance.style.background='#FFA74F';
				return (false);
			}
			
			}
//Validate title

	var checkDIS = "()+0123456789- ";

	var checkStr = theform.title.value;
	//alert(checkStr);
	
	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "Select")
		allValid = false;

	if (checkStr == "0")
		allValid = false;
	
			if (!allValid)
			{
				alert("Please select Title");
				theform.title.focus();
				return false;
			}

//firstname

var checkDIS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,'- ";

	var checkStr = theform.first_name.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
		
	if (checkStr == "first name")
		allValid = false;
		
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your First Name");
				theform.first_name.focus();
				theform.first_name.style.background='#FFA74F';
				return (false);
			}


//validate Surname

var checkDIS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,'- ";

	var checkStr = theform.surname.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "surname")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your Surname");
				theform.surname.style.background='#FFA74F';
				theform.surname.focus();
				return (false);
			}


//Validate the date of birth

var checkDIS = "()+0123456789- ";

	var checkStrDob = theform.DobDay.value;

	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStrDob == "")
		allValid = false;
	if (checkStrDob == "0")
		allValid = false;
	for (i = 0; i < checkStrDob.length; i++)
		{
			ch = checkStrDob.charAt(i);

			if (ch == "(")
				openBrace = true;

			if ((ch == ")") && !openBrace)
			{
				allValid = false;
				break;
			}

			if (ch == ")")
			{
				closeBrace = true;
				openBrace = false;
			}

			if ((ch == "+") && (i != 0))
			{
				allValid = false;
				break;
			}

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}

			if (openBrace)
				allValid = false;

			if (!allValid)
			{
				alert("Please enter day of birth");
				theform.DobDay.focus();
				//theform.DobDay.style.background='#FFA74F';
				return (false);
			}


//Validate the Month of birth

var checkDIS = "()+0123456789- ";
var allValidDate =true;
	var checkStr = theform.DobMon.value;

	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "0")
		allValid = false;
	if (checkStr == "0")
		allValid = false;
		
		//---------------------------------------------------------------------
		//Date of birth according to month
		//---------------------------------------------------------------------
		if (checkStr == "2" || checkStr == "4" || checkStr == "6" || checkStr == "9" || checkStr == "11")
			{
				
			if (checkStr == "2")
			{
				if (checkStrDob == "29")
					allValidDate = false;
				if (checkStrDob == "30")
					allValidDate = false;
				if (checkStrDob == "31")
					allValidDate = false;
			}
			if (checkStr == "4")
			{
				if (checkStrDob == "31")
					allValidDate = false;
			}
			if (checkStr == "6")
			{
				if (checkStrDob == "31")
					allValidDate = false;
			}
			if (checkStr == "9")
			{
				if (checkStrDob == "31")
					allValidDate = false;
			}
			if (checkStr == "11")
			{
				if (checkStrDob == "31")
					allValidDate = false;
			}
			
				if (!allValidDate)
						{
							alert("Please select a valid date of birth");
							theform.DobDay.focus();
							//theform.DobMon.style.background='#FFA74F';
							return (false);
						}
			}
					
		//-----------------------------------------------------------------------
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);

			if (ch == "(")
				openBrace = true;

			if ((ch == ")") && !openBrace)
			{
				allValid = false;
				break;
			}

			if (ch == ")")
			{
				closeBrace = true;
				openBrace = false;
			}

			if ((ch == "+") && (i != 0))
			{
				allValid = false;
				break;
			}

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}

			if (openBrace)

				allValid = false;

			if (!allValid)
			{
				alert("Please enter Month of birth");
				theform.DobMon.focus();
				//theform.DobMon.style.background='#FFA74F';
				return (false);
			}


//Validate the year of birth

var checkDIS = "()+0123456789- ";

	var checkStr = theform.DobYear.value;

	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "")
		allValid = false;
if (checkStr == "0")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);

			if (ch == "(")
				openBrace = true;

			if ((ch == ")") && !openBrace)
			{
				allValid = false;
				break;
			}

			if (ch == ")")
			{
				closeBrace = true;
				openBrace = false;
			}

			if ((ch == "+") && (i != 0))
			{
				allValid = false;
				break;
			}

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}

			if (openBrace)
				allValid = false;

			if (!allValid)
			{
				alert("Please enter year of birth");
				theform.DobYear.focus();
				//theform.DobYear.style.background='#FFA74F';
				return (false);
			}


			

	var varchPost;
	varchPost=document.theForm.fndAdd.value;
				
//validate foundedaddress
if (varchPost == "0") 
{


	//validate postcode

var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,- ";

	var checkStr = theform.postcode.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "postcode")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your postcode");
				theform.postcode.style.background='#FFA74F';
				theform.postcode.focus();
				return (false);
			}
			
	
	
	var checkDIS = "()+0123456789- ";

	var checkStr = theform.foundedaddress.value;
	//alert(checkStr);
	
	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "Select")
		allValid = false;

	if (checkStr == "0")
		allValid = false;
		
	
	
			if (!allValid)
			{
				alert("Please select your address from the list");
				theform.foundedaddress.focus();
				//theform.title.style.background='#FFA74F';
				return false;
			}
}
else
{

//validate street

var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,'- ";

	var checkStr = theform.street.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "house no & street")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter street");
				theform.street.style.background='#FFA74F';
				theform.street.focus();
				return (false);
			}
			
			
			

			
			//validate city

var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,'- ";

	var checkStr = theform.city.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "city")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your City");
				theform.city.style.background='#FFA74F';
				theform.city.focus();
				return (false);
			}
			
			
			//validate postcode

var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,- ";

	var checkStr = theform.postcode.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "postcode")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your postcode");
				theform.postcode.style.background='#FFA74F';
				theform.postcode.focus();
				return (false);
			}
			
			
}
			
//validate HomeTel

var checkDIS = "()+0123456789- ";

	var checkStr = theform.daytime_phone.value;

	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "")
		allValid = false;

	if (checkStr.length < 8)
		allValid = false;
  
if (checkStr == "daytime_phone")
		allValid = false;
		
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);

			if (ch == "(")
				openBrace = true;

			if ((ch == ")") && !openBrace)
			{
				allValid = false;
				break;
			}

			if (ch == ")")
			{
				closeBrace = true;
				openBrace = false;
			}

			if ((ch == "+") && (i != 0))
			{
				allValid = false;
				break;
			}

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}

			if (openBrace)
				allValid = false;

			if (!allValid)
			{
				alert("Please enter a Daytime Telephone Number (Please ensure it is valid)");
				theform.daytime_phone.focus();
				theform.daytime_phone.style.background='#FFA74F';
				return (false);
			}


			
//validate HomeTel

var checkDIS = "()+0123456789- ";

	var checkStr = theform.evening_phone.value;

	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

if (checkStr.length < 8)
		allValid = false;
		
	if (checkStr == "")
		allValid = false;

if (checkStr == "evening_phone")
		allValid = false;
		
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);

			if (ch == "(")
				openBrace = true;

			if ((ch == ")") && !openBrace)
			{
				allValid = false;
				break;
			}

			if (ch == ")")
			{
				closeBrace = true;
				openBrace = false;
			}

			if ((ch == "+") && (i != 0))
			{
				allValid = false;
				break;
			}

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}

			if (openBrace)
				allValid = false;

			if (!allValid)
			{
				alert("Please enter an Evening Telephone Number (Please ensure it is valid)");
				theform.evening_phone.focus();
				theform.evening_phone.style.background='#FFA74F';
				return (false);
			}



//validate Email

var checkDIS = "-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@.";

	var checkStr = theform.email.value;

	var allValid = true;

	var atSign = false;

	var dotOk = false;

	if (checkStr == "")
		allValid = false;
		
		if (checkStr == "you@here.co.uk")
		allValid = false;
		

	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);

			if ((ch == "@") && (i > 0))
				atSign = true;

			if ((ch == ".") && (atSign == true) && (i < (checkStr.length - 1)))
				dotOk = true;

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;

			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!dotOk)
				allValid = false;

			if (!allValid)
			{
				alert("Please enter a valid Email Address i.e. j.smith@dogs.co.uk");
				theform.email.focus();
				theform.email.style.background='#FFA74F';
				return (false);
			}


return (true);

}



function Validate2(theform) 

{

//Validate tenant

	var checkDIS = "()+0123456789- ";

	var checkStr = theform.tenanttype.value;
	//alert(checkStr);
	
	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "Select")
		allValid = false;

	if (checkStr == "0")
		allValid = false;
	
			if (!allValid)
			{
				alert("Please select tenant type");
				theform.tenanttype.focus();
				return false;
			}


//Validate mt

	var checkDIS = "()+0123456789- ";

	var checkStr = theform.month_time.value;
	//alert(checkStr);
	
	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "MM")
		allValid = false;


	
			if (!allValid)
			{
				alert("Please select months at residence");
				theform.month_time.focus();
				return false;
			}
			

//Validate yt

	var checkDIS = "()+0123456789- ";

	var checkStr = theform.year_time.value;
	//alert(checkStr);
	
	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "YY")
		allValid = false;

	
			if (!allValid)
			{
				alert("Please select years at residence");
				theform.year_time.focus();
				return false;
			}
			



//Validate rent

var checkDIS = "()+0123456789£,- ";

	var checkStr = theform.monthlyrent.value;

	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

if (checkStr == "rent/month (£)")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);

			if (ch == "(")
				openBrace = true;

			if ((ch == ")") && !openBrace)
			{
				allValid = false;
				break;
			}

			if (ch == ")")
			{
				closeBrace = true;
				openBrace = false;
			}

			if ((ch == "+") && (i != 0))
			{
				allValid = false;
				break;
			}

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}

			if (openBrace)

				allValid = false;

			if (!allValid)
			{
				alert("Please enter monthly rent");
				theform.monthlyrent.focus();
				return (false);
			}



//Validate the Month of birth

var checkDIS = "()+0123456789£,- ";

	var checkStr = theform.tax.value;

	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

if (checkStr == "")
		allValid = false;
		
if (checkStr == "council tax (£)")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);

			if (ch == "(")
				openBrace = true;

			if ((ch == ")") && !openBrace)
			{
				allValid = false;
				break;
			}

			if (ch == ")")
			{
				closeBrace = true;
				openBrace = false;
			}

			if ((ch == "+") && (i != 0))
			{
				allValid = false;
				break;
			}

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}

			if (openBrace)

				allValid = false;

			if (!allValid)
			{
				alert("Please enter your council tax amount");
				theform.tax.focus();
				return (false);
			}



var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";

	var checkStr = theform.bank.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "bank name")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your bank details");
				theform.bank.focus();
				return (false);
			}
			
			
			

//validate street

var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, ";

	var checkStr = theform.empname.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "company name")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your employers name");
				theform.empname.focus();
				return (false);
			}
			
//validate street

var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, ";

	var checkStr = theform.job.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "job title")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your job title");
				theform.job.focus();
				return (false);
			}
			
			


//Validate rent

var checkDIS = "()+0123456789£,- ";

	var checkStr = theform.income.value;

	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

if (checkStr == "income/yr (£)")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);

			if (ch == "(")
				openBrace = true;

			if ((ch == ")") && !openBrace)
			{
				allValid = false;
				break;
			}

			if (ch == ")")
			{
				closeBrace = true;
				openBrace = false;
			}

			if ((ch == "+") && (i != 0))
			{
				allValid = false;
				break;
			}

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}

			if (openBrace)

				allValid = false;

			if (!allValid)
			{
				alert("Please enter annual income");
				theform.income.focus();
				return (false);
			}


//Validate yt

	var checkDIS = "()+0123456789- ";

	var checkStr = theform.time_job_m.value;
	//alert(checkStr);
	
	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "MM")
		allValid = false;

	
			if (!allValid)
			{
				alert("Please select months at work");
				theform.time_job_m.focus();
				return false;
			}
			


//Validate yt

	var checkDIS = "()+0123456789- ";

	var checkStr = theform.time_job_y.value;
	//alert(checkStr);
	
	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "YY")
		allValid = false;

	
			if (!allValid)
			{
				alert("Please select years at work");
				theform.time_job_y.focus();
				return false;
			}
			
			
//validate street

var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,, ";

	var checkStr = theform.street.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "house no & street")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter street");
				theform.street.focus();
				return (false);
			}
			
			
			

			
			//validate city

var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";

	var checkStr = theform.city.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "city")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your City");
				theform.city.focus();
				return (false);
			}
			
			
			
//validate postcode

var checkDIS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";

	var checkStr = theform.postcode.value;

	var allValid = true;

	if (checkStr == "")
		allValid = false;
if (checkStr == "postcode")
		allValid = false;
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}
			if (!allValid)
			{
				alert("Please enter your postcode");
				theform.postcode.focus();
				return (false);
			}


//validate HomeTel

var checkDIS = "()+0123456789- ";

	var checkStr = theform.emp_phone.value;

	var allValid = true;

	var openBrace = false;

	var closeBrace = false;

	if (checkStr == "")
		allValid = false;

if (checkStr == "contact tel")
		allValid = false;
		
	for (i = 0; i < checkStr.length; i++)
		{
			ch = checkStr.charAt(i);

			if (ch == "(")
				openBrace = true;

			if ((ch == ")") && !openBrace)
			{
				allValid = false;
				break;
			}

			if (ch == ")")
			{
				closeBrace = true;
				openBrace = false;
			}

			if ((ch == "+") && (i != 0))
			{
				allValid = false;
				break;
			}

			for (j = 0; j < checkDIS.length; j++)

			if (ch == checkDIS.charAt(j))
					break;
			if (j == checkDIS.length)
			{
				allValid = false;
				break;
			}
		}

			if (openBrace)
				allValid = false;

			if (!allValid)
			{
				alert("Please enter a number for your employer");
				theform.emp_phone.focus();
				return (false);
			}





return (true);

}