function voidCheckForm(form)
	{
	var message = "";
	var setf = 1;
	var intBDay = form.date.value;
	var intBMonth = form.month.value;
	var intBYear = form.year.value;

	if ((form.date.value == "0") || (form.month.value == "0") || (form.year.value == "0"))
		{
		alert("Please fill in your date of birth.\n\n" + message);
		if (setf) {form.date.focus(); setf = 0;}
		return false;
		}

	var monthMaxDays = new Array(31,31,28,31,30,31,30,31,31,30,31,30,31)
	if ((intBMonth == 2) && (intBYear != 2000))
		{
		if ((intBYear % 4) == 0)
			monthMaxDays[2] = 29;
		}
		
	var monthMaxDay = monthMaxDays[parseInt(intBMonth)]
	if (parseInt(intBDay) > monthMaxDay) 
		{
		message = message + "\t* " + "Invalid date of birth entered - please amend.\n";
		if (setf) {form.date.focus(); setf = 0;}
		}

	var dtToday = new Date;
	var intTYear = dtToday.getYear();
	var intTMonth = dtToday.getMonth() + 1;
	var intTDate = dtToday.getDate();
	
	if (intTYear < 1000) {intTYear += 1900};
	
	var dtUtcCurrent = Date.UTC(intTYear, intTMonth, intTDate);
	var dtUtcBDay = Date.UTC(intBYear, intBMonth, intBDay);
	var intAgeMs = dtUtcCurrent - dtUtcBDay
	form.yrs.value = parseInt(((((intAgeMs/1000)/60)/60)/24)/365.25+.001,10); 
	
	if ((form.plan[0].checked || form.plan[1].checked) && parseInt(form.yrs.value) < 21)
      	{
       	alert("Unfortunately your age is below the minimum required of 21 for the plan.");
       	return(false);
      	}

 	if ((form.plan[0].checked || form.plan[1].checked) == false  && parseInt(form.yrs.value) < 21)
    	{
       	alert("Unfortunately your age is below the minimum required of 21 for the plan.");
       	return(false);
      	}

	if (form.fblnIncludeSpousePartner.checked == true)
		{
		intBDay = form.SpouseDate.value;
		intBMonth = form.SpouseMonth.value;
		intBYear = form.SpouseYear.value;
		
		if ((form.SpouseDate.value == "0") || (form.SpouseMonth.value == "0") || (form.SpouseYear.value == "0"))
			{
			alert("Please fill in your spouse/partner's date of birth.\n\n" + message);
			if (setf) {form.SpouseDate.focus(); setf = 0;}
			return false;
			}
	
		
		if ((intBMonth == 2) && (intBYear != 2000))
			{
			if ((intBYear % 4) == 0)
				monthMaxDays[2] = 29;
			}
			
		var monthMaxDay = monthMaxDays[parseInt(intBMonth)]
		if (parseInt(intBDay) > monthMaxDay) 
			{
			message = message + "\t* " + "Invalid spouse/partner date of birth entered - please amend.\n";
			if (setf) {form.SpouseDate.focus(); setf = 0;}
			}
		if (intTYear < 1000) {intTYear += 1900};
		
		dtUtcBDay = Date.UTC(intBYear, intBMonth, intBDay);
		intAgeMs = dtUtcCurrent - dtUtcBDay
		form.SpouseYrs.value = parseInt(((((intAgeMs/1000)/60)/60)/24)/365.25+0.001,10); 
		
		if ((form.SpousePlan[0].checked || form.SpousePlan[1].checked) && parseInt(form.SpouseYrs.value) < 21)
	      	{
	       	alert("Unfortunately the age of your spouse/partner is below the minimum required of 21 for the plan.");
	       	return(false);
	      	}
	
	 	if ((form.SpousePlan[0].checked || form.SpousePlan[1].checked) == false  && parseInt(form.SpouseYrs.value) < 21)
	    	{
	       	alert("Unfortunately the age of your spouse/partner is below the minimum required of 21 for the plan.");
	       	return(false);
	      	}
		}		
	if (isNaN(form.PP.value))
		{
		form.PP.value = 0;
		}

	if (trim(form.Title.value) == "") 
		{
		message = message + "\t* " + "Title\n";
		if (setf) {form.Title.focus(); setf = 0;}
		}
		
	if (trim(form.initials.value) == "") 
		{
		message = message + "\t* " + "Initials\n";
		if (setf) {form.initials.focus(); setf = 0;}
		}
		
	if (trim(form.Surname.value) == "") 
		{
		message = message + "\t* " + "Surname\n";
		if (setf) {form.Surname.focus(); setf = 0;}
		}
		
	if (trim(form.address1.value) == "") 
		{
		message = message + "\t* " + "Address\n";
		if (setf) {form.address1.focus(); setf = 0;}
		}
		
	if (trim(form.postcode.value) == "") 
		{
		message = message + "\t* " + "Postcode\n";
		if (setf) {form.postcode.focus(); setf = 0;}
		}
		
	if (trim(form.email.value) == "") 
		{
		message = message + "\t* " + "Email\n";
		if (setf) {form.email.focus(); setf = 0;}
		}
	else
		{
		if (!isEmailAddr(form.email.value))
			{
			message = message + "\t* " + "Email must be of the form: 'yourname@yourdomain.com'\n";
			if (setf) {form.email.focus(); setf = 0;}		
			}
		}
		
		
	if ((form.pending[1].checked == true) && (trim(form.pendingq.value) == ""))
		{
		message = message + "\t* " + "You have indicated that you have a pending prosecution, please enter the details\n";
		if (setf) {form.pendingq.focus(); setf = 0;}
		}
		
   	if ((form.medical[1].checked == true) && (form.medicalq.value==""))
      	{
		message = message + "\t* " + "You have indicated that you have a medical condition, please enter the details\n";
		if (setf) {form.medicalq.focus(); setf = 0;}
      	}

	if (form.fblnIncludeSpousePartner.checked == true)
		{
			
		if (isNaN(form.SpousePP.value))
			{
			form.SpousePP.value = 0;
			}
		
		if (trim(form.SpouseTitle.value) == "") 
			{
			message = message + "\t* " + "spouse/partner title\n";
			if (setf) {form.SpouseTitle.focus(); setf = 0;}
			}
			
		if (trim(form.SpouseInitials.value) == "") 
			{
			message = message + "\t* " + "spouse/partner initials\n";
			if (setf) {form.SpouseInitials.focus(); setf = 0;}
			}
			
		if (trim(form.SpouseSurname.value) == "") 
			{
			message = message + "\t* " + "spouse/partner surname\n";
			if (setf) {form.SpouseSurname.focus(); setf = 0;}
			}
			
		if (trim(form.SpouseAddress1.value) == "") 
			{
			message = message + "\t* " + "spouse/partner address\n";
			if (setf) {form.SpouseAddress1.focus(); setf = 0;}
			}
			
		if (trim(form.SpousePostcode.value) == "") 
			{
			message = message + "\t* " + "spouse/partner postcode\n";
			if (setf) {form.SpousePostcode.focus(); setf = 0;}
			}
			
		if ((form.SpousePending[1].checked == true) && (trim(form.SpousePendingq.value) == ""))
			{
			message = message + "\t* " + "You have indicated that your spouse/partner has a pending prosecution, please enter the details\n";
			if (setf) {form.SpousePendingq.focus(); setf = 0;}
			}
			
	   	if ((form.SpouseMedical[1].checked == true) && (form.SpouseMedicalq.value==""))
	      	{
			message = message + "\t* " + "You have indicated that your spouse/partner has a medical condition, please enter the details\n";
			if (setf) {form.SpouseMedicalq.focus(); setf = 0;}
	      	}
		}
		
	if (form.agree.checked != true)
		{
		message = message + "\t* " + "Your agreement to the policy conditions\n";
		if (setf) {form.agree.focus(); setf = 0;}
		}

	if (message != "")
		{
		alert("The following items on your form were not filled in correctly:\n\n" + message);
		return (false);
		}		
		
	form.submit();
	}
	
