/*   ////////////////////////////////////////////
	JavaScript Document :: trustcheck1.js
	version 1.1 24.6.03
	copyright (c) 2003, Chris Whincop, neurvana.com
	email: chrisATneurvanaDOTcom
	tel: +44 (0)1896 820161
	adapted from various Open Source scripts and
	released under the GPL, see:
	http://www.gnu.org/copyleft/gpl.html
 	No warranty, freely distributable and reusable.
	If you make improvements, please let me know.
	Thanks! 
///////////////////////////////////////// */
function validate() { 


//check a field to make sure it's not blank 
if(document.TrustIndem1.orgname.value == '') { 
alert('Please fill in the field: \n\nName of Charity\/Church'); 
document.TrustIndem1.orgname.focus(); 
return false; 
}

//check a field to make sure it's not blank 
if(document.TrustIndem1.orgaddress.value == '') { 
alert('Please fill in the field: \n\nAddress of principal office'); 
document.TrustIndem1.orgaddress.focus(); 
return false; 
}

//check a field to make sure it's not blank 
if(document.TrustIndem1.full_names_of_current_trustees.value == '') { 
alert('Please fill in the field: \n\nFull names of current trustees'); 
document.TrustIndem1.full_names_of_current_trustees.focus(); 
return false; 
}

//check a field to make sure it's not blank 
if(document.TrustIndem1.contname.value == '') { 
alert('Please fill in the field: \n\nContact Name'); 
document.TrustIndem1.contname.focus(); 
return false; 
}


/* 		NEW EMAIL PROCEDURE - 24.6.03 STARTS HERE 	*/

// offer the person the option of leaving the two email fields blank if they are both blank
if((document.TrustIndem1.contemail1a.value == '') && (document.TrustIndem1.contemail1b.value == '')) { 
if(!confirm("Are you sure you want to leave the two 'Contact Email Address' fields blank?\n\nPlease click on 'OK' to confirm, or click on 'Cancel' to go back and enter your email address.")) { 
document.TrustIndem1.contemail1a.focus(); 
return false; 
}
}
// check both email fields to make sure just the first isn't blank 
if((document.TrustIndem1.contemail1b.value != '') && (document.TrustIndem1.contemail1a.value == '')){ 
alert("It looks like you have filled in the second email field, but not the first.\n\nPlease EITHER:\n\n1. fill in the first email field: \n\n'Contact Email Address' \n\nOR:\n\n2. make sure the second email field is also empty"); 
document.TrustIndem1.contemail1a.focus(); 
return false; 
}
// check both email fields to make sure just the second isn't blank 
if((document.TrustIndem1.contemail1a.value != '') && (document.TrustIndem1.contemail1b.value == '')){ 
alert("It looks like you have filled in the first email field, but not the second.\n\nPlease EITHER:\n\n1. fill in the second email field: \n\n'Please retype the Contact Email Address...'\n\nOR:\n\n2. make sure the first email field is also empty"); 
document.TrustIndem1.contemail1b.focus(); 
return false; 
}

// check both email fields again, and this time, if neither is blank, proceed to check each of them for valid syntax
// if both are blank, do nothing
if((document.TrustIndem1.contemail1a.value != '') && (document.TrustIndem1.contemail1b.value != '')) { 
// check if email address entered has got valid syntax 
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.TrustIndem1.contemail1a.value))) { 
alert("What you\'ve entered in the first email field is not a valid email address!\n\nPlease check it for spaces and other typos."); 
document.TrustIndem1.contemail1a.focus(); 
return false; 
}  //end the first if within if
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.TrustIndem1.contemail1b.value))) { 
alert("What you\'ve entered in the second email field is not a valid email address!\n\nPlease check it for spaces and other typos."); 
document.TrustIndem1.contemail1b.focus(); 
return false; 
}  //end the second if within if
} //end the main if

// Now make sure that the two email addresses entered match
  if (document.TrustIndem1.contemail1a.value.toLowerCase() != document.TrustIndem1.contemail1b.value.toLowerCase()) {
alert("The two email addresses you\'ve just entered must match each other exactly!\n\nPlease check them both for spaces and other typos."); 
document.TrustIndem1.contemail1a.focus(); 
return false; 
} //end if 

