/*******************************************************************************
* Javascript functions correspond to page A of the DACV study questionnaire 
* Written on 6/27/05 by Jim Moler 
********************************************************************************/
function loadPage(button) {
	//refreshReferences();
	refreshPartOfMainStudy();
	
	if (button == "investigator"){
		getFormObjectReverse(new RegExp("^investigator\\d{2}_first_name$")).focus();
	}
	else if (button == "institution"){
		getFormObjectReverse(new RegExp("^institution\\d{2}_institution$")).focus();
	}
	else{
		document.forms[0].title.focus();
	}
} //loadPage

function refreshReferences() {
	with (document.forms[0]) {	
		if(published[0].checked == true) { //published
			if (getFormObject(new RegExp("^pub_ids_selected$"))) { //test for existence before enabling
				for (var i=0; i < pub_ids_selected.length; i++) 
					enableThis(pub_ids_selected[i]);
			}
			enableThis(references);
		}
		else { //not published, in press, or radio button not selected yet.
			if (getFormObject(new RegExp("^pub_ids_selected$"))) { //test for existence before disabling			
				for (var i=0; i < pub_ids_selected.length; i++) 
					disableThis(pub_ids_selected[i]);
			}
			disableThis(references);
		}	
	}
} //refreshReferences


function refreshOtherMainStudySpecified() {
	with (document.forms[0]) {
		if(other_main_study.checked == true) { //other main study
			enableThis(other_main_study_specified);
		}
		else {	
			disableThis(other_main_study_specified);
		}
	}
} //refreshOtherMainStudySpecified


function refreshPartOfMainStudy() {
	with (document.forms[0]) {
		if(part_of_main_study[0].checked == true) {  //part of main study
			enableThis(cohort);
			enableThis(case_control);
			enableThis(survey);
			enableThis(clinical_trial);
			enableThis(other_main_study);
			enableThis(hypothesis);
		}
		else{
			disableThis(cohort);
			disableThis(case_control);
			disableThis(survey);
			disableThis(clinical_trial);
			disableThis(other_main_study);
			disableThis(other_main_study_specified);
			disableThis(hypothesis);
		}
		refreshOtherMainStudySpecified()
	}
} //refreshPartOfMainStudy



