
function is_blank(str) {
    if(/\S+/.test(str))
    {
        return false;
    } else {
        return true;
    }
}

function check_form(the_form, form_fields, form_fields_names) {
    alert_string = "";
    focus_element = null;

    nom = 0;
    for (i = 0; i < form_fields.length; i++) {
        if (("checkbox" == the_form[form_fields[i]].type && false == the_form[form_fields[i]].checked) ||
        is_blank(the_form[form_fields[i]].value))
        {
            alert_string += ++nom + ". " + form_fields_names[i] + "\n";
            if (null == focus_element) focus_element = the_form[form_fields[i]];
        }
    }

    if ("" != alert_string) {
        alert(alert_string);
        focus_element.focus();
        return false;
    }

    return true;
}

function hide() {
    for(var i=0; i<arguments.length; i++) {
        element = document.getElementById(arguments[i]);
        if (element) {
            element.style.display = 'none';
        }
    }
}

function show(eleventName, className) {
    for(var i=0; i<arguments.length; i++) {
        element = document.getElementById(arguments[i]);
        if (element) {
            element.style.display = 'block';
        }
    }
}

function show_field_length(obj, max) {
    var val = obj.value;
    if(!max) var max = obj.maxLength;

    if(!max) {
        return;
    }

    var obj_length = document.getElementById(obj.name + '_length');
    if (obj_length) {
        obj_length.value = max - val.length;
    }
}

function submitAction(action_desc, question) {
    if (!question) {
        question = 'Вы действительно хотите';
    }
    if (!action_desc) {
        action_desc = 'выполнить данное действие';
    }
    question = question + ' ' + action_desc + '?';

    if (confirm(question)) {
        return true;
    }

    return false;
}
