function checkLocation(el, title, msg_location) {
    var alertF = $(msg_location);
    if (el.val() == title || el.val() == '') {
        el.val(title);
        alertF.html(messages.location.invalid_address).effect('highlight', {}, 2000);
        return;
    }

    el.oldVal = el.val();
    setTimeout(function() {
        $.get('/check_location', {location_name: el.val()}, function(data) {
            data = JSON.parse(data);
            if (data.length > 1) {
                alertF.html(messages.location.multiple_found).effect('highlight', {}, 2000);
            } else if (data.length == 0) {
                alertF.html(messages.location.invalid_address).effect('highlight', {}, 2000);
            } else {
                el.val(data[0].name);
                alertF.html(messages.location.address_validated).effect('highlight', {}, 2000);
            }
        });
    }, 500);
}

function resetField(el, title) {
    if (el.val() == title) {
        el.val('');
    }
}
