var o_ajax = 0; var o_usage_state = []; function o_usage(id, usage) { o_usage_state[id] = usage; $('#' + id).attr('src', 'check' + usage + '.png'); } function o_usage_click(el, button) { } function o_usage_reset(type) { if (o_ajax) return; o_ajax = 1; var reset = []; $('.usage-' + type).each(function(i, el) { $(el).attr('src', 'check0.png'); reset.push({power: $(el).attr('id'), usage: 0}); }); $.ajax({ type: 'post', cache: false, url: 'ajax.php', data: { id: 1090, reset: reset }, success: function() { o_ajax = 0; } }); } $(document).ready(function() { $('img.usage').mousedown(function(e) { o_usage_click(this, e.which); }); $('img.usage').bind('contextmenu', function(e) { return false; }); });