Inserting Text into a preexisting HTML file

Hey guys

i have a pickle of a problem here.

i have an ALL html website im working on. and for the index page i have 3 pics and 3 captions for them that need to be randomly inserted into the top of the page. right now i have a script that works for the images. but i need to be able to insert A B or C text when A B or C image is displayed. ive searched the forums and google for hours on end today trying to find out how to do this. here is my code:

<script language="JavaScript" type="text/JavaScript">
<!--
    /* ---------------------------------------
    Begin Random Image script copied from www.monkeyslunch.com 
    -------------------------------------------*/
    thePictures = new Array("images/didyouknow_safechild.jpg",
"images/didyouknow_internetsafety.jpg", "images/didyouknow_sor.jpg")
    imageCount = thePictures.length
    
    function choosePicture()
    {
        if (document.images)
        {
            //choose a random number
            randomNumber = Math.floor((Math.random() * imageCount))
            //the random number determines which item in the array to display
            document.randomPicture.src = thePictures[randomNumber]
            }
        }
    /* ---------------------------------------
    End Random Image script 
    -------------------------------------------*/
</script>
<!-- This changes spacer.gif to the random pic -->
<img src="images/spacer.gif" alt="Random Image" name="randomPicture"
width="355" height="255" border="0" />

and i tried this within the if statement:

if (randomNumber == 0)
            {
            document.write("hello world 1");
            }if (randomNumber == 1)
            {
            document.write("hello world 2");
            }if (randomNumber == 2)
            {
            document.write("hello world 3");
            }

Only problem is that with this method, it works in choosing the correct text to display, but it overrides all of the html on the page so i end up with a page that says “Hello World 1 2 or 3” but nothing else :’(

i know its probably a noob question, but how can i take that text and put it in a <div> or <p> or anythign that doesnt override the entire page.

p.s. changing htm to any other extension. or generating the entire page with javascript or anything like that is not able to be done. everythign has to stay the way it is.

Any help would be greatfully appreciated.