function voidCheckClaimForm(form)
	{
	var message = '';
	var setf = 1;
	
	if (trim(form.initials.value) == "") 
		{
		message = message + "\t* " + "Initials\n";
		if (setf) {form.initials.focus(); setf = 0;}
		}
		
	if (trim(form.Surname.value) == "") 
		{
		message = message + "\t* " + "Surname\n";
		if (setf) {form.Surname.focus(); setf = 0;}
		}

	if (trim(form.email.value) == "") 
		{
		message = message + "\t* " + "Email\n";
		if (setf) {form.email.focus(); setf = 0;}
		}
	else
		{
		if (!isEmailAddr(form.email.value))
			{
			message = message + "\t* " + "Email must be of the form: 'yourname@yourdomain.com'\n";
			if (setf) {form.email.focus(); setf = 0;}		
			}
		}
		
	if (trim(form.DrivingLicenceNumber.value) == "") 
		{
		message = message + "\t* " + "Driving licence number\n";
		if (setf) {form.DrivingLicenceNumber.focus(); setf = 0;}
		}

	if (trim(form.PolicyNumber.value) == "") 
		{
		message = message + "\t* " + "Policy number\n";
		if (setf) {form.PolicyNumber.focus(); setf = 0;}
		}

	if (message != "")
		{
		alert("The following items on your form were not filled in correctly:\n\n" + message);
		return (false);
		}		
		
				
	form.submit();
	}

