﻿ function chooseOption( theId ) {
            var opt = document.getElementById( theId );
            if (opt) {
                opt.focus();
            }
        }
        
        function checkOption( theId ) {
            var opt = document.getElementById( theId );
            if (opt) {
                opt.checked = "checked";
            }
        }
    

        function onlyDigits(evt) {
            var keycode;
         
            if (evt)
                ;
            else if (window.event)
                evt = window.event;
            else if (event)
                evt = event;
            else
                return true;
         
            if (evt.charCode)
                keycode = evt.charCode;
            else if (evt.keyCode)
                keycode = evt.keyCode;
            else if (evt.which)
                keycode = evt.which;
            else
                keycode = 0;
         
            return (keycode >= 13 && keycode <= 57);
        }

    
        // Validates the user's input
        function validateInput()
        {
            // Get number of selected options --->
            
            var totalSelected = 0;
                
            for (n = 0; n < cbarray.length; n++)
            {
                if (document.getElementById(cbarray[n]).checked) totalSelected++;
            }
            
            // --->
            
            if (numChoices > 1)
            {
                // Check-box list --->
                
                if (totalSelected != numChoices)
                {
                    alert("Please select " + numChoices + " answers.");
                    return false;
                }
            }
            else
            {
                // Radio-button list --->
                
                if (totalSelected == 0)
                {
                    alert("Please select an answer.");
                    return false;                    
                }
            }
            
            return true;
        }
        
