// *************************************************************************************************
// *** HTML generator functions.
// *************************************************************************************************
// Return HTML code for an image with the given attributes.
function getImage(imageName, imageSize, caption, URL, target)
{
  // *** Variable declarations. ***
  var o, p, hasLink, data;
  
  // *** Error check. ***
  imageName = String(imageName);
  if((imageName == null) || (imageName == '') || (imageSize == null)) return '';
  caption = String(caption);
  if((caption == null) || (caption == '')) caption = '&nbsp;';
  URL = String(URL);
  hasLink = (URL != null) && (URL != '');
  target = String(target);
  if((target == null) || (target == '')) target = '_this';

  // *** Compose link. ***
  if(hasLink)
  {
    o = new Array(5);
    p = 0;
    o[p++] = '<a class="menu-item" href="';
    o[p++] = URL;
    o[p++] = '" target="';
    o[p++] = target;
    o[p++] = '">';
    data = o.join('');
  }
  
  // *** Initialise. ***
  o = new Array(23);
  p = 0;

  // *** Compose HTML. ***
  o[p++] = '<div class="frame" style="width: ';
  o[p++] = String(imageSize[0] + 10);
  o[p++] = 'px;"><div class="image">';
  if(hasLink) o[p++] = data;
  o[p++] = '<img src="';
  o[p++] = imageName;
  o[p++] = '" width="';
  o[p++] = String(imageSize[0]);
  o[p++] = '" height="';
  o[p++] = String(imageSize[1]);
  o[p++] = '" alt="';
  o[p++] = caption;
  o[p++] = '" border="0">';
  if(hasLink) o[p++] = '</a>';
  o[p++] = '</div><table cellspacing="0" cellpadding="0" style="width: ';
  o[p++] = String(imageSize[0]);
  o[p++] = 'px;"><tr><td class="image-caption">';
  o[p++] = caption;
  o[p++] = '</td>';
  if(hasLink)
  {
    o[p++] = '<td style="text-align: right;">';
    o[p++] = data;
    o[p++] = 'Full st&oslash;rrelse</a></td>';
  }
  o[p++] = '</tr></table></div>';
  return o.join('');
}

// *************************************************************************************************

