great. now time for copying and make some adjustment (i hope not). thanks!

If you dont mind i will (with some time) transfer this logic to other language too. php perhaps..