1) document specified without quotes:
$(document).ready(function(){...});
2) $(document).ready(function(){...}); - this is not pure JS, so that it runs, you need to connect the Jquery library
3) function system(){...} course, you can specify it in document ready , but usually it is passed for it:
function system(){...}; $(document).ready(function() {...});
4) Starting the function from the button can be done like this:
$('button').on('click', system);
or so
$('button').on('click', function() { system() });
And this is also not pure JS, you need the Jquery library
5) Your variables are listed differently:
var a1 = $('#value1').val(); // Тут "a1" if (a!=null){ // тут "a" ... }else{ ... }
Change to
var a1 = $('#value1').val(); if (a1 == null){ ... }else{ ... }