// JavaScript Document
function image(_name) {
  this.name = _name;
  this.width = 0;
  this.height = 0;
}

images = new Array();
images[0] = new image( "randomize/1.jpg");
images[1] = new image( "randomize/1.jpg");
images[2] = new image( "randomize/2.jpg");
images[3] = new image( "randomize/3.jpg");
images[4] = new image( "randomize/4.jpg");
images[5] = new image( "randomize/5.jpg");
images[6] = new image( "randomize/6.jpg");
images[7] = new image( "randomize/7.jpg");
images[8] = new image( "randomize/8.jpg");
images[9] = new image( "randomize/9.jpg");
images[10] = new image( "randomize/10.jpg");
images[11] = new image( "randomize/11.jpg");
images[12] = new image( "randomize/12.jpg");
images[13] = new image( "randomize/13.jpg");
images[14] = new image( "randomize/14.jpg");
images[15] = new image( "randomize/15.jpg");
images[16] = new image( "randomize/16.jpg");
images[17] = new image( "randomize/17.jpg");
images[18] = new image( "randomize/18.jpg");

// This function returns an image tag that can be written to the html document
function randomImageTag(imgs) {
  // index to the selected image
  var idx = Math.floor(Math.random() * imgs.length);

  var tag = "<img src=\"" + imgs[idx].name + "\"";

  // if image width is defined
  if (imgs[idx].width != 0)
    tag += " width=" + imgs[idx].width;

  // if image height is defined
  if (imgs[idx].height != 0)
    tag += " height=" + imgs[idx].height;
 
  tag += ">";

  return tag;
}

function randomImage(imgs) {
  // index to the selected image
  var idx = Math.floor(Math.random() * imgs.length);

  var tag = "<img src=\"html/" + imgs[idx].name + "\"";

  // if image width is defined
  if (imgs[idx].width != 0)
    tag += " width=" + imgs[idx].width;

  // if image height is defined
  if (imgs[idx].height != 0)
    tag += " height=" + imgs[idx].height;
 
  tag += ">";

  return tag;
}

// End -->
