bar = function(val, max)
	if val > 100 then
		val = 100;
	end
	local n = max * val / 100;
	local i
	local v=''
	local k = max / 3;
	for i = 1, n do
		if i <= max / 3 then
			v=v..img('images/bar_red.png');
		elseif i <= (max * 2) / 3 then
			v=v..img('images/bar_yellow.png');
		else
			v=v..img('images/bar_green.png');
		end
	end
	return v;
end
