Problem with a timed threshold..... I think?

Please post your code inside code tags. I'm not going to bother trawling through it until you have changed it.