I'm having this weird problem with one of the modules I'm using. In this module I keep a script that displays random quotes each time a user reloads on of my index pages. (I have 5 index pages and this module is used in all of them):

CODE
<script language="JavaScript" type="text/JavaScript">

function text() {
};

text = new text();
number = 0;

// textArray
//Albert Einstein
text[number++] = "Never do anything against conscience even if the state demands it. - [Albert Einstein 1879-1955 e.o.t.]"
text[number++] = "Great spirits have always encountered violent opposition from mediocre minds. - [Albert Einstein 1879-1955 e.o.t.]"  
// keep adding items here...

increment = Math.floor(Math.random() * number);

document.write(text[increment]);

//-->
</script>
(I have ALOT more quotes then are shown here of course)


Often when I rebuild my index templates, or if I enter a new entry, or a user adds comments (which will rebuild the index entries) some of my index pages crash. They don't seem to be able to run the module so it, and everything that comes after it on the page will not load. Then the only way to fix it is to rebuild the entries a few times until they get fixed.

Why does this happen you think? And why does this just affect one or two of the indexes and not all of them?

Thanks!