So, I have a client that wants a new background image every time page is reloaded. I thought I have to script and thought I had it working but when I applied it to all my pages from a template I made in dreamweaver it doesn't work. It only works on the template. Any ideas....??? Oh, FYI I have no background css so things won't get confused. See code below.

<script type="text/javascript">
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");

function MM_displayStatusMsg(msgStr) { //v1.0
document.MM_returnValue = true;


var randombgs=["../images/main_background.png", "../images/main_background2.png", "../images/main_background3.png", "../images/main_background4.png", "../images/main_background.png", "../images/main_background2.png", "../images/main_background3.png", "../images/main_background4.png"]

document.write('<body background="'+randombgs[Math.floor(Math.random()*randombgs.length)]+'" bgcolor="#FFFFFF">')

I don't know about your javascript, but if you know PHP you can use it in a CSS file and then randomly generate the background image there.