2 things:
1: in the 'if mouse pressed over online' thing, instead of var Result = "thing"
, I would recommend Result = "thing"
(it would be preferable if it is defined once, it can be defined in or out of the loop, depending on the code stuff) [also I'm pretty sure u can't use getKeyValue on things other than key/value pairs so maybe change Result/the other variables in (s)getKeyValue to a key/value pair?]
2: Only define things once or else it'll break sometimes (I know from personal experience)