var f1Bufer = false;
var isCheck = true;
var isPhotoOnPage = true;

var varsMustToBe = new Array(
    "name",
    "team",
    "hair",
    "eyescolor",
    "bdate",
    "source",
    "why",
    "study_place",
    "speciality",
    "why_you",

    "hphone",
    "email",
    "address",

    "params",
    "height",
    "weight",
    "fsize",
    "csize",
    "fcolor",
    "cosmetics",
    "undercloses"

    );

function f1Clear() {
    if(!f1Bufer) {
        document.form_anketa.f1.value = '';
        f1Bufer = true;
    }
}

function setChosenPhoto(img) {
    if(document.form_anketa.chosen.value) {
        unchecked = document.getElementById(document.form_anketa.chosen.value);
        unchecked.className = 'unchecked';
        checked = document.getElementById(img);
        checked.className = 'checked';
        //mainPhoto = document.getElementById('mainPhoto');
        //mainPhoto.src = PIC_DIR + img.replace(/%/g, '%25');

        document.form_anketa.chosen.value = img;
    }
}

function noCheck() {
    isCheck = false;
    document.form_anketa.action += '#photos';
}

function checkForm() {
    if(isCheck) {
        ok = true;
        for(i = 0; i < varsMustToBe.length; i++) {
            //alert(varsMustToBe[i]);
            if(!document.form_anketa.elements[varsMustToBe[i]].value) {
                if(warningEement = document.form_anketa.elements[varsMustToBe[i]].parentElement)
                    warningEement.className = 'warning';
                ok = false;
            }
            else {
                if(warningEement = document.form_anketa.elements[varsMustToBe[i]].parentElement)
                    warningEement.className = 'unwarning';
            }
        }
        if(ok) {
            if(!document.form_anketa.uploadName.value) {
                if(warningEement = document.form_anketa.uploadName.parentElement)
                    warningEement.className = 'warning';
                alert('Добавьте фотографию');
                return false;
            }
            if(document.form_anketa.f1.value == 'Введите ваш текст')
                document.form_anketa.f1.value = '';
            return true;
        }
        else {
            alert('Пожалуйста, заполните все обязательные поля');
            return false;
        }
    }
    else
        return true;
}

function checkPhoto() {
    return isPhotoOnPage;
}

function isPhoto() {
    if(!document.form_anketa.uploadName.value) {
        alert('Выберите фотографию');
        isPhotoOnPage = false;
    }
    else  {
        isPhotoOnPage = true;
    }
}