function voidCheckUpgrade1(form)
	{
	var message = '';
	var setf = 1;
	
	if (trim(form.initials.value) == "") 
		{
		message = message + "\t* " + "Initials\n";
		if (setf) {form.initials.focus(); setf = 0;}
		}
		
	if (trim(form.Surname.value) == "") 
		{
		message = message + "\t* " + "Surname\n";
		if (setf) {form.Surname.focus(); setf = 0;}
		}

	if (trim(form.email.value) == "") 
		{
		message = message + "\t* " + "Email\n";
		if (setf) {form.email.focus(); setf = 0;}
		}
	else
		{
		if (!isEmailAddr(form.email.value))
			{
			message = message + "\t* " + "Email must be of the form: 'yourname@yourdomain.com'\n";
			if (setf) {form.email.focus(); setf = 0;}		
			}
		}
		
	if (trim(form.PolicyNumber.value) == "") 
		{
		message = message + "\t* " + "Policy number\n";
		if (setf) {form.PolicyNumber.focus(); setf = 0;}
		}

	if (message != "")
		{
		alert("The following items on your form were not filled in correctly:\n\n" + message);
		return (false);
		}		
		
				
	form.submit();
	}

	function voidCheckUpgrade2(form)
		{
		form.submit();
		}

	
function voidCheckUpgrade2(form)
		{
		form.submit();
		}

function trim (InString)  
	{
	OutString = "";
	if (InString) 
		{
		for (Count=0; Count < InString.length; Count++)  
			{
			TempChar=InString.substring (Count, Count+1);
			if (TempChar != " ") 
				{
				OutString=OutString + TempChar;
				}
			} 				
		}
	return (OutString);
	}

function isEmailAddr(email)
	{
  	var result = false
  	var theStr = new String(email)
  	var index = theStr.indexOf("@");
  	if (index > 0)
  		{
    	var pindex = theStr.indexOf(".",index);
    	if ((pindex > index+1) && (theStr.length > pindex+1))
			{
			result = true;
			}
  		}
  	return result;
	}

function hs()
	{
	objBlock = document.getElementById('spa');
    if (objBlock.style.display == 'none')
		{
		objBlock.style.display = 'block';
		objBlock.style.visibility = 'visible';
		document.request.fblnIncludeSpousePartner.checked = true;
		}
	else
		{
		objBlock.style.display = 'none';
		objBlock.style.visibility = 'hidden';
		document.request.fblnIncludeSpousePartner.checked = false;
		}
	}

function voidShowSP()
	{
	var objSP = document.getElementById('spa');	

	if (document.request.fblnIncludeSpousePartner.checked == true)
		{
		objSP.style.display = 'block';
		objSP.style.visibility = 'visible';
		}
	else
		{
		objSP.style.display = 'none';
		objSP.style.visibility = 'hidden';
		}	
	calctot();	
	}
	

function calctot()
{
with (document.request)
	{
	if (fblnIncludeSpousePartner.checked == true)
		{
		var decProposerAmount = parseInt(ProposerAmount.value*100);
		var decSpouseAmount = parseInt(SpouseAmount.value*100);
		var decProposerDiscountedAmount = 0.0;
		var decSpouseDiscountedAmount = 0.0;
		
		var decTotal;
		if (decProposerAmount > decSpouseAmount)
			{
			decSpouseDiscountedAmount = (decSpouseAmount/2);
			decTotal = decProposerAmount + decSpouseDiscountedAmount;
			}
		else
			{
			decProposerDiscountedAmount = (decProposerAmount/2);
			decTotal = decProposerDiscountedAmount + decSpouseAmount;
			}
		amount.value = trim(Addzero(parseInt(decTotal)/100));
		ProposerDiscountedAmount.value = parseInt(decProposerDiscountedAmount)/100;
		SpouseDiscountedAmount.value = parseInt(decSpouseDiscountedAmount)/100;
		}
	else
		{
		amount.value = trim(ProposerAmount.value);
		ProposerDiscountedAmount.value = 0;
		SpouseDiscountedAmount.value = 0;
		}
	}
}

function Addzero(value1) 
{   
        invalue = " " + value1;
        wherepoint = invalue.indexOf(".");
        vallength    = invalue.length;
        needzero = vallength - wherepoint;
	valueplus1 = invalue + "0";
	valueplus2 = invalue + ".00";
	newvalue = (needzero == 2) ? valueplus1 : invalue;
	newvalue = (wherepoint == -1) ? valueplus2 : newvalue;
	return newvalue;
}
	
function CopyAddress()
{
with (document.request)
	{
	SpouseAddress1.value = address1.value;
	SpouseAddress2.value = address2.value;
	SpouseAddress3.value = address3.value;
	SpouseAddress4.value = address4.value;
	SpousePostcode.value = postcode.value;
	}
}

function CopyPhone()
{
with (document.request)
	{
	SpouseTelephone.value = telephone.value;
	}
}

function voidpp(objValue)
	{
	if (objValue.selectedIndex == 9)
		{
			alert("Please note that for 9 points on the applicant's licence at the time of application, the maximum benefit in any 12 months will be £3000, until their points have reduced to 8 or less and they have advised us in writing and provided us with a copy of their driving licence. For further information about this please contact us on 0845 519 4259.")
		}
	}