
   //////////
   // для языковых тестов

   function step2() {
        if ( document.anketa.fio.value=="" ) {
                alert( "Как вас зовут? Укажите ФИО" );
                document.anketa.fio.focus();
                return false;
        } else
        if ( document.anketa.email.value=="" ) {
                alert( "Вы не ввели контактный адрес электронной почты" );
                document.anketa.email.focus();
                return false;
        }
        document.getElementById( "answers" ).style.display = "";
        document.getElementById( "contacts" ).style.display = "none";

        // start the timer (20 min)
        stopTime = false;
        decreaseTimer();
   }
   function decreaseTimer() {
        if ( stopTime === true ) return;
        counter--;
        var min = Math.floor( counter/60 );
        var sec = counter - min*60;
        teg = document.getElementById( "timer" );
        teg.innerHTML = "До конца теста осталось <b>" + ( min + ":" + ( sec<10 ? "0" + sec : sec ) );
        teg.style.color = ( min < 2 ) ? "red" : "green";
        counter > 0 ? setTimeout("decreaseTimer()", 1000) : submitb();
   }
   function stopTimer() {
        stopTime = true;
        document.getElementById( "submitbutton" ).style.display = "none";
        document.anketa.submit();
   }


        function question( id, trueanswer ) {
                this.elem = eval("document.anketa.quest_"+id);
                this.trueanswer = trueanswer;
                this.verify = verify;
        }
        function verify() {
                var res = ( this.elem[this.elem.selectedIndex].value == this.trueanswer );
                this.elem.style.background = ( res ) ? "white" : "red";
                return res;
        }

        var numquest = trueanswers.length;
        function submitb() {
                document.anketa.action = '/send_form.php?res=204';
                total = 0;
                for (z=1; z<=numquest; z++) {
                        q = new question( z, trueanswers[z-1] );
                        if ( q.verify() ) total++;
                }
                alert( "Правильных ответов: "+total+"\n"+"Неправильных ответов: "+(numquest-total)+"\nАнкета отправлена преподавателю" );
                stopTimer();
        }