// functions for survey PDF checkbox handling

function select_all() {
	var form = document.surveyForm;
	var rows = form.num_rows.value;
	for(i=1;i<=rows;i++) {
		row = eval("form.get_survey_"+i)
		row.checked = true;
	}
	make_list(form,rows);
}


function deselect_all() {
	var form = document.surveyForm;
	var rows = form.num_rows.value;
	for(i=1;i<=rows;i++) {
		row = eval("form.get_survey_"+i)
		row.checked = false;
	}
	make_list(form,rows);
}

function make_list(form,num_rows) { 
	// looking for fields named 'get_survey_1' thru 'get_survey_X'
	var lo = 1; 		
	var hi = num_rows; 
	var listStr=""; 
	for (i=lo; i<=hi; i++) {
		a = "form.get_survey_" + i;
		// Allow for missing "i's" in the sequence of variable names
		if (typeof eval(a) == "undefined") continue;

		if (eval(a + ".checked")) { 
			listStr += eval(a + ".value"); 
			listStr += ","; 
		}
	}
	form.pdf_list.value = listStr.slice(listStr,-1); 
	//alert(form.pdf_list.value);
}

function check_form(form,rows) { // check to see if a box is checked
	var is_checked = 0;
	for(i=1;i<=rows;i++) {
		row = eval("form.get_survey_"+i)
		if(row.checked) is_checked++;
	}
	if(!is_checked) {
		alert('You must select at least one document.');
		return false;
	} else {
		return true;
	}
}