Here's my hint:
http://www.dataschenk.com/Tips/JSSubstring.htm

You aren't doing the substring(start, end) correctly.
foo='012345';
blah = foo.substring(1,2); // would return '1'.
blah = foo.substring(0,3); // returns '012';

Forgive me if my javascript syntax is not up to any standard of even mediocraty. I tend to shy away from most everything client side.

Peace,
Dhej