Hi,
Is this line just for testing to see that the right id was assigned?
new_link.onclick= function(){ alert(count); };
if so try changing it to this..
new_link.onclick= function(){ alert(this.id); };
Because the onclick function is always going to tell you the final value of count after its been incremented.
A great tool for mozilla firefox is firebug, which lets you inspect the id's of elements that have been created dynamically.