//
// create constructor function for user defined image object
// _name: image URL
// _width: image width. 
//         _width == 0 ==> image width undefined
// _height: image height;
//         _height == 0 ==> image height undefined
//
function image(_name, _width, _height) {
  this.name = _name;
  this.width = _width;
  this.height = _height;
}

// create array of image objects
jslogo = new Array();
jslogo[0] = new image("images/img-main-couple.gif", 548, 257);
jslogo[1] = new image("images/img-main-runningshoes.gif", 548, 257);
jslogo[2] = new image("images/img-main-footprints.gif", 548, 257);
jslogo[3] = new image("images/img-main-ofoot.gif", 548, 257);


// 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;
}
