About link

hi guys! i have a problem in this javascript…i made an outline and i wanted to happen that when i visited the page the text color will change it to red so that the user will know that this is a active page…and when i go to the next page the text color will turn into gray to know that it was visited already…but the problem is it wont work that way…the text color would only change into red if your in the fourth link and the first link will turn into gray color…i hope u can help me on this…ive attched my script so that you can see the problem in my code.THANKS!