function _poll_msg_all_error() {
    if (window.location.pathname.substring(0, 4) == '/hr/') {
        alert('Molimo odgovorite na sva pitanja.');
    } else {
        alert('Odgovoriti morate na vsa uprašanja.');
    }
}

function _poll_msg_toc_error() {
    if (window.location.pathname.substring(0, 4) == '/hr/') {
        alert('Morate se slagati sa uvjetima sudjelovanja.');
    } else {
        alert('Morate se strinjati z vsemi pogoji.');
    }
}

function _poll_msg_personal_error() {
    if (window.location.pathname.substring(0, 4) == '/hr/') {
        alert('Molimo unesite sve podatke ispravno.');
    } else {
        alert('Vnesti morate vse podatke.');
    }
}

function _poll_submit(e) {

    var status = true;

    // Check check-box
    $.each([1, 8], function(index, value) {
        if (status == false) {
            return;
        }
        if ($('input[name=q' + value + ']:checked').length == 0) {
            _poll_msg_all_error();
            $('input[name=q' + value + ']').focus();
            status = false;
        }
    });

    // Stop on errors
    if (status == false) {
        e.preventDefault();
        return;
    }

    // Check check-box
    $.each([2,3,4,5,6,7,9,10,11], function(index, value) {
        if (status == false) {
            return;
        }
        if (!$("input[name='q" + value + "']:checked").val()) {
            _poll_msg_all_error();
            $('input[name=q' + value + ']').focus();
            status = false;
        }
    });

    // Stop on errors
    if (status == false) {
        e.preventDefault();
        return;
    }
}

function _personal_submit(e) {

    var status = true;

    // Check check-box
    $.each(['toc', 'msg'], function(index, value) {
        if (status == false) {
            return;
        }
        if ($('input[name=' + value + ']:checked').length == 0) {
            _poll_msg_toc_error();
            $('input[name=q' + value + ']').focus();
            status = false;
        }
    });

    // Stop on errors
    if (status == false) {
        e.preventDefault();
        return;
    }

    // They enter?
    $('input[type=text]').each(function(index, value) {
        if (status == false) {
            return;
        }
        if ($(value).val().length == 0) {
            _poll_msg_personal_error();
            $(value).focus();
            status = false;
        }
    });

    // Stop on errors
    if (status == false) {
        e.preventDefault();
        return;
    }
}

