You have not asked a question. Simply pasting code and saying it has a problem is not going to get many useful responses.
If your code is not working, try to post simplest example which demonstrates the problem along with an explanation of how you would expect it to work and what you have done to try to resolve it.
Please review the
Site FAQ for guidance in posting your questions and general forum usage. Especially, read the link in that page,
How To Ask Questions The Smart Way. The more effort you put into understanding your problem and framing your questions, the better others can help!
Also, please place your code snippets inside [CODE]...[/CODE]
tags for better readability. You may type those yourself or click the "
#" button in the edit controls.