var Consult = {
    question: 0,
    answer: 1,
    owner: 3,
    formId: function(type) {
        switch (type) {
            case this.owner:
                return 'ownerQuestionForm';
                break;
            case this.answer:
                return 'answerForm';
                break;
            default:
                return 'questionForm';
        }
    },
    validateForm: function(type) {
        var f = document.getElementById(this.formId(type));
        var question = f.question.value;
        if (type == Consult.answer || type == Consult.owner) {
            if (!question) {
                alert('Введите, пожалуйста текст ответа!');
                return false;
            }
        } else {
            var sex = f.sex.value; 
            var age = f.age.value; 
            if (!question || !sex || !age) {
                alert('Для того, чтобы ответ был Вам полезен.\nУкажите, пожалуйста помимо текста вопроса,\nВаше пол и возраст.\n\nСпасибо.');
                return false;
            }
        }
        return true;
    },
    toggleQuestionForm: function() {
        var f = document.getElementById('questionForm');
        if (f.style.display == 'none') {
            f.style.display = '';
        } else {
            f.style.display = 'none';
        }
    }
}
