25 function MWJ_findObj( oName
, oFrame
, oDoc
) {
26 /* MWJ_findObj function got from
27 * http://www.howtocreate.co.uk/tutorials/javascript/elementcontents
29 * if not working on a layer, document should be set to the
30 * document of the working frame
31 * if the working frame is not set, use the window object
32 * of the current document
33 * WARNING: - cross frame scripting will cause errors if
34 * your page is in a frameset from a different domain */
35 if( !oDoc
) { if( oFrame
) { oDoc
= oFrame
.document
; } else { oDoc
= window
.document
; } }
37 //check for images, forms, layers
38 if( oDoc
[oName
] ) { return oDoc
[oName
]; }
40 //check for pDOM layers
41 if( oDoc
.all
&& oDoc
.all
[oName
] ) { return oDoc
.all
[oName
]; }
43 //check for DOM layers
44 if( oDoc
.getElementById
&& oDoc
.getElementById(oName
) ) {
45 return oDoc
.getElementById(oName
); }
47 //check for form elements
48 for( var x
= 0; x
< oDoc
.forms
.length
; x
++ ) {
49 if( oDoc
.forms
[x
][oName
] ) { return oDoc
.forms
[x
][oName
]; } }
51 //check for anchor elements
52 //NOTE: only anchor properties will be available,
53 //NOT link properties (in layers browsers)
54 for( var x
= 0; x
< oDoc
.anchors
.length
; x
++ ) {
55 if( oDoc
.anchors
[x
].name
== oName
) {
56 return oDoc
.anchors
[x
]; } }
58 //check for any of the above within a layer in layers browsers
59 for( var x
= 0; document
.layers
&& x
< oDoc
.layers
.length
; x
++ ) {
60 var theOb
= MWJ_findObj( oName
, null, oDoc
.layers
[x
].document
);
61 if( theOb
) { return theOb
; } }
63 //check for frames, variables or functions
64 if( !oFrame
&& window
[oName
] ) { return window
[oName
]; }
65 if( oFrame
&& oFrame
[oName
] ) { return oFrame
[oName
]; }
67 //if checking through frames, check for any of the above within
69 for( var x
= 0; oFrame
&& oFrame
.frames
&& x
< oFrame
.frames
.length
; x
++ ) {
70 var theOb
= MWJ_findObj( oName
, oFrame
.frames
[x
], oFrame
.frames
[x
].document
); if( theOb
) { return theOb
; } }
79 var theOb
= MWJ_findObj( 'your_mom' );
80 for (i
= 0; i
< setSize
; i
++) {
81 var newdiv
= document
.createElement('span');
82 newdiv
.setAttribute('id', 'thing_' + i
);
83 newdiv
.setAttribute('class', margins
[i
]);
84 newdiv
.innerHTML
= contents
[0][i
][0];
85 theOb
.appendChild(newdiv
);
86 wordsLeft
[i
] = contents
[0][i
].length
- 1;
87 itersLeft
+= wordsLeft
[i
];
89 setTimeout(iterate
, initial
);
94 set = (set + 1) % sets
;
95 for (i
= 0; i
< setSize
; i
++) {
96 wordsLeft
[i
] = contents
[set][i
].length
- 1;
97 itersLeft
+= wordsLeft
[i
];
99 setTimeout(iterate
, pause
);
103 var ind
= Math
.floor(Math
.random() * itersLeft
);
104 var i
= findIndex(ind
);
105 var newdiv
= MWJ_findObj('thing_' + i
);
107 var index
= contents
[set][i
].length
- wordsLeft
[i
];
109 alert("too small @" + i
);
111 if (index
>= contents
[set][i
].length
) {
112 alert("too big @" + i
);
114 newdiv
.innerHTML
= contents
[set][i
][index
];
118 setTimeout(iterate
, delta
);
121 function findIndex(ind
) {
122 var count
= wordsLeft
[0];
124 while (count
<= ind
) {
126 count
+= wordsLeft
[i
];