Just dumping all your code and telling us that it doesn't work isn't really good enough. You need to debug your code and narrow down where the issue occurs, then you need to provide only the relevant code, along with a FULL and CLEAR description of the problem, including what you're trying to achieve, how you're trying to achieve it and what happens when you try.