/* JavaScript Document */
function checkRegistrationForm( field )
{
    var check_field = $("#" + field).val();
    var ok          = '<img src="i/ok.gif" />';
    var flag        = false;
    
    switch( field )
    {
        case 'email':
            if(check_field.length > 5 && $("#" + field).val().indexOf("@") != -1)
            {
                flag = true;
            }
            break;
        case 'registration_password':
            if(check_field.length > 5)
            {
                flag = true;
            }
            break;
        case 'repeat_registration_password':
            if(check_field.length > 5 && $("#registration_password").val().length > 5 && check_field == $("#registration_password").val())
            {
                flag = true;
            }
            break;
        case 'company':
            if(check_field.length > 2)
            {
                flag = true;
            }
            break;
        case 'fio':
            if(check_field.length > 5)
            {
                flag = true;
            }
            break;
        case 'phone':
            if(check_field.length > 7)
            {
                flag = true;
            }
            break;
        case 'town_id':
            if(check_field > 0)
            {
                flag = true;
            }
            break;
        case 'description':
            if(check_field.length > 50)
            {
                flag = true;
            }
            break;
        case 'no_robot':
            if($("#" + field + ":checked").length == 1)
            {
                flag = true;
            }
            break;
    }
    if(flag)
    {
        $("#star_" + field).html(ok);
    } else {
        $("#star_"  + field).html("*");
    }
    if($("#email").val().length > 5 && $("#email").val().indexOf("@") != -1 && $("#repeat_registration_password").val().length > 5 && $("#registration_password").val().length > 5 && $("#repeat_registration_password").val() == $("#registration_password").val() && $("#company").val().length > 2 && $("#fio").val().length > 2 && $("#phone").val().length > 7 && $("#town_id").val() > 0 && $("#description").val().length > 50 && $("#no_robot:checked").length == 1)
    {
        $("#registration_submit").attr("disabled","");
    } else {
        $("#registration_submit").attr("disabled","disabled");
    }
}
function checkForgotForm()
{
    if($("#email").val().length > 5 && $("#email").val().indexOf("@") != -1)
    {
        $("#forgot_submit").attr("disabled","");
    } else {
        $("#forgot_submit").attr("disabled","disabled");
    }
}