I use this function from http://sedition.com/perl/javascript.html 

function randomColor(){
   var rgbColor = ‘’;
   for ( i = 1; i < 4; i++ ) {
      rgbColor +=  Math.floor(Math.random() * (250+1));
      if ( i != 3 ) rgbColor += ‘,’;
   }
   //window.status = rgbColor;
   return"rgb("+rgbColor+")";
 }

 Usage example:

element.style.backgroundColor = randomColor();