﻿// array of every field to vaildatevar radioFields = new Array('seven_evidence_and_treatments', 'seven_fundamentals_ofoncology', 'seven_coordination_of_care', 'seven_multidisciplinary_care', 'seven_supportive_care', 'seven_palliative_care', 'seven_indigenous', 'seven_cald', 'seven_paediatric', 'seven_primary_care', 'seven_aya', 'seven_work_life_balance', 'eight_mdc', 'eight_frontline', 'eight_psychosocial', 'ten_getting_started', 'ten_frameworks', 'ten_key_docs', 'ten_case_studies', 'ten_cpi', 'ten_consumer', 'ten_mentoring', 'twelve_forprof', 'twelve_pd_plan', 'twelve_clinical_research', 'twelve_dietetics', 'twelve_nursing', 'twelve_pharmacy', 'twelve_physiotherapy', 'twelve_radiation', 'twelve_social_work', 'twelve_prof_bodies_pdf', 'twelve_for_networks', 'twelve_cpd_accreditation', 'twelve_work_life');// validate the form and then submitfunction validateSurvey(){		var errors = false;	/*	var myForm = getElement('survey_one');		// check question one PROFESSION	if ( myForm.fld_profession.selectedIndex == 0 )    {        errors = true;		myEl = getElement('one_profession');		myEl.className = 'question_title_red';		myEl = null;		    }else if(myForm.fld_profession.getElementsByTagName('option')[myForm.fld_profession.selectedIndex].value == "other" && myForm.other_one.value == ""){			errors = true;		myEl = getElement('one_profession');		myEl.className = 'question_title_red';		myEl = null;		}else{		myEl = getElement('one_profession');		myEl.className = 'question_title';		myEl = null;				}		// check question two GENDER	if ( myForm.fld_gender.selectedIndex == 0 )    {        errors = true;		myEl = getElement('two_gender');		myEl.className = 'question_title_red';		myEl = null;		    }else{			myEl = getElement('two_gender');		myEl.className = 'question_title';		myEl = null;		}		// check question three WORK AREA	if ( myForm.fld_work_area.selectedIndex == 0 )    {        errors = true;		myEl = getElement('three_work_area');		myEl.className = 'question_title_red';		myEl = null;		    }else{			myEl = getElement('three_work_area');		myEl.className = 'question_title';		myEl = null;		}		// check question four STATE	if ( myForm.fld_state.selectedIndex == 0 )    {        errors = true;		myEl = getElement('four_State');		myEl.className = 'question_title_red';		myEl = null;		    }else{			myEl = getElement('four_State');		myEl.className = 'question_title';		myEl = null;		}		// check question five EXPERINCE LEVEL	if ( myForm.fld_experience.selectedIndex == 0 )    {        errors = true;		myEl = getElement('five_experience_level');		myEl.className = 'question_title_red';		myEl = null;		    }else{			myEl = getElement('five_experience_level');		myEl.className = 'question_title';		myEl = null;		}		// check question six HOW DID YOU FIND US	if ( myForm.fld_how_find.selectedIndex == 0 )    {        errors = true;		myEl = getElement('six_how_find');		myEl.className = 'question_title_red';		myEl = null;		    }else if(myForm.fld_how_find.getElementsByTagName('option')[myForm.fld_how_find.selectedIndex].value == "other" && myForm.other_six.value == ""){			errors = true;		myEl = getElement('six_how_find');		myEl.className = 'question_title_red';		myEl = null;		}else{		myEl = getElement('six_how_find');		myEl.className = 'question_title';		myEl = null;				}		// check if yes is ticked on 9,11 0r 13, and show error if they have not entered anything	// nine	var nineBtn = validateRadioBtn(myForm.nine);	if(nineBtn == null){			errors = true;		myEl = getElement('q_nine');		myEl.className = 'question_title_red';	}else{			//check if they slected yes		if(nineBtn == 'yes'){					//check they entered something in the text field			if(myForm.answer_nine.value == ""){							errors = true;				myEl = getElement('q_nine');				myEl.className = 'question_title_red';										}else{				myEl = getElement('q_nine');				myEl.className = 'question_title';			}					}else{				myEl = getElement('q_nine');				myEl.className = 'question_title';		}			}	var nineBtn = null;		// eleven	var elevenBtn = validateRadioBtn(myForm.eleven);	if(elevenBtn == null){			errors = true;		myEl = getElement('q_eleven');		myEl.className = 'question_title_red';	}else{			//check if they slected yes		if(elevenBtn == 'yes'){					//check they entered something in the text field			if(myForm.answer_eleven.value == ""){							errors = true;				myEl = getElement('q_eleven');				myEl.className = 'question_title_red';										}else{				myEl = getElement('q_eleven');				myEl.className = 'question_title';			}					}else{				myEl = getElement('q_eleven');				myEl.className = 'question_title';		}			}	var elevenBtn = null;		// thirteen	var thirteenBtn = validateRadioBtn(myForm.thirteen);	if(thirteenBtn == null){			errors = true;		myEl = getElement('q_thirteen');		myEl.className = 'question_title_red';	}else{			//check if they slected yes		if(thirteenBtn == 'yes'){					//check they entered something in the text field			if(myForm.answer_thirteen.value == ""){							errors = true;				myEl = getElement('q_thirteen');				myEl.className = 'question_title_red';										}else{				myEl = getElement('q_thirteen');				myEl.className = 'question_title';			}					}else{				myEl = getElement('q_thirteen');				myEl.className = 'question_title';		}			}	var thirteenBtn = null;		// fourteen	var fourteenBtn = validateRadioBtn(myForm.fourteen);	if(fourteenBtn == null){			errors = true;		myEl = getElement('q_fourteen');		myEl.className = 'question_title_red';	}else{			//check if they slected yes		if(fourteenBtn == 'yes'){					//check they entered something in the text field			if(myForm.answer_fourteen.value == ""){							errors = true;				myEl = getElement('q_fourteen');				myEl.className = 'question_title_red';										}else{				myEl = getElement('q_fourteen');				myEl.className = 'question_title';			}					}else{				myEl = getElement('q_fourteen');				myEl.className = 'question_title';		}			}	var thirteenBtn = null;		// fifteen	var fifteenBtn = validateRadioBtn(myForm.fifteen);	if(fifteenBtn == null){			errors = true;		myEl = getElement('q_fifteen');		myEl.className = 'question_title_red';	}else{			//check if they slected yes		if(fifteenBtn == 'yes'){					//check they entered something in the text field			if(myForm.answer_fifteen.value == ""){							errors = true;				myEl = getElement('q_fifteen');				myEl.className = 'question_title_red';										}else{				myEl = getElement('q_fifteen');				myEl.className = 'question_title';			}					}else{				myEl = getElement('q_fifteen');				myEl.className = 'question_title';		}			}	var fifteenBtn = null;		// seventeen	var seventeenBtn = validateRadioBtn(myForm.seventeen);	if(seventeenBtn == null){			errors = true;		myEl = getElement('q_seventeen');		myEl.className = 'question_title_red';	}else{			//check if they slected yes		if(seventeenBtn == 'no'){					//check they entered something in the text field			if(myForm.answer_seventeen.value == ""){							errors = true;				myEl = getElement('q_seventeen');				myEl.className = 'question_title_red';										}else{				myEl = getElement('q_seventeen');				myEl.className = 'question_title';			}					}else{				myEl = getElement('q_seventeen');				myEl.className = 'question_title';		}			}	var seventeenBtn = null;	// validation for all those radio buttons etc// create new object to hold the var// find in the arrayfor(var i=0; i<radioFields.length; i++){		myCurrentRadioCheck = document.getElementById(radioFields[i]);	mcrLen = myCurrentRadioCheck.id.length;	mcrInd = myCurrentRadioCheck.id.indexOf('_')+1;	mcr = myCurrentRadioCheck.id.substr(mcrInd,mcrLen);		// get the radio element	myCurrentRadio0 = document.getElementsByName(mcr)[0];	// get the radio element	myCurrentRadio1 = document.getElementsByName(mcr)[1];	// get the radio element	myCurrentRadio2 = document.getElementsByName(mcr)[2];	// get the radio element	myCurrentRadio3 = document.getElementsByName(mcr)[3];		if((myCurrentRadioCheck.checked) && (!myCurrentRadio0.checked) && (!myCurrentRadio1.checked) && (!myCurrentRadio2.checked) && (!myCurrentRadio3.checked)){		// get the parent element		parentEl = myCurrentRadioCheck.parentNode.previousSibling.previousSibling;		parentEl = parentEl.parentNode;		if(parentEl.className == "section_field_last" || parentEl.className == "section_field_last_red"){			parentEl.className = "section_field_last_red";		}else{			parentEl.className = "section_field_red";		}		// add to error		errors = true;	}else{			// get the parent element	parentEl = myCurrentRadioCheck.parentNode.previousSibling.previousSibling;	parentEl = parentEl.parentNode;		if(parentEl.className == "section_field_last" || parentEl.className == "section_field_last_red"){		parentEl.className = "section_field_last";	}else{		parentEl.className = "section_field";	}	}}	*/	if(errors){		//alert("A response is required in any of the questions highlighted in RED. Please respond and then submit your feedback again.\n\n Thanks");		document.forms[0].submit();	}else{		document.forms[0].submit();	}}function validateRadio(myBtn,myType,qNo) {var myForm = getElement('survey_one');	if(myType==1){		//checkbox				mcrLen = myBtn.id.length;		mcrInd = myBtn.id.indexOf('_')+1;		mcr = myBtn.id.substr(mcrInd,mcrLen);		mcrobj = "";				for (i=document.getElementsByName(mcr).length-1; i > -1; i--) {			document.getElementsByName(mcr)[i].checked = false;		}	}else{		//radio		myRdoBtn = myBtn.name;		myChkBtn = qNo+myRdoBtn;		myChkBtn = getElement(myChkBtn);				if(!myChkBtn.checked){			myChkBtn.checked = true;		}	}}//remove answers if they untick "yes"// show hide text box	function showHideDiv(El,myState){	var myEl = getElement(El);		if(myState == "show"){		myEl.className = "hidden_field_show";	}else{		myEl.className = "hidden_field";	}}function validateRadioBtn(myBtn) {    var counter = -1;    for (var i=myBtn.length-1; i > -1; i--) {	        if (myBtn[i].checked){			counter = i;			i = -1;		}		    }	    if (counter > -1){		return myBtn[counter].value;    }else{		return null;	}}