/* 		NEW EMAIL PROCEDURE - 24.6.03 ENDS HERE 	*/


//check a field to make sure it's not blank 
if(document.TrustIndem1.contphone1.value == '') { 
alert('Please fill in the field: \n\nContact Telephone No.'); 
document.TrustIndem1.contphone1.focus(); 
return false; 
}

//check a field to make sure it's not blank 
if(document.TrustIndem1.when_established.value == '') { 
alert('Please fill in the field: \n\nWhen was the Church/Charity established?'); 
document.TrustIndem1.when_established.focus(); 
return false; 
}

//check two text fields and a checkbox to ensure that either at least one of the fields has something filled in or that the checkbox is checked 
if(((document.TrustIndem1.registered_in_Scotland.value == '') && (document.TrustIndem1.registered_in_E_or_W.value == '')) && (!document.TrustIndem1.in_E_or_W_but_not_required_to_register.checked)) { 
alert('Please fill in ONE of the following: \n\n5 a In Scotland and registered under...\n5 b In England or Wales and registered under...\nOR check the checkbox for 5 c: \n\nIn England or Wales but not required to register')  ; 
document.TrustIndem1.registered_in_Scotland.focus(); 
return false; 
}


//check a field to make sure it's not blank 
if(document.TrustIndem1.Principal_activities.value == '') { 
alert('Please fill in the field: \n\nPrincipal activities'); 
document.TrustIndem1.Principal_activities.focus(); 
return false; 
}




// radio name_changed_in_last_5_years
// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.name_changed_in_last_5_years); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to: \n\n7. During the last five years... \na) has the name changed?  \n \nSorry, but you MUST make a selection!"); 
document.TrustIndem1.name_changed_in_last_5_years[0].focus(); // and focus on the first option
return false; 
}

//IFF name_changed_in_last_5_years THEN name_change_details
var radioVal = valRadiobutton(document.TrustIndem1.name_changed_in_last_5_years); 
if((radioVal == 'Yes') && (document.TrustIndem1.name_change_details.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'7. During the last five years... \na) has the name changed?', \n\nplease fill in the field:\n\nIf YES, please give details"); 
document.TrustIndem1.name_change_details.focus(); 
return false; 
}







// radio merger_in_last_5_years
// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.merger_in_last_5_years); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to: \n\n7. During the last five years... \nb) has there been any amalgamation or merger with another Charity/Church? \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.merger_in_last_5_years[0].focus(); // and focus on the first option
return false; 
}
//IFF merger_in_last_5_years THEN merger_details
var radioVal = valRadiobutton(document.TrustIndem1.merger_in_last_5_years); 
if((radioVal == 'Yes') && (document.TrustIndem1.merger_details.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'7. During the last five years... \nb) has there been any amalgamation or merger with another Charity/Church?', \n\nplease fill in the field:\n\nIf YES, please give details"); 
document.TrustIndem1.merger_details.focus(); 
return false; 
}



//check a field to make sure it's not blank 
if(document.TrustIndem1.date_of_last_accounts.value == '') { 
alert('Please fill in the field: \n\nTo what date were the last accounts made up?'); 
document.TrustIndem1.date_of_last_accounts.focus(); 
return false; 
}



//radio accounts_audited
// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.accounts_audited); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to: \n\n8. b) Were those accounts audited or 'independently examined' and given an unqualified report? \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.accounts_audited[0].focus(); // and focus on the first option
return false; 
}



//check a field to make sure it's not blank without OR with pound sign
if((document.TrustIndem1.gross_annual_income.value == '') || (document.TrustIndem1.gross_annual_income.value == '£')) { 
alert('Please fill in the field: \n\nState the gross annual income shown in those accounts'); 
document.TrustIndem1.gross_annual_income.focus(); 
return false; 
}

