You have a scope problem, I suggest you read a little about it, because you can improve your javascript per ton, but you can solve this in two ways:
var inv_count;
or
$(document).ready(function() { var inv_count = 3; function blah(a,b) { alert (inv_count); }
I also recommend that you read clousures if you do not know how they work.
source share