// JavaScript Document
function verifyFields(){
	
// receiving values

	var strSalutation=document.getElementById("salutation").value;
	var strFName=document.getElementById("fname").value;
	var strLName=document.getElementById("lname").value;
	var strIncome=document.getElementById("annual_income").value;
	var strHomeTel=document.getElementById("home_tel").value;
	var strOffTel=document.getElementById("off_tel").value;
	var strMobile=document.getElementById("mobile").value;
	var strHouseNo=document.getElementById("house_no").value;
	var strPostcode=document.getElementById("postcode").value;
	var strAmount=document.getElementById("amount_unsecured_debt").value;
	var strCreditors=document.getElementById("creditors").value;
	
// declaring and initializing variables
	
	var strErrorArray=[];
	var strErrorMsg="Please correct the following";
	strErrorMsg+="\n---------------------------------------------------\n---------------------------------------------------\n";
	
// checking values

	if(strSalutation==""){
		strErrorArray.push("Please select Salutation");
	}
	if(strFName==""){
		strErrorArray.push("Please fill in First Name");
	}
	if(strLName==""){
		strErrorArray.push("Please fill in Last Name");
	}
	if(strIncome==""){
		strErrorArray.push("Please fill in Annual Income");
	}else if(isNaN(strIncome)){
		strErrorArray.push("Please fill in valid Annual Income");
	}
	if(strHomeTel=="" && strOffTel=="" && strMobile==""){
		strErrorArray.push("Please specify atleast one Contact Number");
	}
	if(strHomeTel!=""){
		if(isNaN(strHomeTel)){
			strErrorArray.push("Please fill in valid Home Telephone Number");
		}
	}
	if(strOffTel!=""){
		if(isNaN(strOffTel)){
			strErrorArray.push("Please fill in valid Office Telephone Number");
		}
	}
	if(strMobile!=""){
		if(isNaN(strMobile)){
			strErrorArray.push("Please fill in valid Mobile Number");
		}
	}
	if(strHouseNo==""){
		strErrorArray.push("Please fill in House Name/No");
	}
	if(strPostcode==""){
		strErrorArray.push("Please fill in Postcode");
	}
	if(strAmount==""){
		strErrorArray.push("Please fill in Amount of Unsecured Debt");
	}else if(isNaN(strAmount)){
		strErrorArray.push("Please fill in valid Amount of Unsecured Debt");
	}
	if(strCreditors==""){
		strErrorArray.push("Please select Number of Creditors");
	}
	
// on error(s) dispalying them
	
	if(strErrorArray.length==0){
		return true;
	}else{
		for(var i=0;i<strErrorArray.length;i++){
			strErrorMsg+=(i+1)+". "+strErrorArray[i]+"\n";
		}
		alert(strErrorMsg);
		return false;
	}
	
}