//check a field to make sure it's not blank without OR with pound sign
if((document.TrustIndem1.total_gross_assets.value == '') || (document.TrustIndem1.total_gross_assets.value == '£')) { 
alert('Please fill in the field: \n\nState the total gross assets... ...shown in the last balance sheet'); 
document.TrustIndem1.total_gross_assets.focus(); 
return false; 
}




//radio incorporated_as_a_body_corporate
// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.incorporated_as_a_body_corporate); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to: \n\n9. a) Is any Charity/Church named at (1) above incorporated as a body corporate? \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.incorporated_as_a_body_corporate[0].focus(); // and focus on the first option
return false; 
}


//radio separately_incorporated_company
// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.separately_incorporated_company); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to: \n\n9. b) Does any Charity/Church named at (1) above  \n(whether or not incorporated) carry out any of its activity through any separately incorporated company (e.g. a trading subsidiary)? \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.separately_incorporated_company[0].focus(); // and focus on the first option
return false; 
}




//IFF incorporated_as_a_body_corporate OR separately_incorporated_company THEN companies_concerned
var radioVal1 = valRadiobutton(document.TrustIndem1.incorporated_as_a_body_corporate);
var radioVal2 = valRadiobutton(document.TrustIndem1.separately_incorporated_company);
// Check the value of the FIRST radio button group in question
if(((radioVal1 == 'Yes') ||
// Check the value of the SECOND radio button group in question
(radioVal2 == 'Yes')) &&
// Check for blank field
(document.TrustIndem1.companies_concerned.value == '')) { 
alert("As you have answered 'Yes' to EITHER: \n\n9. a) Is any Charity/Church named at (1) above incorporated as a body corporate? \n\nOR: \n\n9. b) Does any Charity/Church named at (1) above (whether or not incorporated) carry out any of its activity through any separately incorporated company (e.g. a trading subsidiary)? \n\nor BOTH, please provide all of the additional information required:\n\ni) the name and description of all companies concerned (referred to collectively hereinafter as 'the Companies'), indicating how and  when each was incorporated (e.g. the relevant legislation or other legal authority), the relationship between the Charity/Church and the Companies and the activity carried on by each\n\nAND \n\nii) the full name of each person (not already named at (3) above) who is or is considered to be a director or other officer of any of the Companies. In each case please also state all such positions held and in which of the Companies."); 
document.TrustIndem1.companies_concerned.focus();  // and focus on the blank field
return false; 
}






//radio fin_leg_advice
// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.fin_leg_advice); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to:\n\nDoes the Charity provide... ...Financial or legal advice?  \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.fin_leg_advice[0].focus(); // and focus on the first option
return false; 
}


//radio counselling
// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.counselling); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to:\n\nDoes the Charity provide... ...Counselling?  \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.counselling[0].focus(); // and focus on the first option
return false; 
}


//radio medical_advice
// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.medical_advice); 

//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to:\n\nDoes the Charity provide... ...Medical advice, diagnosis or treatment?  \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.medical_advice[0].focus(); // and focus on the first option
return false; 
}


//radio other_advice
// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.other_advice); 

//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to:\n\nDoes the Charity provide... ...Other? \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.other_advice[0].focus(); // and focus on the first option
return false; 
}



//IFF fin_leg_advice THEN details_of_fin_legal_advice
var radioVal = valRadiobutton(document.TrustIndem1.fin_leg_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.details_of_fin_legal_advice.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Financial or legal advice?', \n\nplease fill in the field:\n\n11. a) Give details of type of financial or legal advice provided"); 
document.TrustIndem1.details_of_fin_legal_advice.focus(); 
return false; 
}
//IFF fin_leg_advice THEN finleg_partimers
var radioVal = valRadiobutton(document.TrustIndem1.fin_leg_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.finleg_partimers.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Financial or legal advice?', \n\nplease fill in the field:\n\n11. b) How many people provide it? \n\nPart Time"); 
document.TrustIndem1.finleg_partimers.focus(); 
return false; 
}
//IFF fin_leg_advice THEN finleg_fulltimers
var radioVal = valRadiobutton(document.TrustIndem1.fin_leg_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.finleg_fulltimers.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Financial or legal advice?', \n\nplease fill in the field:\n\n11. b) How many people provide it? \n\nFull Time"); 
document.TrustIndem1.finleg_fulltimers.focus(); 
return false; 
}
//IFF fin_leg_advice THEN finleg_qualifications
var radioVal = valRadiobutton(document.TrustIndem1.fin_leg_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.finleg_qualifications.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Financial or legal advice?', \n\nplease fill in the field:\n\n11. c) What is the qualification/background/experience of the people who provide it?"); 
document.TrustIndem1.finleg_qualifications.focus(); 
return false; 
}
//IFF fin_leg_advice THEN finleg_enquiries_per_annum
var radioVal = valRadiobutton(document.TrustIndem1.fin_leg_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.finleg_enquiries_per_annum.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Financial or legal advice?', \n\nplease fill in the field:\n\n11. d) approximate number of enquiries per annum?"); 
document.TrustIndem1.finleg_enquiries_per_annum.focus(); 
return false; 
}



