function progressShow(balance){
var step = $("#collecting-line").width() / 15;
var i = 0;
while (i < balance) {
$("#collecting-progress").animate({width: step * i}, 200);
$("#current-balance").animate({content: i+'$'}, 200);
i++
}
}
(function myLoop (i) { //Loop with delay sample
setTimeout(function () {
alert('hello'); // your code here
if (--i) myLoop(i); // decrement i and call myLoop again if i > 0
}, 3000)
})(10); // pass the number of iterations as an argument