Complicated Rounding

So here is my issue… I need to be able to round a given number to an even number that is divisible by 10, 100, or 1000 depending on it’s size.
**
For example:**

4 would be 0 – Round to nearest 10
6 would be 10 – Round to nearest 10
54 would be 50 – Round to nearest 10
1440 would be 1400 – Round to nearest 100
16777 would be 16700 – Round to nearest 100
238498 would be 238000 – Round to nearest 1000
4673829 would be 4674000 – Round to nearest 1000
12384767 would be 12384000 – Round to nearest 1000

I’ve been scanning the WWW for a formula to do this in as3, but have come up empty handed.

Any ideas?
-AR