progress bar

HI All, 

I have manged to get a countdown progress bar working in my glance view. However, I am now trying to get it to show a countdown or progress too depending on values

the code to draw the countdown bar is 

  function drawProgress(dc, value, maxvalue, codeColor) {
      var h = dc.getHeight();
      var w = dc.getWidth();

      dc.setColor(Graphics.COLOR_DK_GRAY, Graphics.COLOR_TRANSPARENT);
      dc.fillRectangle(value * w / maxvalue + (h / 20), h / 2 - 1, w, h / 20);
      dc.setColor(Colour, Graphics.COLOR_TRANSPARENT);
      dc.fillRectangle(0, h / 2 - (h / 20), value * w / maxvalue, h / 10 + 1);
  }

its is called by 

 drawProgress(dc, value, maxvalue, Colour);

I expect this to be simple but again am unable to fathom, how I make the function show progress towards the maxvalue instead of effectively counting down from max to 0