//Functionality for Life Insurance Claim and Annuity Forms
function getActionPath(){
	var url = String(document.location).split('//');
	var urlArr = url[1].split('/');

	return	"/" + urlArr[1] + "/tools_and_forms/claims";
}

function validate(){

	var q1 = document.getElementsByName("q1");
	var q2 = document.getElementsByName("q2");	
	var q3 = document.getElementsByName("q3");
	var q4 = document.getElementsByName("q4");
	var q5 = document.getElementsByName("q5");

	var yes = 0;
	var no = 1;

//If it's the Annuity Form
		if(document.getElementById("annuity")){

			for(i=1;i<=2;i++){
			var checkYes = eval("q" + i + "["+ yes +"]" +".checked");
			var checkNo = eval("q" + i + "["+ no +"]" +".checked");
			if(checkYes ==false && checkNo==false){
				alert("Please answer all the questions");
				return false;
				}
		}
	
		var Index = document.getElementById("annuity").selectedIndex;
		var selValue = document.getElementById("annuity").options[Index].value;


			if(q1[yes].checked && q2[yes].checked && selValue!="No" ){
				if(selValue=="Fixed"){
					document.AnnuityClaims.action=getActionPath() + "/annuity_claims/annuity_legal_entity_postableForm.html";
				} else if(selValue="Variable"){
					document.AnnuityClaims.action=getActionPath() + "/annuity_claims/variable_annuity_legal_postableForm.html";
				   } 
			} else{
				document.AnnuityClaims.action=getActionPath() + "/annuity_claims/annuity_claims_-_please_postableForm.html";
			  }

//If it's the Life Insurance Claim
		} else{

			for(i=1;i<=5;i++){
			var checkYes = eval("q" + i + "["+ yes +"]" +".checked");
			var checkNo = eval("q" + i + "["+ no +"]" +".checked");
			if(checkYes ==false && checkNo==false){
				alert("Please answer all the questions");
				return false;
				}
			}
	
			if(q1[yes].checked && q2[yes].checked && q3[yes].checked && q4[no].checked && q5[no].checked){
				document.LifeInsuranceForm.action=getActionPath() + "/life_insurance_claims/life_insurance_legal_postableForm.html";
			} else {
					document.LifeInsuranceForm.action=getActionPath() + "/life_insurance_claims/life_insurance_claims0_postableForm.html";
			}
		}

}
