Random image with corresponding text?

i have a script that is close to working, but not quite. it loads 1 of 9 random images on pageload with the corresponding link on the image. that works fine. i am trying to also get the corresponding copy to appear next to it, but it seems to be totally random as well and not matching up with its proper image (for example, if image 5 loads, then copy 5 should be the one that loads). below is what i have.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

</head>

<body>
<table width="100%" height="150" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="150">
<script language="JavaScript">
 
var imagenumber = 9 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
 
 
images = new Array
images[1] = "i1.jpg"
images[2] = "i2.jpg"
images[3] = "i3.jpg"
images[4] = "i4.jpg"
images[5] = "i5.jpg"
images[6] = "i6.jpg"
images[7] = "i7.jpg"
images[8] = "i8.jpg"
images[9] = "i9.jpg"
var image = images[rand1]
 
 
links = new Array
links[1] = "http://www.i1.com"
links[2] = "http://www.i2.com"
links[3] = "http://www.i3.com"
links[4] = "http://www.i4.com"
links[5] = "http://www.i5.com"
links[6] = "http://www.i6.com"
links[7] = "http://www.i7.com"
links[8] = "http://www.i8.com"
links[9] = "http://www.i9.com"
var link = links[rand1]
 
var Quotation=new Array()
 
Quotation[1] = "i1 copy here";
Quotation[2] = "i2 copy here";
Quotation[3] = "i3 copy here";
Quotation[4] = "i4 copy here";
Quotation[5] = "i5 copy here";
Quotation[6] = "i6 copy here";
Quotation[7] = "i7 copy here";
Quotation[8] = "i8 copy here";
Quotation[9] = "i9 copy here";
 
document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" border="0"></a>')</script></td>
 
 
 
<td valign="top" width="100%"><font face="Arial, Helvetica, sans-serif" size="2" color="#000000">
<script language="JavaScript">var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();</script></font>
</td>
</tr>
</table>
</body>
</html>

figured it out:

<script language="JavaScript">

function showQuotation(){document.write(Quotation[rand1]);}
showQuotation();</script></font>

just inserted the already generated ‘rand1’ from the image randomizer instead of having a totally new one. thanks.