﻿// Focus on a field
function foc(field) {
	document.getElementById(field).focus();
}

// Focus on a field and select text inside
function fs(field) {
	document.getElementById(field).focus();
	document.getElementById(field).select();
}

// Show / hide a question that's wrapped in a div called questionXX where XX is the
// question #
function hide(qno) {document.getElementById('divQ'+qno).style.display='none';}
function show(qno) {document.getElementById('divQ'+qno).style.display='block';}

// If customer selects an "other" checkbox, make an "other" text field appear next to
// it
//
// Should be called from the onclick event of the checkbox
function toggleOtherChkBx(qno) {
	var obj = document.getElementById('spQ'+qno+'_Other');
	var objDisp = document.getElementById('hfQ'+qno+'_OtherDisp');
	if (objDisp.value=='none') {
		obj.style.display='inline';
		objDisp.value='inline';
	}else{
		obj.style.display='none';
		objDisp.value='none';
	}
}

// If customer selects "other" from a drop-down list, make an "other" text field
// appear next to it
//
// Should be called from the onchange event of the DDL
function toggleOtherSel(qno, ddlId) {
	var obj = document.getElementById('spQ'+qno+'_Other');
	var objDisp = document.getElementById('hfQ'+qno+'_OtherDisp');
	var sel = document.getElementById(ddlId);
	if (sel.options[sel.options.selectedIndex].value=='Other') {
		obj.style.display='inline';
		objDisp.value='inline';
	}else{
		obj.style.display='none';
		objDisp.value='none';
	}
}

// Read value of hidden field 'questionXXotherDisp' and apply it to the css display
// property of the span tag 'questionXXother' - allows display state of 'Other' text
// boxes to persist between page views
//
// Should be called from the onload event of the span tag
function displayOther(qno) {
    var obj = document.getElementById('spQ'+qno+'_Other');
	var objDisp = document.getElementById('hfQ'+qno+'_OtherDisp');
	obj.style.display = objDisp.value;
}