//IFF counselling THEN details_of_counselling
var radioVal = valRadiobutton(document.TrustIndem1.counselling); 
if((radioVal == 'Yes') && (document.TrustIndem1.details_of_counselling.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Counselling?', \n\nplease fill in the field:\n\n12. a) Give details of the type of counselling provided"); 
document.TrustIndem1.details_of_counselling.focus(); 
return false; 
}
//IFF counselling THEN counselling_partimers
var radioVal = valRadiobutton(document.TrustIndem1.counselling); 
if((radioVal == 'Yes') && (document.TrustIndem1.counselling_partimers.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Counselling?', \n\nplease fill in the field:\n\n12. b) How many people provide it? \n\nPart Time"); 
document.TrustIndem1.counselling_partimers.focus(); 
return false; 
}
//IFF counselling THEN counselling_fulltimers
var radioVal = valRadiobutton(document.TrustIndem1.counselling); 
if((radioVal == 'Yes') && (document.TrustIndem1.counselling_fulltimers.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Counselling?', \n\nplease fill in the field:\n\n12. b) How many people provide it? \n\nFull Time"); 
document.TrustIndem1.counselling_fulltimers.focus();
return false; 
}
//IFF counselling THEN counselling_qualifications
var radioVal = valRadiobutton(document.TrustIndem1.counselling); 
if((radioVal == 'Yes') && (document.TrustIndem1.counselling_qualifications.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Counselling?', \n\nplease fill in the field:\n\n12. c) What is the qualification/background/experience of the people who provide it?");
document.TrustIndem1.counselling_qualifications.focus(); 
return false; 
}
//IFF counselling THEN counselling_enquiries_per_annum
var radioVal = valRadiobutton(document.TrustIndem1.counselling); 
if((radioVal == 'Yes') && (document.TrustIndem1.counselling_enquiries_per_annum.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Counselling?', \n\nplease fill in the field:\n\n12. d) approximate number of enquiries per annum?"); 
document.TrustIndem1.counselling_enquiries_per_annum.focus(); 
return false; 
}




//IFF fin_leg_advice OR counselling THEN require finleg_procedures [textarea]
//IFF incorporated_as_a_body_corporate OR separately_incorporated_company THEN companies_concerned
var radioVal1 = valRadiobutton(document.TrustIndem1.fin_leg_advice);
var radioVal2 = valRadiobutton(document.TrustIndem1.counselling);
// Check the value of the FIRST radio button group in question
if(((radioVal1 == 'Yes') ||
// Check the value of the SECOND radio button group in question
(radioVal2 == 'Yes')) &&
// Check for blank field
(document.TrustIndem1.finleg_procedures.value == '')) { 
alert("As you have answered 'Yes' to EITHER: \n\nDoes the Charity provide... ...Financial or legal advice? \n\nOR: \n\nDoes the Charity provide... ...Counselling? \n\nor BOTH, please provide a response to:\n\n13. a) Where counselling or financial or legal advice is provided, give details of present procedures/guidelines which identify situations where the person being counselled/advised should be encouraged to seek independent professional advice"); 
document.TrustIndem1.finleg_procedures.focus();  // and focus on the blank field
return false; 
}

//IFF fin_leg_advice OR counselling THEN require finleg_recommend_advisors [radio]
//IFF incorporated_as_a_body_corporate OR separately_incorporated_company THEN companies_concerned
var radioVal1 = valRadiobutton(document.TrustIndem1.fin_leg_advice);
var radioVal2 = valRadiobutton(document.TrustIndem1.counselling);
var radioVal3 = valRadiobutton(document.TrustIndem1.finleg_recommend_advisors);
// Check the value of the FIRST radio button group in question
if(((radioVal1 == 'Yes') ||
// Check the value of the SECOND radio button group in question
(radioVal2 == 'Yes')) &&
// Check for blank field
(radioVal3 == '')) { 
alert("As you have answered 'Yes' to EITHER: \n\nDoes the Charity provide... ...Financial or legal advice? \n\nOR: \n\nDoes the Charity provide... ...Counselling? \n\nor BOTH, please provide a response to:\n\n13. b) Where such independent advice is appropriate, is it usual practice to recommend one or more named advisors?"); 
document.TrustIndem1.finleg_recommend_advisors[0].focus(); // and focus on the first option
return false; 
}



//IFF medical_advice THEN details_of_med_advice
var radioVal = valRadiobutton(document.TrustIndem1.medical_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.details_of_med_advice.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Medical advice, diagnosis or treatment?', \n\nplease fill in the field:\n\n14. Give details of medical advice, diagnosis or treatment provided"); 
document.TrustIndem1.details_of_med_advice.focus(); 
return false; 
}
// but NOT, notice: IFF medical_advice THEN medical_partimers -> medical_enquiries_per_annum! - because not one is on the form





//IFF other_advice THEN details_of_other_services
var radioVal = valRadiobutton(document.TrustIndem1.other_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.details_of_other_services.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Other?', \n\nplease fill in the field:\n\n15. a) Give full details of other services (e.g. advice, information, assistance, design) provided"); 
document.TrustIndem1.details_of_other_services.focus(); 
return false; 
}
//IFF other_advice THEN other_partimers
var radioVal = valRadiobutton(document.TrustIndem1.other_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.other_partimers.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Other?', \n\nplease fill in the field:\n\n15. b) How many people provide it? \n\nPart Time"); 
document.TrustIndem1.other_partimers.focus(); 
return false; 
}
//IFF other_advice THEN other_fulltimers
var radioVal = valRadiobutton(document.TrustIndem1.other_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.other_fulltimers.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Other?', \n\nplease fill in the field:\n\n15. b) How many people provide it? \n\nFull Time"); 
document.TrustIndem1.other_fulltimers.focus(); 
return false; 
}
//IFF other_advice THEN other_qualifications
var radioVal = valRadiobutton(document.TrustIndem1.other_advice); 
if((radioVal == 'Yes') && (document.TrustIndem1.other_qualifications.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'Does the Charity provide... ...Other?', \n\nplease fill in the field:\n\n15. c) What is the qualification/background/experience of the people who provide it?"); 
document.TrustIndem1.other_qualifications.focus(); 
return false; 
}
// but NOT, notice: IFF other_advice THEN other_enquiries_per_annum! - because it doesn't exist






//radio refusal_or_cancellation
var radioVal = valRadiobutton(document.TrustIndem1.refusal_or_cancellation); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to:\n\n16. Has the Charity, any of the Companies or any past or present Trustee been refused this type of insurance or had a similar insurance cancelled? \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.refusal_or_cancellation[0].focus(); // and focus on the first option
return false; 
}
//IFF refusal_or_cancellation THEN details_of_refusal
var radioVal = valRadiobutton(document.TrustIndem1.refusal_or_cancellation); 
if((radioVal == 'Yes') && (document.TrustIndem1.details_of_refusal.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'16. Has the Charity, any of the Companies or any past or present Trustee been refused this type of insurance or had a similar insurance cancelled?', \n\nplease fill in the field:\n\nIf YES, please give details:"); 
document.TrustIndem1.details_of_refusal.focus(); 
return false; 
}


//radio claim_in_last_5_yrs
var radioVal = valRadiobutton(document.TrustIndem1.claim_in_last_5_yrs); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to:\n\n17. Has any claim that might have fallen within the scope of the proposed insurance been made during the last five years against the Charity, any of the Companies or any past or present Trustee? \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.claim_in_last_5_yrs[0].focus(); // and focus on the first option
return false; 
}
//IFF claim_in_last_5_yrs THEN details_of_claims_made
var radioVal = valRadiobutton(document.TrustIndem1.claim_in_last_5_yrs); 
if((radioVal == 'Yes') && (document.TrustIndem1.details_of_claims_made.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'17. Has any claim that might have fallen within the scope of the proposed insurance been made during the last five years against the Charity, any of the Companies or any past or present Trustee?', \n\nplease fill in the field:\n\nIf YES, please give details:"); 
document.TrustIndem1.details_of_claims_made.focus(); 
return false; 
}

//radio aware_of_possible_future_claim
var radioVal = valRadiobutton(document.TrustIndem1.aware_of_possible_future_claim); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to:\n\n18. Is the Charity, any of the Companies or any present Trustee aware, after enquiry, of any circumstance or incident which it or he/she has reason to suppose might result in any future claim which would fall within the scope of the proposed insurance? \n\nSorry, but you MUST make a selection!"); 
document.TrustIndem1.aware_of_possible_future_claim[0].focus(); // and focus on the first option
return false; 
}
//IFF aware_of_possible_future_claim THEN details_of_awareness_of_impending_claim
var radioVal = valRadiobutton(document.TrustIndem1.aware_of_possible_future_claim); 
if((radioVal == 'Yes') && (document.TrustIndem1.details_of_awareness_of_impending_claim.value == '')) { 
alert("As you have answered 'Yes' to the question:\n\n'18. Is the Charity, any of the Companies or any present Trustee aware, after enquiry, of any circumstance or incident which it or he/she has reason to suppose might result in any future claim which would fall within the scope of the proposed insurance?', \n\nplease fill in the field:\n\nIf YES, please give details:"); 
document.TrustIndem1.details_of_awareness_of_impending_claim.focus(); 
return false; 
}




// Get the value of the radio button group in question
// valRadioButton is a function we define down below 
var radioVal = valRadiobutton(document.TrustIndem1.resubmitting); 
//make sure that the user actually selected one of the radio buttons: 
if (radioVal == '') { 
alert("It looks like you forgot to click on your choice in response to the \n'Are you resubmitting...' question. \n \nSorry, but you MUST make a selection!"); 
document.TrustIndem1.resubmitting[0].focus(); // and focus on the first option
return false; 
}



//check for two conditions within a single field to make sure something else is filled in 
if((document.TrustIndem1.Full_Name_1.value == '') || (document.TrustIndem1.Full_Name_1.value == 'your full name')) { 
alert('Please fill in the first \'your full name\' field, in the declaration, with: \n\nyour full name'); 
document.TrustIndem1.Full_Name_1.focus(); 
return false; 
}


//check for two conditions within a single field to make sure something else is filled in
if((document.TrustIndem1.Full_Name_2.value == '') || (document.TrustIndem1.Full_Name_2.value == 'your full name')) { 
alert('Please fill in the second  \'your full name\' field, just after the declaration, with: \n\nyour full name'); 
document.TrustIndem1.Full_Name_2.focus(); 
return false; 
}


//check a field to make sure it's not blank 
if(document.TrustIndem1.date.value == '') { 
alert('Please fill in the field: \n\nDate'); 
document.TrustIndem1.date.focus(); 
return false; 
}



//if the checking gets this far, everything checked is OK 

return; 

}// end function: validate 



/*  this function gets the value of a required radio group */
function valRadiobutton(radiobutton) { 
myOption = -1; 
for (i=0; i< radiobutton.length; i++) { 
if (radiobutton[i].checked) { 
myOption = i; 
}
}
if (myOption == -1) { 
return ""; 
} else { 
return radiobutton[myOption].value 
}
}// end function: valRadioButton 


//EOF

